gtkmagnifier: Avoid a crash if the inspected widget is finalized

If the inspected widget is finalized and we then try to disconnect
from its signals we'll crash.

https://bugzilla.gnome.org/show_bug.cgi?id=761775
This commit is contained in:
Rui Matos 2016-02-09 15:30:00 +01:00
parent 1331b60029
commit 019dab7c38

View File

@ -204,7 +204,8 @@ disconnect_resize_handler (GtkMagnifier *magnifier)
if (priv->resize_handler)
{
g_signal_handler_disconnect (priv->inspected, priv->resize_handler);
if (priv->inspected)
g_signal_handler_disconnect (priv->inspected, priv->resize_handler);
priv->resize_handler = 0;
}
}
@ -239,7 +240,8 @@ disconnect_draw_handler (GtkMagnifier *magnifier)
if (priv->draw_handler)
{
g_signal_handler_disconnect (priv->inspected, priv->draw_handler);
if (priv->inspected)
g_signal_handler_disconnect (priv->inspected, priv->draw_handler);
priv->draw_handler = 0;
}
}
@ -343,7 +345,13 @@ _gtk_magnifier_set_inspected (GtkMagnifier *magnifier,
disconnect_draw_handler (magnifier);
disconnect_resize_handler (magnifier);
if (priv->inspected)
g_object_remove_weak_pointer (G_OBJECT (priv->inspected),
(gpointer *) &priv->inspected);
priv->inspected = inspected;
if (priv->inspected)
g_object_add_weak_pointer (G_OBJECT (priv->inspected),
(gpointer *) &priv->inspected);
connect_draw_handler (magnifier);
connect_resize_handler (magnifier);