Ensure gdk_quartz_drag_source freed on all paths.

New release function _gdk_quartz_drag_source_context_destroy_gtk_only
gets called when drag fails to start or is cancelled as well as
when it successfully completes.
This commit is contained in:
John Ralls 2021-04-25 16:53:15 -07:00
parent 27dad4b90a
commit a6c3887736
4 changed files with 18 additions and 5 deletions

View File

@ -803,8 +803,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
gdk_event_free (event);
g_object_unref (_gdk_quartz_drag_source_context);
_gdk_quartz_drag_source_context = NULL;
_gdk_quartz_drag_source_context_destroy_gtk_only ();
}
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER

View File

@ -59,6 +59,14 @@ _gdk_quartz_window_drag_begin (GdkWindow *window,
return _gdk_quartz_drag_source_context;
}
void
_gdk_quartz_drag_source_context_destroy_gtk_only ()
{
if (_gdk_quartz_drag_source_context)
g_object_unref (_gdk_quartz_drag_source_context);
_gdk_quartz_drag_source_context = NULL;
}
static gboolean
gdk_quartz_drag_context_drag_motion (GdkDragContext *context,
GdkWindow *dest_window,

View File

@ -51,6 +51,9 @@ id gdk_quartz_drag_context_get_dragging_info_libgtk_only (GdkDragContext
GDK_AVAILABLE_IN_ALL
GdkDragContext *gdk_quartz_drag_source_context_libgtk_only (void);
GDK_AVAILABLE_IN_3_24
void _gdk_quartz_drag_source_context_destroy_gtk_only ();
G_END_DECLS
#endif /* __GDK_QUARTZ_DRAG_CONTEXT_H__ */

View File

@ -1088,8 +1088,10 @@ gtk_drag_begin_idle (gpointer arg)
[types release];
if ((nswindow = get_toplevel_nswindow (info->source_widget)) == NULL)
return G_SOURCE_REMOVE;
{
_gdk_quartz_drag_source_context_destroy_gtk_only ();
return G_SOURCE_REMOVE;
}
/* Ref the context. It's unreffed when the drag has been aborted */
g_object_ref (info->context);
@ -1101,6 +1103,7 @@ gtk_drag_begin_idle (gpointer arg)
if (drag_image == NULL)
{
g_object_unref (info->context);
_gdk_quartz_drag_source_context_destroy_gtk_only ();
return G_SOURCE_REMOVE;
}
@ -1669,7 +1672,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget,
break;
default:
g_assert_not_reached ();
}
}
}
/**