[vlc-devel] commit: Simplifications ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Oct 20 22:16:07 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Mon Oct 20 23:15:24 2008 +0300| [a62521c0ff7366d571b8cd4cc0c700124418b5b1] | committer: Rémi Denis-Courmont 

Simplifications

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

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

diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index d830fa1..e2de9be 100755
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -33,7 +33,6 @@
 #include <QMutex>
 #include <QMutexLocker>
 #include <QWaitCondition>
-#include <QPointer>
 
 #include "qt4.hpp"
 #include "dialogs_provider.hpp"
@@ -232,6 +231,7 @@ vlc_module_begin();
 #endif
 vlc_module_end();
 
+/* Ugly, but the Qt4 interface assumes single instance anyway */
 static struct
 {
     QMutex lock;
@@ -446,15 +446,11 @@ static void *Thread( void *obj )
     if (p_mi != NULL)
     {
         QMutexLocker locker (&iface.lock);
-        p_intf->p_sys->p_mi = NULL;
-
-        /* We need to warn to detach from any vout before
-         * deleting miP (WindowClose will not be called after it) */
-        p_mi->releaseVideo( NULL );
 
+        msg_Dbg (p_intf, "destroying the main Qt4 interface");
+        p_intf->p_sys->p_mi = NULL;
         /* Destroy first the main interface because it is connected to some
            slots in the MainInputManager */
-        /* Destroy under the iface lock to sync vout QPointer */
         delete p_mi;
     }
 
@@ -516,7 +512,7 @@ static int WindowControl (vout_window_t *, int, va_list);
 static int WindowOpen (vlc_object_t *obj)
 {
     vout_window_t *wnd = (vout_window_t *)obj;
-    QPointer<MainInterface> *miP;
+    MainInterface *p_mi;
 
     if (config_GetInt (obj, "embedded-video") <= 0)
         return VLC_EGENERIC;
@@ -529,44 +525,36 @@ static int WindowOpen (vlc_object_t *obj)
 
     QMutexLocker (&iface.lock);
     msg_Dbg (obj, "waiting for interface...");
-    while (intf->p_sys->p_mi == NULL)
+    while ((p_mi = intf->p_sys->p_mi) == NULL)
         iface.ready.wait (&iface.lock);
 
-    msg_Dbg (obj, "requesting window...");
-    /* create our own copy */
-    miP = new QPointer<MainInterface> (intf->p_sys->p_mi);
+    msg_Dbg (obj, "requesting video...");
     vlc_object_release (intf);
 
-    if (miP->isNull ())
-        return VLC_EGENERIC;
-
-    wnd->handle = (*miP)->requestVideo (wnd->vout, &wnd->pos_x, &wnd->pos_y,
-                                        &wnd->width, &wnd->height);
+    wnd->handle = p_mi->requestVideo (wnd->vout, &wnd->pos_x, &wnd->pos_y,
+                                      &wnd->width, &wnd->height);
     if (!wnd->handle)
         return VLC_EGENERIC;
 
     wnd->control = WindowControl;
-    wnd->p_private = miP;
+    wnd->p_private = p_mi;
     return VLC_SUCCESS;
 }
 
 static int WindowControl (vout_window_t *wnd, int query, va_list args)
 {
+    MainInterface *p_mi = (MainInterface *)wnd->p_private;
     QMutexLocker locker (&iface.lock);
-    QPointer<MainInterface> *miP = (QPointer<MainInterface> *)wnd->p_private;
 
-    if (miP->isNull ())
-        return VLC_EGENERIC;
-    return (*miP)->controlVideo (wnd->handle, query, args);
+    return p_mi->controlVideo (wnd->handle, query, args);
 }
 
 static void WindowClose (vlc_object_t *obj)
 {
     vout_window_t *wnd = (vout_window_t *)obj;
+    MainInterface *p_mi = (MainInterface *)wnd->p_private;
     QMutexLocker locker (&iface.lock);
-    QPointer<MainInterface> *miP = (QPointer<MainInterface> *)wnd->p_private;
 
-    if (!miP->isNull ())
-        (*miP)->releaseVideo( wnd->handle );
-    delete miP;
+    msg_Dbg (obj, "releasing video...");
+    p_mi->releaseVideo (wnd->handle);
 }




More information about the vlc-devel mailing list