From c4d1a91a89e2969dd3a825b25532984c0b66be89 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont <pdherbemont@free.fr>
Date: Mon, 28 Dec 2009 03:01:53 +0100
Subject: [PATCH] qtcapture: Make sure we don't block on main thread at
 destruction.

---
 modules/access/qtcapture.m | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/access/qtcapture.m b/modules/access/qtcapture.m
index 712385f05942..f6665eb45e07 100644
--- a/modules/access/qtcapture.m
+++ b/modules/access/qtcapture.m
@@ -351,9 +351,11 @@ static void Close( vlc_object_t *p_this )
      * Else we dead lock. */
     if( vlc_object_alive(p_this->p_libvlc))
     {
-        [p_sys->session stopRunning];
-        [p_sys->output release];
-        [p_sys->session release];
+        // Perform this on main thread, as the framework itself will sometimes try to synchronously
+        // work on main thread. And this will create a dead lock.
+        [p_sys->session performSelectorOnMainThread:@selector(stopRunning) withObject:nil waitUntilDone:NO];
+        [p_sys->output performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
+        [p_sys->session performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
     }
     free( p_sys );
 
-- 
GitLab