]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/menus.cpp
Use pl_Release with the right argument.
[vlc] / modules / gui / wxwidgets / menus.cpp
index 0f6513fcf069152151c66fe15c98a9f3cb456a24..ff0a99c1804131a7c0337f281c2bb3a2c3577aae 100644 (file)
@@ -25,7 +25,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_interface.h>
 
 #include "wxwidgets.hpp"
@@ -206,16 +206,6 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf, ArrayOfInts &ri_objects,
                                                 FIND_PARENT );
     if( p_object != NULL )
     {
-        if( is_popup )
-        {
-#ifndef WIN32
-            PUSH_VAR( "intf-switch" );
-#endif
-        }
-        else
-        {
-            PUSH_VAR( "intf-switch" );
-        }
         PUSH_VAR( "intf-add" );
         PUSH_VAR( "intf-skins" );
         vlc_object_release( p_object );
@@ -239,8 +229,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf, ArrayOfInts &ri_objects,
     unsigned int i_last_separator = 0; \
     ArrayOfInts ai_objects; \
     ArrayOfStrings as_varnames; \
-    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 ) \
         return; \
     input_thread_t *p_input = p_playlist->p_input
@@ -280,7 +269,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf, ArrayOfInts &ri_objects,
             popupmenu.InsertSeparator( 0 ); \
             popupmenu.Insert( 0, Play_Event, wxU(_("Play")) ); \
         } \
-        if( p_playlist ) vlc_object_release( p_playlist ); \
+        if( p_playlist ) pl_Release( p_intf ); \
     } \
     \
     popupmenu.Append( MenuDummy_Event, wxU(_("Miscellaneous")), \
@@ -307,7 +296,7 @@ void VideoPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
         }
         vlc_object_release( p_input );
     }
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
     CREATE_POPUP;
 }
 
@@ -329,7 +318,7 @@ void AudioPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
         }
         vlc_object_release( p_input );
     }
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
     CREATE_POPUP;
 }
 
@@ -358,7 +347,7 @@ void MiscPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
     p_intf->p_sys->p_popup_menu = &popupmenu;
     p_parent->PopupMenu( &popupmenu, pos.x, pos.y );
     p_intf->p_sys->p_popup_menu = NULL;
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
@@ -414,7 +403,7 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
     p_intf->p_sys->p_popup_menu = &popupmenu;
     p_parent->PopupMenu( &popupmenu, pos.x, pos.y );
     p_intf->p_sys->p_popup_menu = NULL;
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
 }
 
 /*****************************************************************************
@@ -527,7 +516,6 @@ wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
                                                 FIND_PARENT );
     if( p_object != NULL )
     {
-        PUSH_VAR( "intf-switch" );
         PUSH_VAR( "intf-add" );
         vlc_object_release( p_object );
     }
@@ -565,7 +553,7 @@ void Menu::Populate( ArrayOfStrings & ras_varnames,
                      ArrayOfInts & rai_objects )
 {
     vlc_object_t *p_object;
-    vlc_bool_t b_section_empty = VLC_FALSE;
+    bool b_section_empty = false;
     int i;
 
     i_item_id = i_start_id;
@@ -580,22 +568,21 @@ void Menu::Populate( ArrayOfStrings & ras_varnames,
                 Enable( MenuDummy_Event + i, FALSE );
             }
             AppendSeparator();
-            b_section_empty = VLC_TRUE;
+            b_section_empty = true;
             continue;
         }
 
         if( rai_objects[i] == 0  )
         {
             Append( MenuDummy_Event, wxU(ras_varnames[i]) );
-            b_section_empty = VLC_FALSE;
+            b_section_empty = false;
             continue;
         }
 
-        p_object = (vlc_object_t *)vlc_object_get( p_intf,
-                                                   rai_objects[i] );
+        p_object = (vlc_object_t *)vlc_object_get( rai_objects[i] );
         if( p_object == NULL ) continue;
 
-        b_section_empty = VLC_FALSE;
+        b_section_empty = false;
         CreateMenuItem( this, ras_varnames[i], p_object );
         vlc_object_release( p_object );
     }
@@ -652,8 +639,6 @@ static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object,
 
     if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
     {
-        /* Very evil hack ! intf-switch can have only one value */
-        if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
         if( val.i_int == 1 && b_root ) return TRUE;
         else return FALSE;
     }
@@ -717,7 +702,7 @@ void Menu::CreateMenuItem( wxMenu *menu, const char *psz_var,
                       CreateChoicesMenu( psz_var, p_object, TRUE ),
                       wxT("")/* Nothing for now (maybe use a GETLONGTEXT) */ );
 
-        if( text.psz_string ) free( text.psz_string );
+        free( text.psz_string );
         return;
     }
 
@@ -747,7 +732,7 @@ void Menu::CreateMenuItem( wxMenu *menu, const char *psz_var,
         break;
     }
 
-    if( text.psz_string ) free( text.psz_string );
+    free( text.psz_string );
 }
 
 wxMenu *Menu::CreateChoicesMenu( const char *psz_var, vlc_object_t *p_object,
@@ -822,7 +807,7 @@ wxMenu *Menu::CreateChoicesMenu( const char *psz_var, vlc_object_t *p_object,
                        val_list.p_list->p_values[i].psz_string ) )
               menu->Check( i_item_id, TRUE );
 
-          if( val.psz_string ) free( val.psz_string );
+          free( val.psz_string );
           break;
 
         case VLC_VAR_INTEGER:
@@ -951,9 +936,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
     if( event.GetId() >= Play_Event && event.GetId() <= Stop_Event )
     {
         input_thread_t *p_input;
-        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 ) return;
 
         switch( event.GetId() )
@@ -984,8 +967,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
             playlist_Next( p_playlist );
             break;
         }
-
-        vlc_object_release( p_playlist );
+        pl_Release( p_intf );
         return;
     }
 
@@ -1026,8 +1008,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
         wxMenuItemExt *p_menuitemext = (wxMenuItemExt *)p_menuitem;
         vlc_object_t *p_object;
 
-        p_object = (vlc_object_t *)vlc_object_get( p_intf,
-                                       p_menuitemext->i_object_id );
+        p_object = (vlc_object_t *)vlc_object_get( p_menuitemext->i_object_id );
         if( p_object == NULL ) return;
 
         wxMutexGuiLeave(); // We don't want deadlocks
@@ -1058,7 +1039,7 @@ wxMenuItemExt::wxMenuItemExt( wxMenu* parentMenu, int id, const wxString& text,
 
 wxMenuItemExt::~wxMenuItemExt()
 {
-    if( psz_var ) free( psz_var );
-    if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
-        && val.psz_string ) free( val.psz_string );
+    free( psz_var );
+    if( ( i_val_type & VLC_VAR_TYPE ) == VLC_VAR_STRING )
+        free( val.psz_string );
 };