[vlc-devel] [PATCH] qt: do not try to lock non-existent thread

Marvin Scholz epirat07 at gmail.com
Wed May 27 20:13:48 CEST 2020


On macOS the qt interface does not spawn a thread but instead runs
on the main thread, so taking the locks here would lead to a deadlock.
---
 modules/gui/qt/qt.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 9bab39e933..f5bc3f0f90 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -472,8 +472,10 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
     /* Wait for the interface to be ready. This prevents the main
      * LibVLC thread from starting video playback before we can create
      * an embedded video window. */
+#ifndef Q_OS_MAC
     while (open_state == OPEN_STATE_INIT)
         wait_ready.wait(lock);
+#endif
 
     if (open_state == OPEN_STATE_ERROR)
     {
@@ -682,14 +684,14 @@ static void *Thread( void *obj )
     /* Explain how to show a dialog :D */
     p_intf->pf_show_dialog = ShowDialog;
 
+#ifndef Q_OS_MAC
     /* Tell the main LibVLC thread we are ready */
     {
         vlc::threads::mutex_locker locker (lock);
         open_state = OPEN_STATE_OPENED;
         wait_ready.signal();
     }
-
-#ifdef Q_OS_MAC
+#else
     /* We took over main thread, register and start here */
     if( !p_sys->b_isDialogProvider )
     {
@@ -730,11 +732,15 @@ static void *ThreadCleanup( intf_thread_t *p_intf, bool error )
     intf_sys_t *p_sys = p_intf->p_sys;
 
     {
+#ifndef Q_OS_MAC
         vlc::threads::mutex_locker locker (lock);
+#endif
         if( error )
         {
             open_state = OPEN_STATE_ERROR;
+#ifndef Q_OS_MAC
             wait_ready.signal();
+#endif
         }
         else
             open_state = OPEN_STATE_INIT;
-- 
2.24.1 (Apple Git-126)



More information about the vlc-devel mailing list