[gtk+/native-layout] Rework a previous commit to not crash in addition to fixing leaks
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/native-layout] Rework a previous commit to not crash in addition to fixing leaks
- Date: Sun, 4 Apr 2010 02:13:39 +0000 (UTC)
commit 91663e079108ef1499b549eb9a0819dd7c19308a
Author: Kristian Rietveld <kris gtk org>
Date: Fri Jan 1 20:39:57 2010 +0100
Rework a previous commit to not crash in addition to fixing leaks
The target list/entry to pasteboard entry conversions return a NSSet
now instead of NSArray.
gtk/gtkclipboard-quartz.c | 14 +++++++++-----
gtk/gtkdnd-quartz.c | 11 ++++++++---
gtk/gtkquartz.c | 18 ++++--------------
gtk/gtkquartz.h | 4 ++--
4 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkclipboard-quartz.c b/gtk/gtkclipboard-quartz.c
index d0cc562..4b57d77 100644
--- a/gtk/gtkclipboard-quartz.c
+++ b/gtk/gtkclipboard-quartz.c
@@ -328,15 +328,13 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
gboolean have_owner)
{
GtkClipboardOwner *owner;
- NSArray *types;
+ NSSet *types;
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
- types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
-
if (!(clipboard->have_owner && have_owner) ||
clipboard->user_data != user_data)
{
@@ -351,10 +349,14 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
clipboard->user_data != user_data)
{
(*clear_func) (clipboard, user_data);
+ [pool release];
return FALSE;
}
else
- return TRUE;
+ {
+ [pool release];
+ return TRUE;
+ }
}
}
@@ -369,7 +371,9 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
gtk_target_list_unref (clipboard->target_list);
clipboard->target_list = gtk_target_list_new (targets, n_targets);
- [clipboard->pasteboard declareTypes:types owner:owner];
+ types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
+
+ [clipboard->pasteboard declareTypes:[types allObjects] owner:owner];
[types release];
[pool release];
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index f01a71f..dfce31b 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -446,7 +446,7 @@ register_types (GtkWidget *widget, GtkDragDestSite *site)
if (site->target_list)
{
NSWindow *nswindow = get_toplevel_nswindow (widget);
- NSArray *types;
+ NSSet *types;
NSAutoreleasePool *pool;
if (!nswindow)
@@ -455,7 +455,7 @@ register_types (GtkWidget *widget, GtkDragDestSite *site)
pool = [[NSAutoreleasePool alloc] init];
types = _gtk_quartz_target_list_to_pasteboard_types (site->target_list);
- [nswindow registerForDraggedTypes:[types copy]];
+ [nswindow registerForDraggedTypes:[types allObjects]];
[types release];
[pool release];
@@ -1072,13 +1072,18 @@ gtk_drag_begin_idle (gpointer arg)
NSPasteboard *pasteboard;
GtkDragSourceOwner *owner;
NSPoint point;
+ NSSet *types;
g_assert (info != NULL);
pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
owner = [[GtkDragSourceOwner alloc] initWithInfo:info];
- [pasteboard declareTypes:_gtk_quartz_target_list_to_pasteboard_types (info->target_list) owner:owner];
+ types = _gtk_quartz_target_list_to_pasteboard_types (info->target_list);
+
+ [pasteboard declareTypes:[types allObjects] owner:owner];
+
+ [types release];
if ((nswindow = get_toplevel_nswindow (info->source_widget)) == NULL)
return FALSE;
diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
index 6a94c3f..dcc8ee0 100644
--- a/gtk/gtkquartz.c
+++ b/gtk/gtkquartz.c
@@ -83,11 +83,10 @@ target_to_pasteboard_type (const char *target)
return [NSString stringWithUTF8String:target];
}
-NSArray *
+NSSet *
_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
{
NSMutableSet *set = [[NSMutableSet alloc] init];
- NSArray *ret;
GList *list;
for (list = target_list->list; list; list = list->next)
@@ -98,19 +97,14 @@ _gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
g_free (target);
}
- ret = [set allObjects];
-
- [set release];
-
- return ret;
+ return set;
}
-NSArray *
+NSSet *
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
guint n_targets)
{
NSMutableSet *set = [[NSMutableSet alloc] init];
- NSArray *ret;
int i;
for (i = 0; i < n_targets; i++)
@@ -118,11 +112,7 @@ _gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
[set addObject:target_to_pasteboard_type (targets[i].target)];
}
- ret = [set allObjects];
-
- [set release];
-
- return ret;
+ return set;
}
GdkAtom
diff --git a/gtk/gtkquartz.h b/gtk/gtkquartz.h
index cb84f27..54f4126 100644
--- a/gtk/gtkquartz.h
+++ b/gtk/gtkquartz.h
@@ -26,8 +26,8 @@
G_BEGIN_DECLS
-NSArray *_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list);
-NSArray *_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
+NSSet *_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list);
+NSSet *_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
guint n_targets);
GList *_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]