[vlc-commits] Qt: kill warnings and probably a crash on Win32

Jean-Baptiste Kempf git at videolan.org
Sat May 14 20:43:35 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat May 14 20:43:03 2011 +0200| [19acda054bf4312dec4d82e0646cb90437157cff] | committer: Jean-Baptiste Kempf

Qt: kill warnings and probably a crash on Win32

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19acda054bf4312dec4d82e0646cb90437157cff
---

 modules/gui/qt4/components/simple_preferences.cpp |    8 ++++----
 modules/gui/qt4/util/registry.cpp                 |   14 +++++---------
 modules/gui/qt4/util/registry.hpp                 |    2 +-
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp
index ea2858b..2a4e6ac 100644
--- a/modules/gui/qt4/components/simple_preferences.cpp
+++ b/modules/gui/qt4/components/simple_preferences.cpp
@@ -912,7 +912,7 @@ bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
     const char* psz_VLC = "VLC";
     current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
 
-    if( strstr( qvReg->ReadRegistryString( psz_ext, "", ""  ), psz_VLC ) )
+    if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
     {
         current->setCheckState( 0, Qt::Checked );
         b_temp = false;
@@ -966,7 +966,7 @@ void SPrefsPanel::assoDialog()
     videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
     otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
 
-    QTreeWidgetItem *currentItem;
+    QTreeWidgetItem *currentItem = NULL;
 
     int i_temp = 0;
 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
@@ -1066,7 +1066,7 @@ void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
 {
     char psz_VLC[] = "VLC";
-    char *psz_value = qvReg->ReadRegistryString( psz_ext, "", ""  );
+    char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
 
     if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
     {
@@ -1081,7 +1081,7 @@ void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
 }
 void SPrefsPanel::saveAsso()
 {
-    QVLCRegistry * qvReg;
+    QVLCRegistry * qvReg = NULL;
     for( int i = 0; i < listAsso.size(); i ++ )
     {
         qvReg  = new QVLCRegistry( HKEY_CLASSES_ROOT );
diff --git a/modules/gui/qt4/util/registry.cpp b/modules/gui/qt4/util/registry.cpp
index 263a3bf..9758e28 100644
--- a/modules/gui/qt4/util/registry.cpp
+++ b/modules/gui/qt4/util/registry.cpp
@@ -128,10 +128,12 @@ int QVLCRegistry::ReadRegistryInt( const char *path, const char *valueName, int
     return default_value;
 }
 
-char * QVLCRegistry::ReadRegistryString( const char *path, const char *valueName, char *default_value )
+char * QVLCRegistry::ReadRegistryString( const char *path, const char *valueName, const char *default_value )
 {
     HKEY keyHandle;
     char *tempValue = NULL;
+    char *tempValue2 = NULL;
+
     DWORD size1;
     DWORD valueType;
 
@@ -145,20 +147,14 @@ char * QVLCRegistry::ReadRegistryString( const char *path, const char *valueName
                tempValue = ( char * )malloc( size1+1 ); // +1 für NullByte`?
                if( RegQueryValueEx(  keyHandle, valueName, NULL, &valueType, (LPBYTE)tempValue, &size1 ) == ERROR_SUCCESS )
                {
-                  default_value = tempValue;
+                  tempValue2 = tempValue;
                };
            }
         }
         RegCloseKey( keyHandle );
     }
-    if( tempValue == NULL )
-    {
-        // wenn tempValue nicht aus registry gelesen wurde dafür sorgen das ein neuer String mit der Kopie von DefaultValue
-        // geliefert wird - das macht das Handling des Rückgabewertes der Funktion einfacher - immer schön mit free freigeben!
-        default_value = strdup( default_value );
-    }
 
-    return default_value;
+    return tempValue == NULL ? strdup( default_value ) : tempValue2;
 }
 
 double QVLCRegistry::ReadRegistryDouble( const char *path, const char *valueName, double default_value )
diff --git a/modules/gui/qt4/util/registry.hpp b/modules/gui/qt4/util/registry.hpp
index 361211a..3cac7db 100644
--- a/modules/gui/qt4/util/registry.hpp
+++ b/modules/gui/qt4/util/registry.hpp
@@ -39,7 +39,7 @@ public:
     void WriteRegistryDouble( const char *path, const char *valueName, double value);
 
     int ReadRegistryInt( const char *path, const char *valueName, int default_value);
-    char * ReadRegistryString( const char *path, const char *valueName, char *default_value);
+    char * ReadRegistryString( const char *path, const char *valueName, const char *default_value);
     double ReadRegistryDouble( const char *path, const char *valueName, double default_value);
 
     bool RegistryKeyExists( const char *path);



More information about the vlc-commits mailing list