]> git.sesse.net Git - vlc/commitdiff
qt4(Win32): correct crash when saving preferences
authorErwan Tulou <erwan10@videolan.org>
Thu, 27 Aug 2009 12:22:14 +0000 (14:22 +0200)
committerErwan Tulou <erwan10@videolan.org>
Thu, 27 Aug 2009 12:58:53 +0000 (14:58 +0200)
The way options are stored in a list by append and retrieve by named index
(enum list) is kind of risky. Errors can easily occur, some are obvious
 (crash), others may be more silent.

modules/gui/qt4/components/simple_preferences.cpp

index 29110522de0ee1b0d91fad61f6aa19868e68a24f..ee7d4eebe83abbe8c970319be35c068a83cd6f8d 100644 (file)
@@ -519,6 +519,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             optionWidgets.append( ui.stylesCombo );
 #else
             ui.stylesCombo->hide();
+            optionWidgets.append( NULL );
 #endif
 
             ui.skins_zone->setEnabled( ui.skins->isChecked() );
@@ -760,8 +761,9 @@ void SPrefsPanel::apply()
             config_PutPsz( p_intf, "intf", "skins2" );
         if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
             config_PutPsz( p_intf, "intf", "qt" );
-        getSettings()->setValue( "MainWindow/QtStyle",
-            qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
+        if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
+            getSettings()->setValue( "MainWindow/QtStyle",
+                qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
 
         break;
     }