From 0a938e815d5c988f8abf023663de9d12b9ba4d58 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Wed, 17 Jul 2013 11:05:11 +0100 Subject: [PATCH] display: prevent a crash if the screen being dragged is removed https://bugzilla.gnome.org/show_bug.cgi?id=704389 --- panels/display/cc-display-panel.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index 02cf94d03..1db8f476e 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -1741,6 +1741,13 @@ set_primary_output (CcDisplayPanel *self, gnome_rr_output_info_set_primary (outputs[i], outputs[i] == output); } +static void +grab_weak_ref_notify (gpointer area, + GObject *object) +{ + foo_scroll_area_end_grab (area, NULL); +} + static void on_output_event (FooScrollArea *area, FooScrollAreaEvent *event, @@ -1783,6 +1790,7 @@ on_output_event (FooScrollArea *area, gnome_rr_output_info_get_geometry (output, &output_x, &output_y, NULL, NULL); foo_scroll_area_begin_grab (area, on_output_event, data); + g_object_weak_ref (data, grab_weak_ref_notify, area); info = g_new0 (GrabInfo, 1); info->grab_x = event->x; @@ -1855,6 +1863,7 @@ on_output_event (FooScrollArea *area, g_free (g_object_get_data (G_OBJECT (output), "grab-info")); g_object_set_data (G_OBJECT (output), "grab-info", NULL); + g_object_weak_unref (data, grab_weak_ref_notify, area); #if 0 g_debug ("new position: %d %d %d %d", output->x, output->y, output->width, output->height);