Commit c049c6a3 authored by Kristian Rietveld's avatar Kristian Rietveld

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.
parent 69312450
......@@ -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];
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment