From 09a4d3923a18f54dcb382164d9657bf04a2423ab Mon Sep 17 00:00:00 2001 From: deepend Date: Mon, 16 Feb 2026 18:11:37 -0700 Subject: [PATCH] =?UTF-8?q?Fixed=20the=20GTK3=20unrealize=20lifecycle=20in?= =?UTF-8?q?=20gtk=5Fxtext=5Funrealize()=20by=20removing=20the=20early=20gd?= =?UTF-8?q?k=5Fwindow=5Fset=5Fuser=5Fdata(window,=20NULL)=20path,=20so=20t?= =?UTF-8?q?he=20widget/window=20ownership=20remains=20valid=20until=20pare?= =?UTF-8?q?nt=20unrealize=20runs.=20This=20matches=20GTK=E2=80=99s=20expec?= =?UTF-8?q?ted=20unregister=20flow=20and=20addresses=20the=20user=5Fdata?= =?UTF-8?q?=20=3D=3D=20NULL=20abort=20pattern=20you=20described.=20Kept=20?= =?UTF-8?q?GTK2=20behavior=20unchanged=20(#if=20!HAVE=5FGTK3=20still=20cle?= =?UTF-8?q?ars=20widget->window=20user=20data=20in=20the=20legacy=20path).?= =?UTF-8?q?=20Added=20an=20in-code=20comment=20documenting=20why=20GTK3=20?= =?UTF-8?q?must=20preserve=20user-data=20until=20chaining=20to=20parent=20?= =?UTF-8?q?unrealize.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fe-gtk/xtext.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 16fc3a03..de908181 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -931,16 +931,13 @@ gtk_xtext_finalize (GObject *object) static void gtk_xtext_unrealize (GtkWidget * widget) { -#if HAVE_GTK3 - GdkWindow *window = gtk_widget_get_window (widget); -#endif backend_deinit (GTK_XTEXT (widget)); - /* if there are still events in the queue, this'll avoid segfault */ -#if HAVE_GTK3 - if (window) - gdk_window_set_user_data (window, NULL); -#endif + /* + * Keep GtkWidget/GdkWindow association intact until parent unrealize. + * GtkWidget's unrealize path unregisters the window and expects + * gdk_window_get_user_data(window) == widget. + */ #if !HAVE_GTK3 gdk_window_set_user_data (widget->window, NULL); #endif