After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668239 - texts disappear when notebook switch page at zh_CN locate!
texts disappear when notebook switch page at zh_CN locate!
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.24.x
Other Windows
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
: 674334 678414 682517 691180 701671 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-01-19 04:09 UTC by louis
Modified: 2013-11-22 10:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch that doesn't ensure a native window (5.19 KB, patch)
2012-11-22 10:38 UTC, Michael Natterer
none Details | Review
Patch for same issue on GTK3 (5.20 KB, patch)
2012-11-26 05:00 UTC, Fan, Chun-wei
none Details | Review

Description louis 2012-01-19 04:09:27 UTC
I run gtk-demo.exe on win7 x64 locate="zh_CN", when I switch GtkNotebook pages, texts in GtkTextView on page disappear.

I find the BUG, use msys:

when I run gtk-demo.exe use LC_ALL="C", it works fine.
$ export LC_ALL="C"
$ ./gtk-demo.exe

BUT, when I use LC_ALL="zh_CN", texts disappear~
$ export LC_ALL="C"
$ ./gtk-demo.exe
Comment 1 Michael Natterer 2012-11-09 09:38:28 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=658841

The IME input method needs a native GdkWindow, so in
gtk_im_context_ime_set_client_window() it calls GDK_WINDOW_HWND()
which expands to gdk_win32_drawable_get_handle() which calls
gdk_window_ensure_native().

And the native GdkWindows code is very untested on windows
Comment 2 Michael Natterer 2012-11-09 09:40:08 UTC
*** Bug 674334 has been marked as a duplicate of this bug. ***
Comment 3 Michael Natterer 2012-11-22 10:38:09 UTC
Created attachment 229625 [details] [review]
Patch that doesn't ensure a native window

This patch simply attaches the IME to the existing ->impl window,
which is usually the toplevel. It seems to work fine, but I can't
test this myself (lack of windows).
Comment 4 Michael Natterer 2012-11-23 14:43:50 UTC
Fixed in 2-24. Not closing because this is probably needed in 3.x too,
but hasn't seen any testing there.

commit f357151cc60003000865252135905c6417504dd6
Author: Michael Natterer <mitch@lanedo.com>
Date:   Fri Nov 23 15:39:29 2012 +0100

    Bug 668239 - texts disappear when notebook switch page at zh_CN locate
    
    In gtkimcontextime.c, use gdk_win32_window_get_impl_hwnd() to get to
    the impl's existing native window instead of GDK_WINDOW_HWND() which
    implicitly ensures a native window for the widget itself. This seems
    to work around whatever GDK problem with native subwindows and fixes
    the bug.

 modules/input/gtkimcontextime.c |   34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
Comment 5 Michael Natterer 2012-11-23 16:17:40 UTC
*** Bug 678414 has been marked as a duplicate of this bug. ***
Comment 6 louis 2012-11-23 16:18:52 UTC
Great! I will test soon, need some days because of busy life.

