[gnome-packagekit/gnome-3-6] Don't crash if the window that invoked the task exits before the task starts up



commit 10abf863788775bb119e6dee9875487a12f15e12
Author: Richard Hughes <richard hughsie com>
Date:   Wed Nov 28 14:53:41 2012 +0000

    Don't crash if the window that invoked the task exits before the task starts up
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=756208

 src/gpk-dbus.c |    6 ++++--
 src/gpk-x11.c  |    2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/gpk-dbus.c b/src/gpk-dbus.c
index 8dc19c5..aa43581 100644
--- a/src/gpk-dbus.c
+++ b/src/gpk-dbus.c
@@ -334,6 +334,7 @@ gpk_dbus_create_task (GpkDbus *dbus, guint32 xid, const gchar *interaction, DBus
 	gchar *sender;
 	gchar *exec;
 	guint timestamp = 0;
+	gboolean ret;
 
 	task = gpk_dbus_task_new ();
 
@@ -349,8 +350,9 @@ gpk_dbus_create_task (GpkDbus *dbus, guint32 xid, const gchar *interaction, DBus
 
 	/* try to get the user time of the window */
 	if (xid != 0) {
-		gpk_x11_set_xid (dbus->priv->x11, xid);
-		timestamp = gpk_x11_get_user_time (dbus->priv->x11);
+		ret = gpk_x11_set_xid (dbus->priv->x11, xid);
+		if (ret)
+			timestamp = gpk_x11_get_user_time (dbus->priv->x11);
 	}
 
 	/* set the context for the return values */
diff --git a/src/gpk-x11.c b/src/gpk-x11.c
index 9b54454..2a5b13f 100644
--- a/src/gpk-x11.c
+++ b/src/gpk-x11.c
@@ -54,6 +54,8 @@ gpk_x11_set_xid (GpkX11 *x11, guint32 xid)
 	g_return_val_if_fail (GPK_IS_X11 (x11), FALSE);
 
 	window = gdk_x11_window_foreign_new_for_display (x11->priv->gdk_display, xid);
+	if (window == NULL)
+		return FALSE;
 
 	/* save the x state */
 	x11->priv->display = GDK_DISPLAY_XDISPLAY (x11->priv->gdk_display);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]