backends: Do NULL checks before disconnecting/connecting signals

The displayed cursor may be NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=754806
This commit is contained in:
Carlos Garnacho 2017-11-20 13:20:36 +01:00
parent 3067dab84c
commit cf4b5efdd1

View File

@ -75,12 +75,21 @@ update_displayed_cursor (MetaCursorTracker *tracker)
if (tracker->displayed_cursor == cursor) if (tracker->displayed_cursor == cursor)
return FALSE; return FALSE;
g_signal_handlers_disconnect_by_func (tracker->displayed_cursor, if (tracker->displayed_cursor)
cursor_texture_updated, {
tracker); g_signal_handlers_disconnect_by_func (tracker->displayed_cursor,
cursor_texture_updated,
tracker);
}
g_set_object (&tracker->displayed_cursor, cursor); g_set_object (&tracker->displayed_cursor, cursor);
g_signal_connect (tracker->displayed_cursor, "texture-changed",
G_CALLBACK (cursor_texture_updated), tracker); if (cursor)
{
g_signal_connect (cursor, "texture-changed",
G_CALLBACK (cursor_texture_updated), tracker);
}
return TRUE; return TRUE;
} }