]> git.sesse.net Git - vlc/blobdiff - modules/misc/qte_main.cpp
playlist: Make sure we don't pl_Release(p_playlist).
[vlc] / modules / misc / qte_main.cpp
index 158679aa0d7d4bef34c92cabbe4ca805f6cd4f21..ea9510523145445c0e3351b88397faab982ffa4d 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * qte_main.c : QT Embedded wrapper for gte_main
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
+ * Copyright (C) 2003 the VideoLAN team
  * $Id$
  *
- * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
+ * Authors: Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  *****************************************************************************/
 extern "C"
 {
-#include <vlc/vlc.h>
-#include <stdlib.h>                                              /* atexit() */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 }
 
 #include <qapplication.h>
@@ -69,9 +73,9 @@ static qte_thread_t * p_qte_main = NULL;
     "from normal Qt.")
 
 vlc_module_begin();
-    set_description( _("Qt Embedded GUI helper") );
+    set_description( N_("Qt Embedded GUI helper") );
     set_capability( "gui-helper", 90 );
-    add_bool( "qte-guiserver", 0, NULL, STANDALONE_TEXT, STANDALONE_LONGTEXT, VLC_FALSE );
+    add_bool( "qte-guiserver", 0, NULL, STANDALONE_TEXT, STANDALONE_LONGTEXT, false );
     add_shortcut( "qte" );
     set_callbacks( Open, Close );
 vlc_module_end();
@@ -83,18 +87,14 @@ vlc_module_end();
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    vlc_value_t lockval;
-
-    /* FIXME: put this in the module (de)initialization ASAP */
-    var_Create( p_this->p_libvlc, "qte", VLC_VAR_MUTEX );
+    vlc_mutex_t *lock;
 
-    var_Get( p_this->p_libvlc, "qte", &lockval );
-    vlc_mutex_lock( (vlc_mutex_t *) lockval.p_address );
+    lock = var_AcquireMutex( "qte" );
 
     if( i_refcount > 0 )
     {
         i_refcount++;
-        vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address );
+        vlc_mutex_unlock( lock );
 
         return VLC_SUCCESS;
     }
@@ -104,17 +104,19 @@ static int Open( vlc_object_t *p_this )
     /* Launch the QApplication::exec() thread. It will not return until the
      * application is properly initialized, which ensures us thread safety. */
     if( vlc_thread_create( p_qte_main, "qte_main", QteMain,
-                           VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
+                           VLC_THREAD_PRIORITY_LOW, true ) )
     {
-        vlc_object_destroy( p_qte_main );
+        vlc_object_release( p_qte_main );
         i_refcount--;
-        vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address );
-        var_Destroy( p_this->p_libvlc, "qte" );
+        vlc_mutex_unlock( lock );
         return VLC_ETHREAD;
     }
 
     i_refcount++;
-    vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address );
+    vlc_mutex_unlock( lock );
+
+    vlc_object_attach( p_qte_main, p_this );
+    msg_Dbg( p_this, "qte_main running" );
 
     return VLC_SUCCESS;
 }
@@ -124,17 +126,15 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    vlc_value_t lockval;
+    vlc_mutex_t *lock;
 
-    var_Get( p_this->p_libvlc, "qte", &lockval );
-    vlc_mutex_lock( (vlc_mutex_t *) lockval.p_address );
+    lock = var_AcquireMutex( "qte" );
 
     i_refcount--;
 
     if( i_refcount > 0 )
     {
-        vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address );
-        var_Destroy( p_this->p_libvlc, "qte" );
+        vlc_mutex_unlock( lock );
         return;
     }
     p_qte_main->p_qte_application->quit();
@@ -143,11 +143,13 @@ static void Close( vlc_object_t *p_this )
     delete p_qte_main->p_qte_widget;
     delete p_qte_main->p_qte_application;
 
-    vlc_object_destroy( p_qte_main );
+    msg_Dbg( p_this, "Detaching qte_main" );
+    vlc_object_detach( p_qte_main );
+
+    vlc_object_release( p_qte_main );
     p_qte_main = NULL;
 
-    vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address );
-    var_Destroy( p_this->p_libvlc, "qte" );
+    vlc_mutex_unlock( lock );
 }
 
 /*****************************************************************************
@@ -160,30 +162,27 @@ static void QteMain( qte_thread_t *p_this )
 {
     int i_argc = 1;
 
-    p_this->b_gui_server = VLC_FALSE;
+    p_this->b_gui_server = false;
     if( config_GetInt( p_this, "qte-guiserver" ) )
     {
         msg_Dbg( p_this, "Running as Qt Embedded standalone GuiServer" );
-        p_this->b_gui_server = VLC_TRUE;
+        p_this->b_gui_server = true;
     }
 
     /* Run as standalone GuiServer or as GuiClient. */
     QApplication* pApp = new QApplication(i_argc, NULL,
         (p_this->b_gui_server ? (QApplication::GuiServer):(QApplication::GuiClient)) );
-    if(pApp)
+    if( pApp )
     {
         p_this->p_qte_application = pApp;
     }
 
-    QWidget* pWidget = new QWidget();
-    if(pWidget)
+    QWidget* pWidget = new QWidget(0, _("video") );
+    if( pWidget )
     {
         p_this->p_qte_widget = pWidget;
     }
 
-    if (p_this->b_gui_server) {
-        p_this->p_qte_application->desktop()->setFixedSize(240, 320);
-    }
     /* signal the creation of the window */
     p_this->p_qte_application->setMainWidget(p_this->p_qte_widget);
     p_this->p_qte_widget->show();
@@ -191,4 +190,3 @@ static void QteMain( qte_thread_t *p_this )
     vlc_thread_ready( p_this );
     p_this->p_qte_application->exec();
 }
-