From 2a1e296dac2afd76b0661e82ca5da911eef20697 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 9 Mar 2015 20:35:45 +0100 Subject: [PATCH] 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. --- book.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) 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); } -- 1.7.0.4