(In reply to comment #4)
> Fixed in 2-24. Not closing because this is probably needed in 3.x too,
> but hasn't seen any testing there.
> 
> commit f357151cc60003000865252135905c6417504dd6
> Author: Michael Natterer <mitch@lanedo.com>
> Date:   Fri Nov 23 15:39:29 2012 +0100
> 
>     Bug 668239 - texts disappear when notebook switch page at zh_CN locate
> 
>     In gtkimcontextime.c, use gdk_win32_window_get_impl_hwnd() to get to
>     the impl's existing native window instead of GDK_WINDOW_HWND() which
>     implicitly ensures a native window for the widget itself. This seems
>     to work around whatever GDK problem with native subwindows and fixes
>     the bug.
> 
>  modules/input/gtkimcontextime.c |   34 +++++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 17 deletions(-)
Comment 7 louis 2012-11-24 16:36:55 UTC
It works when use this patch!!

I test in gtk-2.24.8, use mingw compile.
Comment 8 Dieter Verfaillie 2012-11-24 20:15:29 UTC
Let's leave this open so we don't forget to test if the same fix
is needed in gtk 3...
Comment 9 louis 2012-11-26 03:22:43 UTC
I test use gtk-demo.exe it work, but some other bug still exist.
when I run my program, it crashed!
I use debug version test, I find that 

** context_ime->client_window maybe NULL

so hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
when context_ime->client_window==NULL, it crash!!!

stack:

  • #0 gdk_win32_window_get_impl_hwnd
    at gdkwindow-win32.c line 4120
  • #1 get_utf8_preedit_string
    at gtkimcontextime.c line 373
  • #2 gtk_im_context_ime_get_preedit_string
    at gtkimcontextime.c line 535
  • #3 gtk_im_context_get_preedit_string
    at gtkimcontext.c line 447
  • #4 gtk_im_context_get_preedit_string
    at gtkimcontext.c line 447
  • #5 gtk_entry_create_layout
    at gtkentry.c line 5380
  • #6 gtk_entry_ensure_layout
    at gtkentry.c line 5459
  • #7 gtk_entry_get_cursor_locations
    at gtkentry.c line 5908
  • #8 update_im_cursor_location
    at gtkentry.c line 5305
  • #9 recompute_idle_func
    at gtkentry.c line 5339
  • #10 gdk_threads_dispatch
    at gdk.c line 512
  • #11 g_main_context_dispatch
    from d:\gtk_2.24\bin\libglib-2.0-0.dll
  • #12 g_main_context_iterate.clone.5
    from d:\gtk_2.24\bin\libglib-2.0-0.dll
  • #13 g_main_loop_run
    from d:\gtk_2.24\bin\libglib-2.0-0.dll
  • #14 gtk_main
    at gtkmain.c line 1256


(In reply to comment #8)
> Let's leave this open so we don't forget to test if the same fix
> is needed in gtk 3...
Comment 10 louis 2012-11-26 03:35:07 UTC
I add these code
  if (!GDK_IS_WINDOW (context_ime->client_window))
    return;

before

 hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);

witch forget check context_ime->client_window.

all works fine.


(In reply to comment #9)
> I test use gtk-demo.exe it work, but some other bug still exist.
> when I run my program, it crashed!
> I use debug version test, I find that 
> 
> ** context_ime->client_window maybe NULL
> 
> so hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
> when context_ime->client_window==NULL, it crash!!!
> 
> stack:
> 
>
Comment 11 Fan, Chun-wei 2012-11-26 05:00:21 UTC
Created attachment 229875 [details] [review]
Patch for same issue on GTK3

Hi,

I can confirm that this problem exists in the gtk3 code, as I run Windows 7 in Chinese.  This is the code that is only reached if one is running Windows with IME's installed (which is normally true when one is running Chinese, Korean or Japanese versions of Windows).  So here is the gtk3 version of the patch, which isn't much different (if at all) from the gtk2 patch.

The interesting thing is, if one runs the GTK+ program from the normal Windows command line (cmd.exe), the problem Louis encountered will occur if LC_ALL is not set, otherwise it is alright.

Louis: Can I know what was your program doing when the crash occurred?  I think have fixed this crash in gtk3 with commit a866ed73[1], as it was why the pickers demos crashed in gtk3 (but apparently not in gtk2).  Is it possible that you can build GTK+-3.6.x with my patch and see whether things are alright for you there?

With blessings, thank you!

[1]:Please see http://git.gnome.org/browse/gtk+/commit/modules/input/gtkimcontextime.c?id=a866ed737810ea32ec55260ad512f386a4e6df5d
Comment 12 louis 2012-11-26 05:16:08 UTC
Well, first, I use gdk_win32_window_get_impl_hwnd replace GDK_WINDOW_HWND, and check context_ime->client_window use GDK_IS_WINDOW (context_ime->client_window). everything works fine.

In my tests, whatever use command line or normal windows to run gtk-demo.exe, gtk_notebook switch page cause texts disappear.

I see your patch, you also check context_ime->client_window, but not use gdk_win32_window_get_impl_hwnd replace GDK_WINDOW_HWND, I don't known if it's right.

I have not succeed compile GTK+-3 use mingw, so sorry, I can't test it, but If gtk3 have official publish version, I will test it.

(In reply to comment #11)
> Created an attachment (id=229875) [details] [review]
> Patch for same issue on GTK3
> 
> Hi,
> 
> I can confirm that this problem exists in the gtk3 code, as I run Windows 7 in
> Chinese.  This is the code that is only reached if one is running Windows with
> IME's installed (which is normally true when one is running Chinese, Korean or
> Japanese versions of Windows).  So here is the gtk3 version of the patch, which
> isn't much different (if at all) from the gtk2 patch.
> 
> The interesting thing is, if one runs the GTK+ program from the normal Windows
> command line (cmd.exe), the problem Louis encountered will occur if LC_ALL is
> not set, otherwise it is alright.
> 
> Louis: Can I know what was your program doing when the crash occurred?  I think
> have fixed this crash in gtk3 with commit a866ed73[1], as it was why the
> pickers demos crashed in gtk3 (but apparently not in gtk2).  Is it possible
> that you can build GTK+-3.6.x with my patch and see whether things are alright
> for you there?
> 
> With blessings, thank you!
> 
> [1]:Please see
> http://git.gnome.org/browse/gtk+/commit/modules/input/gtkimcontextime.c?id=a866ed737810ea32ec55260ad512f386a4e6df5d
Comment 13 Fan, Chun-wei 2012-11-26 08:28:19 UTC
(In reply to comment #12)
> I see your patch, you also check context_ime->client_window, but not use
> gdk_win32_window_get_impl_hwnd replace GDK_WINDOW_HWND, I don't known if it's
> right.

Umm, sorry, I was not being clear enough in my comment (comment #11).  What I meant there is that I think I have fixed the crash problem you have mentioned in gtk3 in the commit I have mentioned in [1].  The patch for the redraw problem that we both would get, I have attached in comment #11.

> I have not succeed compile GTK+-3 use mingw, so sorry, I can't test it, but If
> gtk3 have official publish version, I will test it.

I see.  Sorry, since I build GTK+-2/3 with Visual C++, I can't help much with the MinGW builds.  You might want to ask Dieter for the MinGW builds, or let me know if using a Visual C++ 2008 build to test these things are okay for you.

[1]: Please see
http://git.gnome.org/browse/gtk+/commit/modules/input/gtkimcontextime.c?id=a866ed737810ea32ec55260ad512f386a4e6df5d

With blessings.
Comment 14 Michael Natterer 2012-11-26 15:34:43 UTC
I cherry-picked that commit to gtk-2-24 now:

commit 2d57ddd6ef0ef44382be7080484e2408375eb463
Author: Chun-wei Fan <fanchunwei@src.gnome.org>
Date:   Wed Aug 29 14:03:46 2012 +0800

    gtkimcontexttime.c: Check context_ime->client_window is not NULL
    
    Be a bit more careful in get_pango_attr_list() and
    get_utf8_preedit_string() to ensure that the client_window is properly
    created before proceeding, to avoid access violation/segfault crashes on
    Windows with IME installed, especially when running the pickers demo.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682919
    (cherry picked from commit a866ed737810ea32ec55260ad512f386a4e6df5d)

 modules/input/gtkimcontextime.c |    6 ++++++
 1 file changed, 6 insertions(+)
Comment 15 Michael Natterer 2012-11-29 15:28:56 UTC
Is this bug now fixed for everybody? I'd like to close it.
Comment 16 Fan, Chun-wei 2012-11-30 02:31:24 UTC
Hi Michael,

I would like to see whether my patch in comment 11 for gtk3 is good to land, as the problem in this bug is also in gtk3, which takes your approach there as well.

With blessings, thank you!
Comment 17 Fan, Chun-wei 2012-12-13 03:10:28 UTC
Hi,

I think I am going to push the patch in comment 11 anyways to master (commit 656ec39c) and gtk-3-6 (commit 136c7199), as:
-I don't want this to fall into oblivion (sorry)
-It fixed the issue for me, as this also happens on the zh_TW locale on Windows.(thanks Michael)

I will close the bug as a result-if the patch should cause any problems on gtk-3-6 and/or master, please feel free to reopen this bug report.

With blessings, thank you!
Comment 18 Michael Natterer 2012-12-15 07:43:42 UTC
*** Bug 682517 has been marked as a duplicate of this bug. ***
Comment 19 Fan, Chun-wei 2013-02-14 04:13:36 UTC
*** Bug 691180 has been marked as a duplicate of this bug. ***
Comment 20 Michael Natterer 2013-06-05 19:09:25 UTC
*** Bug 701671 has been marked as a duplicate of this bug. ***
Comment 21 huzheng001@gmail.com 2013-11-22 10:51:59 UTC
Could anyone update the GTK+ files in http://www.gtk.org/download/win32.php to
2.24.14 or later? It is still 2.24.10 there, which is 2012.02, and it is
2013.11 now!

Thank you very very much!!!!