[gtk/mcatanzaro/#2424] window: prepare for window destruction after gtk_window_close()
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/mcatanzaro/#2424] window: prepare for window destruction after gtk_window_close()
- Date: Mon, 10 Feb 2020 23:19:45 +0000 (UTC)
commit f18ea715047afdc48085b1562caa04c1763dac09
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Feb 10 17:14:18 2020 -0600
window: prepare for window destruction after gtk_window_close()
Epiphany is doing something weird after calling gtk_window_close(),
because by the time the callback executes, the window has no GdkWindow.
Let's protect the GtkWindow for the callback, and also guard against
NULL GdkWindow.
Fixes #2424
gtk/gtkwindow.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7229518900..ed6d9b1cd2 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1310,22 +1310,33 @@ _gtk_window_toggle_maximized (GtkWindow *window)
gtk_window_maximize (window);
}
-static gboolean
-send_delete_event (gpointer data)
+static void
+send_delete_event (GtkWindow *window)
{
- GtkWidget *window = data;
- GtkWindowPrivate *priv = GTK_WINDOW (window)->priv;
-
+ GtkWindowPrivate *priv = window->priv;
GdkEvent *event;
event = gdk_event_new (GDK_DELETE);
+ event->any.window = _gtk_widget_get_window (GTK_WIDGET (window));
+ if (event->any.window)
+ {
+ g_object_ref (event->any.window);
+ event->any.send_event = TRUE;
+ priv->delete_event_handler = 0;
- event->any.window = g_object_ref (_gtk_widget_get_window (window));
- event->any.send_event = TRUE;
- priv->delete_event_handler = 0;
+ gtk_main_do_event (event);
+ }
- gtk_main_do_event (event);
gdk_event_free (event);
+}
+
+static gboolean
+do_send_delete_event (gpointer data)
+{
+ GtkWindow *window = data;
+
+ send_delete_event (window);
+ g_object_unref (window);
return G_SOURCE_REMOVE;
}
@@ -1348,7 +1359,7 @@ gtk_window_close (GtkWindow *window)
if (!_gtk_widget_get_realized (GTK_WIDGET (window)))
return;
- window->priv->delete_event_handler = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT, send_delete_event,
window, NULL);
+ window->priv->delete_event_handler = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT, do_send_delete_event,
g_object_ref (window), NULL);
g_source_set_name_by_id (window->priv->delete_event_handler, "[gtk+] send_delete_event");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]