From: H.G.Muller Date: Mon, 9 Mar 2015 19:35:45 +0000 (+0100) Subject: Fix display update during Edit Book X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2a1e296dac2afd76b0661e82ca5da911eef20697;p=xboard.git Fix display update during Edit Book When moves were deleted from the book, this was only shown after quitting and restarting XBoard, because the stream that was used for reading the book was a different one as the stream writing it. --- diff --git a/book.c b/book.c index c52e6e3..520d941 100644 --- a/book.c +++ b/book.c @@ -575,6 +575,8 @@ GetBookMoves (FILE *f, int moveNr, entry_t entries[], int max) return count; } +static int dirty; + int ReadFromBookFile (int moveNr, char *book, entry_t entries[]) { // retrieve all entries for given position from book in 'entries', return number. @@ -582,6 +584,7 @@ ReadFromBookFile (int moveNr, char *book, entry_t entries[]) static char curBook[MSG_SIZ]; if(book == NULL) return -1; + if(dirty) { if(f) fclose(f); dirty = 0; f = NULL; } if(!f || strcmp(book, curBook)){ // keep book file open until book changed strncpy(curBook, book, MSG_SIZ); if(f) fclose(f); @@ -873,6 +876,7 @@ SaveToBook (char *text) writepos += len2; } while(len1); } + dirty = 1; fclose(f); }