From: H.G. Muller Date: Wed, 27 Jul 2011 16:47:45 +0000 (+0200) Subject: Force Move History refresh after loading/reverting variation X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=98d170abf0ab910767ea165d9cb94ece49ff3e08;p=xboard.git Force Move History refresh after loading/reverting variation 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. --- diff --git a/backend.c b/backend.c index afb379b..b1e5e93 100644 --- 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; diff --git a/backend.h b/backend.h index 9dccb7f..56c9d3e 100644 --- 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 )); -Boolean SearchPattern P(( const char * text, const char * pattern )); +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*/ + 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; +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)); diff --git a/history.c b/history.c index 6226889..7c64582 100644 --- 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 ) {