]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs.cpp
Use QPointer and QMutexLocker so we don't crash at Qt4 interface exit
[vlc] / modules / gui / wxwidgets / dialogs.cpp
index 98f2c2f4c06ae2374dddbba083ba82f07ecae982..2204abf445f9d6a6ab1ba8c675a2c4eeb7d27e49 100644 (file)
  * Preamble
  *****************************************************************************/
 #include <errno.h>                                                 /* ENOMEM */
-#include <string.h>                                            /* strerror() */
-#include <stdio.h>
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 #include <vlc_aout.h>
 #include <vlc_interface.h>
 
@@ -65,7 +67,9 @@ private:
     void Open( int i_access_method, int i_arg );
 
     /* Event handlers (these functions should _not_ be virtual) */
+#ifdef UPDATE_CHECK
     void OnUpdateVLC( wxCommandEvent& event );
+#endif
     //void OnVLM( wxCommandEvent& event );
     void OnInteraction( wxCommandEvent& event );
     void OnExit( wxCommandEvent& event );
@@ -110,7 +114,9 @@ public:
     wxFrame             *p_prefs_dialog;
     wxFrame             *p_bookmarks_dialog;
     wxFileDialog        *p_file_generic_dialog;
+#ifdef UPDATE_CHECK
     UpdateVLC           *p_updatevlc_dialog;
+#endif
     //VLMFrame            *p_vlm_dialog;
 };
 }
@@ -158,8 +164,10 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
 
     EVT_COMMAND(INTF_DIALOG_EXIT, wxEVT_DIALOG,
                 DialogsProvider::OnExitThread)
+#ifdef UPDATE_CHECK
     EVT_COMMAND(INTF_DIALOG_UPDATEVLC, wxEVT_DIALOG,
                 DialogsProvider::OnUpdateVLC)
+#endif
 #if 0
     EVT_COMMAND(INTF_DIALOG_VLM, wxEVT_DIALOG,
                 DialogsProvider::OnVLM)
@@ -191,11 +199,13 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
     p_wizard_dialog = NULL;
     p_bookmarks_dialog = NULL;
     p_dir_dialog = NULL;
+#ifdef UPDATE_CHECK
     p_updatevlc_dialog = NULL;
+#endif
     //p_vlm_dialog = NULL;
 
     /* Give our interface a nice little icon */
-    p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
+    p_intf->p_sys->p_icon = new wxIcon( (const char**) vlc_xpm );
 
     /* Create the messages dialog so it can begin storing logs */
     p_messages_dialog = new Messages( p_intf, p_parent ? p_parent : this );
@@ -254,20 +264,22 @@ DialogsProvider::~DialogsProvider()
     PopEventHandler(true);
 
     /* Clean up */
-    if( p_open_dialog )     delete p_open_dialog;
+    delete p_open_dialog;
     if( p_prefs_dialog )    p_prefs_dialog->Destroy();
