]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
Quit correctly(?) from the interface/DP. Should fix #1598.
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index 0419d8e2ea5bc90241d012e1a5a809a53a7183f1..2e4df5887d0f2d6365ed1b246671be688022c7ae 100644 (file)
@@ -21,6 +21,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include <QEvent>
 #include <QApplication>
 #include "dialogs/mediainfo.hpp"
 #include "dialogs/messages.hpp"
 #include "dialogs/extended.hpp"
+#include "dialogs/vlm.hpp"
 #include "dialogs/sout.hpp"
 #include "dialogs/open.hpp"
-#include "dialogs/vlm.hpp"
 #include "dialogs/help.hpp"
 #include "dialogs/gototime.hpp"
 #include "dialogs/podcast_configuration.hpp"
-#include "dialogs/vlm.hpp"
-
 
 DialogsProvider* DialogsProvider::instance = NULL;
 
@@ -71,14 +72,23 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
 
 DialogsProvider::~DialogsProvider()
 {
+    msg_Dbg( p_intf, "Destroying the Dialog Provider" );
     PlaylistDialog::killInstance();
     MediaInfoDialog::killInstance();
+    MessagesDialog::killInstance();
+    ExtendedDialog::killInstance();
+    BookmarksDialog::killInstance();
+    HelpDialog::killInstance();
+#ifdef UPDATE_CHECK
+    UpdateDialog::killInstance();
+#endif
+
     fixed_timer->stop();
 }
 
 void DialogsProvider::quit()
 {
-    vlc_object_kill( p_intf );
+    vlc_object_kill( p_intf->p_libvlc );
     QApplication::closeAllWindows();
     QApplication::quit();
 }
@@ -114,8 +124,10 @@ void DialogsProvider::customEvent( QEvent *event )
            bookmarksDialog(); break;
         case INTF_DIALOG_EXTENDED:
            extendedDialog(); break;
+#ifdef ENABLE_VLM
         case INTF_DIALOG_VLM:
            vlmDialog(); break;
+#endif
         case INTF_DIALOG_INTERACTION:
            doInteraction( de->p_arg ); break;
         case INTF_DIALOG_POPUPMENU:
@@ -169,10 +181,12 @@ void DialogsProvider::gotoTimeDialog()
     GotoTimeDialog::getInstance( p_intf )->toggleVisible();
 }
 
+#ifdef ENABLE_VLM
 void DialogsProvider::vlmDialog()
 {
     VLMDialog::getInstance( p_intf )->toggleVisible();
 }
+#endif
 
 void DialogsProvider::helpDialog()
 {
@@ -203,7 +217,7 @@ void DialogsProvider::mediaCodecDialog()
 
 void DialogsProvider::bookmarksDialog()
 {
-    BookmarksDialog::getInstance( p_intf )->toggleVisible(); 
+    BookmarksDialog::getInstance( p_intf )->toggleVisible();
 }
 
 void DialogsProvider::podcastConfigureDialog()
@@ -282,7 +296,7 @@ QStringList DialogsProvider::showSimpleOpen( QString help,
     fileTypes.replace(QString(";*"), QString(" *"));
     return QFileDialog::getOpenFileNames( NULL,
         help.isNull() ? qfu(I_OP_SEL_FILES ) : help,
-        path.isNull() ? qfu( p_intf->p_libvlc->psz_homedir ) : path,
+        path.isNull() ? qfu( p_intf->p_sys->psz_filepath ) : path,
         fileTypes );
 }
 
@@ -303,7 +317,7 @@ void DialogsProvider::addFromSimple( bool pl, bool go)
                                                ( i ? PLAYLIST_PREPARSE : 0 ) )
                          : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
                       PLAYLIST_END,
-                      pl ? VLC_TRUE : VLC_FALSE, VLC_FALSE );
+                      pl ? true : false, false );
         i++;
     }
 }
@@ -337,10 +351,12 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
                                         qtu( "directory://" + dir ), NULL,
                                         0, NULL, -1 );
 
+        /* FIXME: playlist_AddInput() can fail */
         playlist_AddInput( THEPL, p_input,
                        go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
-                       PLAYLIST_END, pl, VLC_FALSE );
-        input_Read( THEPL, p_input, VLC_FALSE );
+                       PLAYLIST_END, pl, false );
+        input_Read( THEPL, p_input, false );
+        vlc_gc_decref( p_input );
     }
 }
 
@@ -371,7 +387,7 @@ void DialogsProvider::saveAPlaylist()
 {
     QFileDialog *qfd = new QFileDialog( NULL,
                                    qtr( "Choose a filename to save playlist" ),
-                                   qfu( p_intf->p_libvlc->psz_homedir ),
+                                   qfu( p_intf->p_sys->psz_filepath ),
                                    qtr( "XSPF playlist (*.xspf);; " ) +
                                    qtr( "M3U playlist (*.m3u);; Any (*.*) " ) );
     qfd->setFileMode( QFileDialog::AnyFile );
@@ -422,7 +438,7 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
 
     if( s->exec() == QDialog::Accepted )
     {
-        msg_Err( p_intf, "Sout mrl %s", qta( s->getMrl() ) );
+        msg_Dbg( p_intf, "Sout mrl %s", qta( s->getMrl() ) );
         /* Just do it */
         int i_len = strlen( qtu( s->getMrl() ) ) + 10;
         char *psz_option = (char*)malloc( i_len );
@@ -430,7 +446,7 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
 
         playlist_AddExt( THEPL, qtu( mrl ), "Streaming",
                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
-                        -1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
+                        -1, &psz_option, 1, true, false );
     }
 }
 
@@ -487,6 +503,17 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
         qdialog = (InteractionDialog*)(p_dialog->p_private);
         if( qdialog )
             qdialog->update();
+        else
+        {
+            /* The INTERACT_NEW message was forgotten
+               so we must create the dialog and update it*/
+            qdialog = new InteractionDialog( p_intf, p_dialog );
+            p_dialog->p_private = (void*)qdialog;
+            if( !(p_dialog->i_status == ANSWERED_DIALOG) )
+                qdialog->show();
+            if( qdialog )
+                qdialog->update();
+        }
         break;
     case INTERACT_HIDE:
         qdialog = (InteractionDialog*)(p_dialog->p_private);
@@ -502,8 +529,3 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
         break;
     }
 }
-
-void DialogsProvider::switchToSkins()
-{
-    var_SetString( p_intf, "intf-switch", "skins2" );
-}