[gtk+] wayland: Plug some memleaks in DnD/clipboard code
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] wayland: Plug some memleaks in DnD/clipboard code
- Date: Thu, 25 Jun 2015 13:10:44 +0000 (UTC)
commit 6cc9b17429787de578c18616fb5af03aac12378f
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jun 25 14:52:47 2015 +0200
wayland: Plug some memleaks in DnD/clipboard code
gdk_atom_name() return value must be freed, this code was consistently
not doing so...
gdk/wayland/gdkdnd-wayland.c | 13 ++++++++++---
gdk/wayland/gdkselection-wayland.c | 27 +++++++++++++++++++++------
2 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c
index fea4480..6bbe3ce 100644
--- a/gdk/wayland/gdkdnd-wayland.c
+++ b/gdk/wayland/gdkdnd-wayland.c
@@ -214,8 +214,10 @@ gdk_wayland_drop_context_set_status (GdkDragContext *context,
if (l)
{
- wl_data_offer_accept (wl_offer, context_wayland->serial,
- gdk_atom_name (l->data));
+ gchar *mimetype = gdk_atom_name (l->data);
+
+ wl_data_offer_accept (wl_offer, context_wayland->serial, mimetype);
+ g_free (mimetype);
return;
}
}
@@ -353,7 +355,12 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
gdk_wayland_drag_context_get_selection (context));
for (l = context->targets; l; l = l->next)
- wl_data_source_offer (context_wayland->data_source, gdk_atom_name (l->data));
+ {
+ gchar *mimetype = gdk_atom_name (l->data);
+
+ wl_data_source_offer (context_wayland->data_source, mimetype);
+ g_free (mimetype);
+ }
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
context_wayland->data_source,
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index d0e7e7d..d1c754c 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -504,10 +504,16 @@ gdk_wayland_selection_store (GdkWindow *window,
if (mode != GDK_PROP_MODE_REPLACE &&
type != selection->stored_selection.type)
{
+ gchar *type_str, stored_str;
+
+ type_str = gdk_atom_name (type);
+ stored_str = gdk_atom_name (selection->stored_selection.type);
+
g_warning (G_STRLOC ": Attempted to append/prepend selection data with "
"type %s into the current selection with type %s",
- gdk_atom_name (type),
- gdk_atom_name (selection->stored_selection.type));
+ type_str, stored_str);
+ g_free (type_str);
+ g_free (stored_str);
return;
}
@@ -925,6 +931,7 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display,
{
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
SelectionBuffer *buffer_data;
+ gchar *mimetype;
if (!wayland_selection->offer)
{
@@ -944,10 +951,12 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display,
return;
}
+ mimetype = gdk_atom_name (target);
+
if (target != gdk_atom_intern_static_string ("TARGETS"))
wl_data_offer_accept (wayland_selection->offer,
_gdk_wayland_display_get_serial (GDK_WAYLAND_DISPLAY (display)),
- gdk_atom_name (target));
+ mimetype);
buffer_data = g_hash_table_lookup (wayland_selection->selection_buffers,
target);
@@ -975,8 +984,7 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display,
{
g_unix_open_pipe (pipe_fd, FD_CLOEXEC, NULL);
wl_data_offer_receive (wayland_selection->offer,
- gdk_atom_name (target),
- pipe_fd[1]);
+ mimetype, pipe_fd[1]);
stream = g_unix_input_stream_new (pipe_fd[0], TRUE);
close (pipe_fd[1]);
}
@@ -1001,6 +1009,8 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display,
if (!buffer_data->stream)
selection_buffer_notify (buffer_data);
+
+ g_free (mimetype);
}
gint
@@ -1072,7 +1082,12 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
g_array_append_vals (wayland_selection->source_targets, targets, ntargets);
for (i = 0; i < ntargets; i++)
- wl_data_source_offer (data_source, gdk_atom_name (targets[i]));
+ {
+ gchar *mimetype = gdk_atom_name (targets[i]);
+
+ wl_data_source_offer (data_source, mimetype);
+ g_free (mimetype);
+ }
if (selection == atoms[ATOM_CLIPBOARD])
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]