Commit 5d0d2b0d authored by David Fuhrmann's avatar 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
parent eab53a42
......@@ -115,6 +115,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;
}
}
......@@ -322,6 +332,7 @@ static VLCMain *sharedInstance = nil;
- (void)applicationWillTerminate:(NSNotification *)notification
{
msg_Dbg(getIntf(), "applicationWillTerminate called");
if (b_intf_terminating)
return;
b_intf_terminating = true;
......@@ -342,8 +353,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment