wayland: Fix memory handling for the selection callbacks

This commit is contained in:
Rob Bradford 2012-01-13 15:42:53 +00:00
parent 368d6c50b7
commit 1e0b22c176
2 changed files with 8 additions and 5 deletions

View File

@ -1007,6 +1007,7 @@ _request_content_io_func (GIOChannel *channel,
closure->cb (closure->device->pointer, data, len, closure->userdata);
g_free (data);
data_offer_unref (closure->offer);
g_io_channel_unref (channel);
g_free (closure);
@ -1099,8 +1100,8 @@ data_source_send (void *data,
int32_t fd)
{
GdkWaylandSelectionOffer *offer = (GdkWaylandSelectionOffer *)data;;
const gchar *buf;
gssize len, bytes_written;
gchar *buf;
gssize len, bytes_written = 0;
g_debug (G_STRLOC ": %s source = %p, mime_type = %s fd = %d",
G_STRFUNC, source, mime_type, fd);
@ -1109,13 +1110,14 @@ data_source_send (void *data,
while (len > 0)
{
bytes_written = write (fd, buf, len);
bytes_written += write (fd, buf + bytes_written, len);
if (bytes_written == -1)
goto error;
len -= bytes_written;
}
close (fd);
g_free (buf);
return;
error:
@ -1124,6 +1126,7 @@ error:
g_strerror (errno));
close (fd);
g_free (buf);
}
static void

View File

@ -39,7 +39,7 @@ int
gdk_wayland_device_get_selection_type_atoms (GdkDevice *device,
GdkAtom **atoms_out);
typedef void (*GdkDeviceWaylandRequestContentCallback) (GdkDevice *device, gchar *data, gsize len, gpointer userdata);
typedef void (*GdkDeviceWaylandRequestContentCallback) (GdkDevice *device, const gchar *data, gsize len, gpointer userdata);
#define gdk_wayland_device_request_selection_content gdk_wayland_device_request_selection_content_libgtk_only
gboolean
@ -48,7 +48,7 @@ gdk_wayland_device_request_selection_content (GdkDevice
GdkDeviceWaylandRequestContentCallback cb,
gpointer userdata);
typedef const gchar *(*GdkDeviceWaylandOfferContentCallback) (GdkDevice *device, const gchar *mime_type, gssize *len, gpointer userdata);
typedef gchar *(*GdkDeviceWaylandOfferContentCallback) (GdkDevice *device, const gchar *mime_type, gssize *len, gpointer userdata);
#define gdk_wayland_device_offer_selection_content gdk_wayland_device_offer_selection_content_libgtk_only
gboolean