[vlc-devel] commit: Fix another small race condition in the Qt4 video window ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Oct 30 18:58:29 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Oct 30 19:33:35 2008 +0200| [c4aac77c660a12edef25481656b6de760c57b2d5] | committer: Rémi Denis-Courmont 

Fix another small race condition in the Qt4 video window

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

 modules/gui/qt4/qt4.cpp |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 2dc8293..6f91398 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -273,9 +273,13 @@ static int Open( vlc_object_t *p_this )
     else
     {
         QMutexLocker locker (&iface.lock);
+        vlc_value_t val;
 
         while (p_sys->p_mi == NULL)
             iface.ready.wait (&iface.lock);
+        var_Create (p_this->p_libvlc, "qt4-iface", VLC_VAR_ADDRESS);
+        val.p_address = p_this;
+        var_Set (p_this->p_libvlc, "qt4-iface", val);
     }
     return VLC_SUCCESS;
 }
@@ -297,6 +301,7 @@ static void Close( vlc_object_t *p_this )
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
     intf_sys_t *p_sys = p_intf->p_sys;
 
+    var_Destroy (p_this->p_libvlc, "qt4-iface");
     QApplication::postEvent (p_sys->p_mi, new QCloseEvent());
 
     if( p_intf->p_sys->b_isDialogProvider )
@@ -510,24 +515,23 @@ static int WindowControl (vout_window_t *, int, va_list);
 static int WindowOpen (vlc_object_t *obj)
 {
     vout_window_t *wnd = (vout_window_t *)obj;
-    MainInterface *p_mi;
+    intf_thread_t *intf = NULL;
+    vlc_value_t val;
 
     if (config_GetInt (obj, "embedded-video") <= 0)
         return VLC_EGENERIC;
 
-    intf_thread_t *intf = (intf_thread_t *)
-        vlc_object_find_name (obj, "qt4", FIND_ANYWHERE);
-    if (intf == NULL)
-        return VLC_EGENERIC; /* Qt4 not in use */
-    assert (intf->i_object_type == VLC_OBJECT_INTF);
-
     QMutexLocker (&iface.lock);
-    msg_Dbg (obj, "waiting for interface...");
-    while ((p_mi = intf->p_sys->p_mi) == NULL)
-        iface.ready.wait (&iface.lock);
+    if (var_Get (obj->p_libvlc, "qt4-iface", &val) == 0)
+        intf = (intf_thread_t *)val.p_address;
+    if (intf == NULL)
+    {   /* If another interface is used, this plugin cannot work */
+        msg_Dbg (obj, "Qt4 interface not found");
+        return VLC_EGENERIC;
+    }
 
+    MainInterface *p_mi = intf->p_sys->p_mi;
     msg_Dbg (obj, "requesting video...");
-    vlc_object_release (intf);
 
     wnd->handle = p_mi->requestVideo (wnd->vout, &wnd->pos_x, &wnd->pos_y,
                                       &wnd->width, &wnd->height);




More information about the vlc-devel mailing list