mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
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.
This commit is contained in:
parent
b2d6bf1526
commit
91663e0791
@ -328,15 +328,13 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
|
|||||||
gboolean have_owner)
|
gboolean have_owner)
|
||||||
{
|
{
|
||||||
GtkClipboardOwner *owner;
|
GtkClipboardOwner *owner;
|
||||||
NSArray *types;
|
NSSet *types;
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
|
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
|
||||||
|
|
||||||
types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
|
|
||||||
|
|
||||||
if (!(clipboard->have_owner && have_owner) ||
|
if (!(clipboard->have_owner && have_owner) ||
|
||||||
clipboard->user_data != user_data)
|
clipboard->user_data != user_data)
|
||||||
{
|
{
|
||||||
@ -351,10 +349,14 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
|
|||||||
clipboard->user_data != user_data)
|
clipboard->user_data != user_data)
|
||||||
{
|
{
|
||||||
(*clear_func) (clipboard, user_data);
|
(*clear_func) (clipboard, user_data);
|
||||||
|
[pool release];
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return TRUE;
|
{
|
||||||
|
[pool release];
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +371,9 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
|
|||||||
gtk_target_list_unref (clipboard->target_list);
|
gtk_target_list_unref (clipboard->target_list);
|
||||||
clipboard->target_list = gtk_target_list_new (targets, n_targets);
|
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];
|
[types release];
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ register_types (GtkWidget *widget, GtkDragDestSite *site)
|
|||||||
if (site->target_list)
|
if (site->target_list)
|
||||||
{
|
{
|
||||||
NSWindow *nswindow = get_toplevel_nswindow (widget);
|
NSWindow *nswindow = get_toplevel_nswindow (widget);
|
||||||
NSArray *types;
|
NSSet *types;
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
|
|
||||||
if (!nswindow)
|
if (!nswindow)
|
||||||
@ -455,7 +455,7 @@ register_types (GtkWidget *widget, GtkDragDestSite *site)
|
|||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
types = _gtk_quartz_target_list_to_pasteboard_types (site->target_list);
|
types = _gtk_quartz_target_list_to_pasteboard_types (site->target_list);
|
||||||
|
|
||||||
[nswindow registerForDraggedTypes:[types copy]];
|
[nswindow registerForDraggedTypes:[types allObjects]];
|
||||||
|
|
||||||
[types release];
|
[types release];
|
||||||
[pool release];
|
[pool release];
|
||||||
@ -1072,13 +1072,18 @@ gtk_drag_begin_idle (gpointer arg)
|
|||||||
NSPasteboard *pasteboard;
|
NSPasteboard *pasteboard;
|
||||||
GtkDragSourceOwner *owner;
|
GtkDragSourceOwner *owner;
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
|
NSSet *types;
|
||||||
|
|
||||||
g_assert (info != NULL);
|
g_assert (info != NULL);
|
||||||
|
|
||||||
pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
|
pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
|
||||||
owner = [[GtkDragSourceOwner alloc] initWithInfo:info];
|
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)
|
if ((nswindow = get_toplevel_nswindow (info->source_widget)) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -83,11 +83,10 @@ target_to_pasteboard_type (const char *target)
|
|||||||
return [NSString stringWithUTF8String:target];
|
return [NSString stringWithUTF8String:target];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *
|
NSSet *
|
||||||
_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
|
_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
|
||||||
{
|
{
|
||||||
NSMutableSet *set = [[NSMutableSet alloc] init];
|
NSMutableSet *set = [[NSMutableSet alloc] init];
|
||||||
NSArray *ret;
|
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
for (list = target_list->list; list; list = list->next)
|
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);
|
g_free (target);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = [set allObjects];
|
return set;
|
||||||
|
|
||||||
[set release];
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *
|
NSSet *
|
||||||
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||||
guint n_targets)
|
guint n_targets)
|
||||||
{
|
{
|
||||||
NSMutableSet *set = [[NSMutableSet alloc] init];
|
NSMutableSet *set = [[NSMutableSet alloc] init];
|
||||||
NSArray *ret;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < n_targets; 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)];
|
[set addObject:target_to_pasteboard_type (targets[i].target)];
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = [set allObjects];
|
return set;
|
||||||
|
|
||||||
[set release];
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkAtom
|
GdkAtom
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
NSArray *_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list);
|
NSSet *_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_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||||
guint n_targets);
|
guint n_targets);
|
||||||
|
|
||||||
GList *_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array);
|
GList *_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array);
|
||||||
|
Loading…
Reference in New Issue
Block a user