-    if( p_file_dialog )     delete p_file_dialog;
-    if( p_playlist_dialog ) delete p_playlist_dialog;
-    if( p_messages_dialog ) delete p_messages_dialog;
-    if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
-    if( p_file_generic_dialog ) delete p_file_generic_dialog;
-    if( p_wizard_dialog ) delete p_wizard_dialog;
-    if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
-    if( p_updatevlc_dialog ) delete p_updatevlc_dialog;
-    //if( p_vlm_dialog ) delete p_vlm_dialog;
+    delete p_file_dialog;
+    delete p_playlist_dialog;
+    delete p_messages_dialog;
+    delete p_fileinfo_dialog;
+    delete p_file_generic_dialog;
+    delete p_wizard_dialog;
+    delete p_bookmarks_dialog;
+#ifdef UPDATE_CHECK
+    delete p_updatevlc_dialog;
+#endif
+    //delete p_vlm_dialog;
 
 
-    if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
+    delete p_intf->p_sys->p_icon;
 
     /* We must set this here because on win32 this destructor will be
      * automatically called so we must not call it again on wxApp->OnExit().
@@ -415,17 +427,15 @@ void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event )
         }
         free( p_arg->psz_results );
     }
-    if( p_arg->psz_title ) free( p_arg->psz_title );
-    if( p_arg->psz_extensions ) free( p_arg->psz_extensions );
+    free( p_arg->psz_title );
+    free( p_arg->psz_extensions );
 
     free( p_arg );
 }
 
 void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
 {
-    playlist_t *p_playlist =
-        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                       FIND_ANYWHERE );
+    playlist_t *p_playlist = pl_Yield( p_intf );
     if( p_playlist == NULL )
     {
         return;
@@ -435,10 +445,10 @@ void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
         p_file_dialog = new wxFileDialog( NULL, wxU(_("Open File")),
             wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
 
-       p_file_dialog->SetWildcard(wxU(_("All Files (*.*)|*"
-        "|Sound Files (*.mp3, *.ogg, etc.)|" EXTENSIONS_AUDIO 
-        "|Video Files (*.avi, *.mpg, etc.)|" EXTENSIONS_VIDEO 
-        "|Playlist Files (*.m3u, *.pls, etc.)|" EXTENSIONS_PLAYLIST 
+    p_file_dialog->SetWildcard(wxU(_("All Files (*.*)|*"
+        "|Sound Files (*.mp3, *.ogg, etc.)|" EXTENSIONS_AUDIO
+        "|Video Files (*.avi, *.mpg, etc.)|" EXTENSIONS_VIDEO
+        "|Playlist Files (*.m3u, *.pls, etc.)|" EXTENSIONS_PLAYLIST
         "|Subtitle Files (*.srt, *.sub, etc.)|" EXTENSIONS_SUBTITLE)));
 
     if( p_file_dialog && p_file_dialog->ShowModal() == wxID_OK )
@@ -454,22 +464,19 @@ void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
                 playlist_Add( p_playlist, psz_utf8, NULL,
                               PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
                               (i ? PLAYLIST_PREPARSE : 0 ),
-                              PLAYLIST_END, VLC_TRUE, VLC_FALSE );
+                              PLAYLIST_END, true, false );
             else
                 playlist_Add( p_playlist, psz_utf8, NULL,
-                              PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE, VLC_FALSE );
+                              PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , true, false );
             wxLocaleFree( psz_utf8 );
         }
     }
-
-    vlc_object_release( p_playlist );
+    pl_Release( p_playlist );
 }
 
 void DialogsProvider::OnOpenDirectory( wxCommandEvent& event )
 {
-    playlist_t *p_playlist =
-        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                       FIND_ANYWHERE );
+    playlist_t *p_playlist = pl_Yield( p_intf );
     if( p_playlist == NULL )
     {
         return;
@@ -484,11 +491,10 @@ void DialogsProvider::OnOpenDirectory( wxCommandEvent& event )
         char *psz_utf8 = wxFromLocale( path );
         playlist_Add( p_playlist, psz_utf8, NULL,
                       PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
-                      PLAYLIST_END, VLC_TRUE, VLC_FALSE );
+                      PLAYLIST_END, true, false );
         wxLocaleFree( psz_utf8 );
     }
-
-    vlc_object_release( p_playlist );
+    pl_Release( p_playlist );
 }
 
 void DialogsProvider::OnOpenFile( wxCommandEvent& event )
@@ -551,6 +557,7 @@ void DialogsProvider::OnExitThread( wxCommandEvent& WXUNUSED(event) )
     wxTheApp->ExitMainLoop();
 }
 
+#ifdef UPDATE_CHECK
 void DialogsProvider::OnUpdateVLC( wxCommandEvent& WXUNUSED(event) )
 {
     /* Show/hide the file info window */
@@ -562,6 +569,7 @@ void DialogsProvider::OnUpdateVLC( wxCommandEvent& WXUNUSED(event) )
         p_updatevlc_dialog->Show( !p_updatevlc_dialog->IsShown() );
     }
 }
+#endif
 
 #if 0
 void DialogsProvider::OnVLM( wxCommandEvent& WXUNUSED(event) )