Force Move History refresh after loading/reverting variation
authorH.G. Muller <h.g.muller@hccnet.nl>
Wed, 27 Jul 2011 16:47:45 +0000 (18:47 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sat, 6 Aug 2011 16:40:52 +0000 (18:40 +0200)
The Move History window was not refreshed after switching to or from
a variation if that variation happened to have the same length as
the main line. Now a change in storedGames since the previous refresh will
force a full refresh to avoid this. For this to work, storedGames
did have to be decremented after ToNrEvent in PopInner, because ToNrEvent
calls HistorySet before the history is restored, so we don't want
it to snatch away the full refresh. A call to HistorySet had to be
added after PopInner is done restoring the move history.

backend.c
backend.h
history.c

index afb379b..b1e5e93 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -16443,8 +16443,8 @@ PopInner(Boolean annotate)
        int i, j, nrMoves;
        char buf[8000], moveBuf[20];
 
-       storedGames--;
-       ToNrEvent(savedFirst[storedGames]); // sets currentMove
+       ToNrEvent(savedFirst[storedGames-1]); // sets currentMove
+       storedGames--; // do this after ToNrEvent, to make sure HistorySet will refresh entire game after PopInner returns
        nrMoves = savedLast[storedGames] - currentMove;
        if(annotate) {
                int cnt = 10;
@@ -16492,6 +16492,7 @@ PopTail(Boolean annotate)
        CommentPopDown(); // make sure no stale variation comments to the destroyed line can remain open
 
        PopInner(annotate);
+       HistorySet(parseList, backwardMostMove, forwardMostMove, currentMove-1);
 
        if(storedGames == 0) GreyRevert(TRUE);
        return TRUE;
index 9dccb7f..56c9d3e 100644 (file)
--- a/backend.h
+++ b/backend.h
@@ -132,8 +132,8 @@ int PieceForSquare P((int x, int y));
 int OKToStartUserMove P((int x, int y));
 void Reset P((int redraw, int init));
 void ResetGameEvent P((void));
-Boolean HasPattern P(( const char * text, const char * pattern ));\r
-Boolean SearchPattern P(( const char * text, const char * pattern ));\r
+Boolean HasPattern P(( const char * text, const char * pattern ));
+Boolean SearchPattern P(( const char * text, const char * pattern ));
 int LoadGame P((FILE *f, int n, char *title, int useList));
 int LoadGameFromFile P((char *filename, int n, char *title, int useList));
 int CmailLoadGame P((FILE *f, int n, char *title, int useList));
@@ -283,6 +283,7 @@ typedef struct _ListGame {
     GameInfo gameInfo;      /*  Note that some entries may be NULL. */
 } ListGame;
  
+extern int storedGames;
 extern int opponentKibitzes;
 extern ChessSquare gatingPiece;
 extern List gameList;
@@ -388,7 +389,7 @@ typedef struct _CPS {
     char *optionSettings;
     void *programLogo; /* [HGM] logo: bitmap of the logo                    */
     char *fenOverride; /* [HGM} FRC: force FEN casling & ep fields by hand  */
-    char userError;    /* [HGM] crash: flag to suppress fatal-error messages*/\r
+    char userError;    /* [HGM] crash: flag to suppress fatal-error messages*/
 } ChessProgramState;
 
 extern ChessProgramState first, second;
@@ -414,7 +415,7 @@ extern ChessProgramStats_Move pvInfoList[MAX_MOVES];
 extern Boolean shuffleOpenings;
 extern ChessProgramStats programStats;
 extern int opponentKibitzes; // used by wengineo.c
-extern int errorExitStatus;\r
+extern int errorExitStatus;
 void SettingsPopUp P((ChessProgramState *cps)); // [HGM] really in front-end, but CPS not known in frontend.h
 int WaitForEngine P((ChessProgramState *cps, DelayedEventCallback x));
 void Load P((ChessProgramState *cps, int n));
index 6226889..7c64582 100644 (file)
--- a/history.c
+++ b/history.c
@@ -50,6 +50,7 @@ typedef char MoveHistoryString[ MOVE_LEN*2 ];
 static int lastFirst = 0;
 static int lastLast = 0;
 static int lastCurrent = -1;
+static int lastGames;
 
 static char lastLastMove[ MOVE_LEN ];
 
@@ -79,7 +80,7 @@ static Boolean OnlyCurrentPositionChanged()
         currFirst == lastFirst &&
         currLast == lastLast &&
         currCurrent >= 0 &&
-        TRUE )
+        lastGames == storedGames )
     {
         result = TRUE;
 
@@ -105,7 +106,7 @@ static Boolean OneMoveAppended()
         lastLast == (currLast-1) &&
         lastCurrent == (currCurrent-1) &&
         currCurrent == (currLast-1) &&
-        TRUE )
+        lastGames == storedGames )
     {
         result = TRUE;
     }
@@ -179,6 +180,7 @@ void MemoContentUpdated()
     lastFirst = currFirst;
     lastLast = currLast;
     lastCurrent = currCurrent;
+    lastGames = storedGames;
     lastLastMove[0] = '\0';
 
     if( lastLast > 0 ) {