summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2024-04-02 12:34:16 +1100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2024-04-15 15:28:45 +0000
commit592f85fd6cba0a18efeb83ec4f722ac3f87af2ea (patch)
tree18ceb84f7edbf9737778ca2fd57ef119f8d86fbf
parentb7b2b80de18b5b0b0bcb362d2b825573ecf4c82d (diff)
glwindow/cocoa: keep a window reference across an async callback
Esnures that the window is alive when the callback is fired. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6566>
-rw-r--r--subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m3
1 files changed, 2 insertions, 1 deletions
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
index 3be6c88b01..06a8b95047 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
@@ -286,6 +286,7 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
priv = window_cocoa->priv;
if (priv->internal_win_id) {
+ GstGLWindowCocoa *window_cocoa2 = gst_object_ref (window_cocoa);
if (handle) {
priv->external_view = (gpointer)handle;
priv->visible = TRUE;
@@ -295,7 +296,6 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
priv->visible = FALSE;
}
-
dispatch_async (dispatch_get_main_queue (), ^{
GstGLNSWindow *internal_win_id =
(__bridge GstGLNSWindow *)window_cocoa->priv->internal_win_id;
@@ -310,6 +310,7 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
[external_view setAutoresizesSubviews: YES];
[view setFrame: [external_view bounds]];
[view setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
+ gst_object_unref (window_cocoa2);
});
} else {
/* no internal window yet so delay it to the next drawing */