]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwindows/wxwindows.cpp: include setlocale.h after the vlc headers.
authorGildas Bazin <gbazin@videolan.org>
Thu, 26 Feb 2004 12:04:14 +0000 (12:04 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 26 Feb 2004 12:04:14 +0000 (12:04 +0000)
* modules/gui/wxwindows/menus.cpp: fixed memory leaks.
* modules/gui/wxwindows/playlist.cpp: fixed deadlock.

modules/gui/wxwindows/menus.cpp
modules/gui/wxwindows/playlist.cpp
modules/gui/wxwindows/wxwindows.cpp

index 5d748f8d4e0331293e1d71a0123606cdaa5837f0..8bcf9745bbeca830caca53bfd5cbfa6eb0887359 100644 (file)
@@ -2,7 +2,7 @@
  * menus.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2004 VideoLAN
- * $Id: menus.cpp,v 1.32 2004/02/26 00:23:04 gbazin Exp $
+ * $Id: menus.cpp,v 1.33 2004/02/26 12:04:14 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -531,8 +531,6 @@ void Menu::CreateMenuItem( wxMenu *menu, char *psz_var,
     /* Get the descriptive name of the variable */
     var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
 
-    var_Get( p_object, psz_var, &val );
-
     if( i_type & VLC_VAR_HASCHOICE )
     {
         menu->Append( MenuDummy_Event,
@@ -548,6 +546,7 @@ void Menu::CreateMenuItem( wxMenu *menu, char *psz_var,
     switch( i_type & VLC_VAR_TYPE )
     {
     case VLC_VAR_VOID:
+        var_Get( p_object, psz_var, &val );
         menuitem = new wxMenuItemExt( menu, ++i_item_id,
                                       wxU(text.psz_string ?
                                         text.psz_string : psz_var),
@@ -557,6 +556,7 @@ void Menu::CreateMenuItem( wxMenu *menu, char *psz_var,
         break;
 
     case VLC_VAR_BOOL:
+        var_Get( p_object, psz_var, &val );
         val.b_bool = !val.b_bool;
         menuitem = new wxMenuItemExt( menu, ++i_item_id,
                                       wxU(text.psz_string ?
@@ -566,13 +566,8 @@ void Menu::CreateMenuItem( wxMenu *menu, char *psz_var,
         menu->Append( menuitem );
         Check( i_item_id, val.b_bool ? FALSE : TRUE );
         break;
-
-    default:
-        if( text.psz_string ) free( text.psz_string );
-        return;
     }
 
-    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
     if( text.psz_string ) free( text.psz_string );
 }
 
@@ -601,15 +596,9 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
         return NULL;
     }
 
-    if( var_Get( p_object, psz_var, &val ) < 0 )
-    {
-        return NULL;
-    }
-
     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
                     &val_list, &text_list ) < 0 )
     {
-        if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
         return NULL;
     }
 
@@ -632,6 +621,8 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
           break;
 
         case VLC_VAR_STRING:
+          var_Get( p_object, psz_var, &val );
+
           another_val.psz_string =
               strdup(val_list.p_list->p_values[i].psz_string);
           menuitem =
@@ -646,13 +637,17 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
 
           menu->Append( menuitem );
 
-          if( !(i_type & VLC_VAR_ISCOMMAND) &&
+          if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
               !strcmp( val.psz_string,
                        val_list.p_list->p_values[i].psz_string ) )
               menu->Check( i_item_id, TRUE );
+
+          if( val.psz_string ) free( val.psz_string );
           break;
 
         case VLC_VAR_INTEGER:
+          var_Get( p_object, psz_var, &val );
+
           menuitem =
               new wxMenuItemExt( menu, ++i_item_id,
                                  text_list.p_list->p_values[i].psz_string ?
@@ -679,7 +674,6 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
     }
 
     /* clean up everything */
-    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
 
     return menu;
index 34bf04c44a14377e3e98df0863bf81b71775c106..ca6dd453f5ccea596da7d701020cbc656b5c1db2 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2004 VideoLAN
- * $Id: playlist.cpp,v 1.45 2004/02/26 08:24:29 gbazin Exp $
+ * $Id: playlist.cpp,v 1.46 2004/02/26 12:04:14 gbazin Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *
@@ -541,11 +541,11 @@ void Playlist::UpdatePlaylist()
     }
 
     /* Update the colour of items */
-    vlc_mutex_lock( &p_playlist->object_lock );
-    if( p_intf->p_sys->i_playing != p_playlist->i_index )
+    int i_playlist_index = p_playlist->i_index;
+    if( p_intf->p_sys->i_playing != i_playlist_index )
     {
         wxListItem listitem;
-        listitem.m_itemId = p_playlist->i_index;
+        listitem.m_itemId = i_playlist_index;
         listitem.SetTextColour( *wxRED );
         listview->SetItem( listitem );
 
@@ -555,9 +555,8 @@ void Playlist::UpdatePlaylist()
             listitem.SetTextColour( *wxBLACK );
             listview->SetItem( listitem );
         }
-        p_intf->p_sys->i_playing = p_playlist->i_index;
+        p_intf->p_sys->i_playing = i_playlist_index;
     }
-    vlc_mutex_unlock( &p_playlist->object_lock );
 
     vlc_object_release( p_playlist );
 }
index 2b8808c5ef7995da461f51823a50e73e3fcd07ad..0ef1d12f2c65d5c564ac711539968ebfe0331d29 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2004 VideoLAN
- * $Id: wxwindows.cpp,v 1.38 2004/01/25 03:29:02 hartman Exp $
+ * $Id: wxwindows.cpp,v 1.39 2004/02/26 12:04:14 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 #include <string.h>                                            /* strerror() */
 #include <stdio.h>
 
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+
 #ifdef HAVE_LOCALE_H
 #   include <locale.h>
 #endif
 
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
-
 #include "wxwindows.h"
 
 /* Temporary hack */