events: Return early if we close the display

This is so we won't poke into the MetaDisplay, which is invalid memory,
and crash. This can sometimes work right now because GSlice might not
deallocate the object immediately, but it's still not a fun thing to do.
This commit is contained in:
Jasper St. Pierre 2014-07-13 11:42:37 -04:00
parent f9d33b2efc
commit 46361c3e28

View File

@ -1148,7 +1148,7 @@ process_selection_request (MetaDisplay *display,
meta_verbose ("Handled selection request\n"); meta_verbose ("Handled selection request\n");
} }
static void static gboolean
process_selection_clear (MetaDisplay *display, process_selection_clear (MetaDisplay *display,
XEvent *event) XEvent *event)
{ {
@ -1169,7 +1169,7 @@ process_selection_clear (MetaDisplay *display,
meta_XFree (str); meta_XFree (str);
return; return FALSE;
} }
meta_verbose ("Got selection clear for screen %d on display %s\n", meta_verbose ("Got selection clear for screen %d on display %s\n",
@ -1177,6 +1177,7 @@ process_selection_clear (MetaDisplay *display,
meta_display_unmanage_screen (display, display->screen, meta_display_unmanage_screen (display, display->screen,
event->xselectionclear.time); event->xselectionclear.time);
return TRUE;
} }
static gboolean static gboolean
@ -1772,13 +1773,14 @@ meta_display_handle_xevent (MetaDisplay *display,
if (event->type == SelectionClear) if (event->type == SelectionClear)
{ {
/* Do this here so we can return without any further if (process_selection_clear (display, event))
* processing. */ {
process_selection_clear (display, event); /* This means we called meta_display_unmanage_screen, which
/* Note that processing that may have resulted in * means the MetaDisplay is effectively dead. We don't want
* closing the display... */ * to poke into display->current_time below, since that would
bypass_gtk = bypass_compositor = TRUE; * crash, so just directly return. */
goto out; return TRUE;
}
} }
out: out: