vlc/vlc-3.0 | branch: master | David Fuhrmann <dfuhrm...@videolan.org> | Sun 
Feb 18 19:16:57 2018 +0100| [74ba6047f3a18c9d48bda27f5c287268ea48a58e] | 
committer: David Fuhrmann

macosx: Spin event loop to process pending selectors on main thread

This is needed to cleanup everything correctly. In one particular
occurence, the InputManager still had pending selectors in the queue
which prevented the object from being released.
This resulted in playback position never saved, which is fixed now
with this change.

Also this fixes occasional crashes in debug mode as the ref count of
the current input thread is now correct on exit.

fixes #19704

(cherry picked from commit 5d0d2b0d533df40c6e78460d2a320997e7e3ee34)
Signed-off-by: David Fuhrmann <dfuhrm...@videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=74ba6047f3a18c9d48bda27f5c287268ea48a58e
---

 modules/gui/macosx/VLCMain.m | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/VLCMain.m b/modules/gui/macosx/VLCMain.m
index 16e8656b05..9f33cab3f0 100644
--- a/modules/gui/macosx/VLCMain.m
+++ b/modules/gui/macosx/VLCMain.m
@@ -114,6 +114,16 @@ void CloseIntf (vlc_object_t *p_this)
         [[VLCMain sharedInstance] applicationWillTerminate:nil];
         [VLCMain killInstance];
 
+        /*
+         * Spinning the event loop here is important to help cleaning up all 
objects which should be
+         * destroyed here. Its possible that main thread selectors (which hold 
a strong reference
+         * to the target object), are still in the queue (e.g. fired from 
variable callback).
+         * Thus make sure those are still dispatched and the references to the 
targets are
+         * cleared, to allow the objects to be released.
+         */
+        msg_Dbg(p_this, "Spin the event loop to clean up the interface");
+        [[NSRunLoop mainRunLoop] runUntilDate:[NSDate date]];
+
         p_interface_thread = nil;
     }
 }
@@ -321,6 +331,7 @@ static VLCMain *sharedInstance = nil;
 
 - (void)applicationWillTerminate:(NSNotification *)notification
 {
+    msg_Dbg(getIntf(), "applicationWillTerminate called");
     if (b_intf_terminating)
         return;
     b_intf_terminating = true;
@@ -341,8 +352,6 @@ static VLCMain *sharedInstance = nil;
     config_PutInt(p_intf, "loop", var_GetBool(p_playlist, "loop"));
     config_PutInt(p_intf, "repeat", var_GetBool(p_playlist, "repeat"));
 
-    msg_Dbg(p_intf, "Terminating");
-
     var_DelCallback(p_intf->obj.libvlc, "intf-toggle-fscontrol", 
ShowController, (__bridge void *)self);
     var_DelCallback(p_intf->obj.libvlc, "intf-show", ShowController, (__bridge 
void *)self);
 

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to