x11: Always delete selection input stream property when flushing

This is a preparation for each input stream creating its own window. It
moves deleting the property from meta_x11_selection_input_stream_xevent
where it can run after the stream has been finalized to a spot where
the stream still exists. Use an error trap in case the property was not
set by the client, such as when the conversion failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1812>
This commit is contained in:
Sebastian Keller 2021-04-05 00:51:52 +02:00
parent 7b78d5a625
commit d25175b91c

View File

@ -132,8 +132,13 @@ meta_x11_selection_input_stream_flush (MetaX11SelectionInputStream *stream)
{
MetaX11SelectionInputStreamPrivate *priv =
meta_x11_selection_input_stream_get_instance_private (stream);
Display *xdisplay = priv->x11_display->xdisplay;
gssize written;
meta_x11_error_trap_push (priv->x11_display);
XDeleteProperty (xdisplay, priv->window, priv->xproperty);
meta_x11_error_trap_pop (priv->x11_display);
if (!meta_x11_selection_input_stream_has_data (stream))
return;
@ -428,9 +433,6 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,
g_async_queue_push (priv->chunks, bytes);
meta_x11_selection_input_stream_flush (stream);
}
XDeleteProperty (xdisplay, xwindow, xevent->xproperty.atom);
return FALSE;
case SelectionNotify:
@ -489,8 +491,6 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,
meta_x11_selection_input_stream_complete (stream);
}
}
XDeleteProperty (xdisplay, xwindow, xevent->xselection.property);
}
g_object_unref (task);