Qt4 - fix some saving and reading size bugs. Patch by Andre Weber
authorJean-Baptiste Kempf <jb@videolan.org>
Wed, 16 Jan 2008 08:22:22 +0000 (08:22 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 16 Jan 2008 08:22:22 +0000 (08:22 +0000)
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/util/qvlcframe.hpp

index 5675a59..a203666 100644 (file)
@@ -293,7 +293,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     move( settings->value( "pos", QPoint( 0, 0 ) ).toPoint() );
 
-    resize( settings->value( "size", QSize( 350, 60 ) ).toSize() );
+    QSize newSize = settings->value( "size", QSize( 350, 60 ) ).toSize();
+    if( newSize.isValid() )
+    {
+        resize( newSize );
+    }
+    else
+    {
+        msg_Warn( p_intf, "Invalid size in constructor" );
+    }
 
     int tgPlay = settings->value( "playlist-visible", 0 ).toInt();
     settings->endGroup();
@@ -738,8 +746,11 @@ void MainInterface::togglePlaylist()
         settings->endGroup();
         settings->beginGroup( "playlist" );
         dockPL->move( settings->value( "pos", QPoint( 0,0 ) ).toPoint() );
-        dockPL->resize( settings->value( "size", QSize( 400, 300 ) ).toSize() );
+        QSize newSize = settings->value( "size", QSize( 400, 300 ) ).toSize();
+        if( newSize.isValid() )
+            dockPL->resize( newSize );
         settings->endGroup();
+
         dockPL->show();
         playlistVisible = true;
     }
index d1f2a61..a45c392 100644 (file)
@@ -58,7 +58,10 @@ protected:
     {
         QSettings settings( "vlc", "vlc-qt-interface" );
         settings.beginGroup( name );
-        resize( settings.value( "size", defSize ).toSize() );
+        /* never trust any saved size ;-) */
+        QSize newSize = settings.value( "size", defSize ).toSize();
+        if( newSize.isValid() )
+           resize( newSize );
         move( settings.value( "pos", defPos ).toPoint() );
         settings.endGroup();
     }
@@ -66,7 +69,10 @@ protected:
     {
         QSettings settings( "vlc", "vlc-qt-interface" );
         settings.beginGroup( name );
-        settings.setValue ("size", size() );
+        /* only save valid sizes ... */
+        QSize currentsize = size();
+        if( currentsize.isValid() )
+           settings.setValue ("size", currentsize );
         settings.setValue( "pos", pos() );
         settings.endGroup();
     }
@@ -156,18 +162,27 @@ protected:
         move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
         settings.endGroup();
     }
+
     void readSettings( QString name )
     {
         QSettings settings( "vlc", "vlc-qt-interface" );
         settings.beginGroup( name );
         mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
+        if( !mainSize.isValid() )
+        {
+           mainSize = QSize(0,0);
+        }
         settings.endGroup();
     }
+
     void writeSettings( QString name )
     {
         QSettings settings( "vlc", "vlc-qt-interface" );
         settings.beginGroup( name );
-        settings.setValue ("size", size() );
+        /* only save valid sizes ... */
+        QSize currentsize = size();
+        if( currentsize.isValid() )
+            settings.setValue ("size", currentsize );
         settings.setValue( "pos", pos() );
         settings.endGroup();
     }