[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.8/kdegames/kpat
From:       Parker Coates <parker.coates () kdemail ! net>
Date:       2012-01-22 4:08:37
Message-ID: 20120122040837.30D57AC892 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1275131 by coates:

Backport of commit 1275129.

Don't bother saving state on close if the player has already won.

This was a behaviour regression caused by the clean up of the loading
and saving code. Somewhat surprisingly, saving after the game has been
won worked without issue and loading that save caused the player to
instantly win again, so it acted like the state was actually remembered.
Of course, the user doesn't expect to fire up KPat just to be instantly
told that they've won.

CCBUG:291959


 M  +3 -3      dealer.h  
 M  +6 -6      mainwindow.cpp  


--- branches/KDE/4.8/kdegames/kpat/dealer.h #1275130:1275131
@@ -102,6 +102,9 @@
     Solver * solver() const;
     void startSolver() const;
 
+    virtual bool isGameLost() const;
+    virtual bool isGameWon() const;
+
     bool allowedToStartNewGame();
     int moveCount() const;
 
@@ -159,9 +162,6 @@
 
     void setSolver( Solver * solver );
 
-    virtual bool isGameLost() const;
-    virtual bool isGameWon() const;
-
     virtual QList<MoveHint> getHints();
 
     // reimplement these to store and load game-specific information in the state structure
--- branches/KDE/4.8/kdegames/kpat/mainwindow.cpp #1275130:1275131
@@ -733,21 +733,21 @@
 
 void MainWindow::closeEvent(QCloseEvent *e)
 {
-    if ( m_dealer )
-    {
         QString stateFileName = KStandardDirs::locateLocal( "appdata", saved_state_file );
         QFile stateFile( stateFileName );
 
-        if ( Settings::rememberStateOnExit() )
+    // Remove the existing state file, if any.
+    stateFile.remove();
+    
+    if ( m_dealer )
         {
+        if ( Settings::rememberStateOnExit() && !m_dealer->isGameWon() )
+        {
             stateFile.open( QFile::WriteOnly | QFile::Truncate );
             m_dealer->saveGame( &stateFile );
         }
         else
         {
-            // If we're not going to save state, remove the state file, if any.
-            stateFile.remove();
-
             // If there's a game in progress and we aren't going to save it
             // then record its statistics, since the DealerScene will be destroyed
             // shortly.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic