GNOME Bugzilla – Bug 668239
texts disappear when notebook switch page at zh_CN locate!
Last modified: 2013-11-22 10:51:59 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
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
*** Bug 674334 has been marked as a duplicate of this bug. ***
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).
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(-)
*** Bug 678414 has been marked as a duplicate of this bug. ***
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(-)
It works when use this patch!! I test in gtk-2.24.8, use mingw compile.
Let's leave this open so we don't forget to test if the same fix is needed in gtk 3...
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:
+ Trace 231222
(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...
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: > >
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
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
(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.
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(+)
Is this bug now fixed for everybody? I'd like to close it.
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!
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!
*** Bug 682517 has been marked as a duplicate of this bug. ***
*** Bug 691180 has been marked as a duplicate of this bug. ***
*** Bug 701671 has been marked as a duplicate of this bug. ***
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!!!!