This patch allow to change the board without waiting for tree windows to complete search.
Can you try it to see if there are some bugs or side effects?
? .cproject
? .project
? Makefile
Index: src/position.cpp
===================================================================
RCS file: /cvsroot/scid/scid/src/position.cpp,v
retrieving revision 1.9
diff -u -p -r1.9 position.cpp
--- src/position.cpp	6 Jan 2010 17:17:24 -0000	1.9
+++ src/position.cpp	19 Apr 2010 14:49:42 -0000
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <ctype.h>
+#include <string.h>
 
 static uint hashVal [16][64];
 static uint stdStartHash = 0;
@@ -31,6 +32,26 @@ static uint stdStartPawnHash = 0;
 #define HASH(h,p,sq)    (h) ^= hashVal[(p)][(sq)]
 #define UNHASH(h,p,sq)  (h) ^= hashVal[(p)][(sq)]
 
+Position::Position(const Position& p)
+: EPTarget(p.EPTarget), ToMove(p.ToMove), HalfMoveClock(p.HalfMoveClock),
+  PlyCounter (p.PlyCounter), Castling(p.Castling), StrictCastling(p.StrictCastling),
+  Hash(p.Hash), PawnHash(p.PawnHash), LegalMoves(0), SANStrings(0)
+{
+	memcpy(Board, p.Board, sizeof(Board));
+	memcpy(Count, p.Count, sizeof(Count));
+	memcpy(Material, p.Material, sizeof(Material));
+	memcpy(ListPos, p.ListPos, sizeof(ListPos));
+	memcpy(List, p.List, sizeof(List));
+	memcpy(NumOnRank, p.NumOnRank, sizeof(NumOnRank));
+	memcpy(NumOnFyle, p.NumOnFyle, sizeof(NumOnFyle));
+	memcpy(NumOnLeftDiag, p.NumOnLeftDiag, sizeof(NumOnLeftDiag));
+	memcpy(NumOnRightDiag, p.NumOnRightDiag, sizeof(NumOnRightDiag));
+	memcpy(NumOnSquareColor, p.NumOnSquareColor, sizeof(NumOnSquareColor));
+	memcpy(Pinned, p.Pinned, sizeof(Pinned));
+	if (p.LegalMoves) LegalMoves = new MoveList(*p.LegalMoves);
+	if (p.SANStrings) SANStrings = new sanListT(*p.SANStrings);
+}
+
 inline void
 Position::AddHash (pieceT p, squareT sq)
 {
Index: src/position.h
===================================================================
RCS file: /cvsroot/scid/scid/src/position.h,v
retrieving revision 1.8
diff -u -p -r1.8 position.h
--- src/position.h	6 Jan 2010 17:17:24 -0000	1.8
+++ src/position.h	19 Apr 2010 14:49:42 -0000
@@ -163,6 +163,7 @@ public:
 
 #endif
     Position()   { Init(); }
+    Position(const Position& p);
     ~Position()  {
                      if (LegalMoves != NULL) { delete LegalMoves; }
 #ifdef WINCE
Index: src/tkscid.cpp
===================================================================
RCS file: /cvsroot/scid/scid/src/tkscid.cpp,v
retrieving revision 1.55
diff -u -p -r1.55 tkscid.cpp
--- src/tkscid.cpp	13 Apr 2010 21:28:04 -0000	1.55
+++ src/tkscid.cpp	19 Apr 2010 14:50:01 -0000
@@ -18,6 +18,7 @@
 
 #include <sys/fcntl.h>
 #include <errno.h>
+#include <set>
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Global variables:
@@ -127,7 +128,7 @@ PreMoveCommand (Tcl_Interp * ti)
 // Progress Bar update routine:
 //
 static void
-updateProgressBar (Tcl_Interp * ti, uint done, uint total)
+updateProgressBar (Tcl_Interp * ti, uint done, uint total, bool update_idletasks_only = false)
 {
     char tempStr [250];
     uint width = progBar.width;
@@ -155,7 +156,10 @@ updateProgressBar (Tcl_Interp * ti, uint
                  elapsed / 60, elapsed % 60, estimated / 60, estimated % 60);
         Tcl_Eval (ti, tempStr);
     }
-    Tcl_Eval (ti, "update");
+    if (update_idletasks_only)
+        Tcl_Eval (ti, "update idletasks");
+    else
+    	Tcl_Eval (ti, "update");
 }
 
 static bool
@@ -13402,13 +13406,10 @@ sc_tree_search (ClientData cd, Tcl_Inter
     int sortMethod = SORT_FREQUENCY; // default move order: frequency
 
     scidBaseT * base = db;
-    Game *g = scratchGame;
-    db->bbuf->Empty();
-    bool showProgress = startProgressBar();
+    static std::set<scidBaseT**> search_pool;
 
     // Check that there is an even number of optional arguments and
     // parse them as option-value pairs:
-
     int arg = 2;
     int argsLeft = (argc - arg);
     if (argsLeft % 2 != 0) { return errorResult (ti, usageStr); }
@@ -13431,6 +13432,9 @@ sc_tree_search (ClientData cd, Tcl_Inter
             listMode = strGetBoolean (argv[arg+1]);
         } else if (strIsPrefix (argv[arg], "-fastmode")) {
             fastMode = strGetBoolean (argv[arg+1]);
+        } else if (strIsPrefix (argv[arg], "-cancel")) {
+        	search_pool.clear();
+        	return TCL_OK;
         } else {
             return errorResult (ti, usageStr);
         }
@@ -13442,281 +13446,289 @@ sc_tree_search (ClientData cd, Tcl_Inter
     if (!base->inUse) {
         return setResult (ti, errMsgNotOpen(ti));
     }
+    search_pool.insert(&base);
 
-    IndexEntry * ie;
-    simpleMoveT sm;
-    treeT *tree = &(base->tree);
-    treeNodeT * node;
-    tree->moveCount = tree->totalCount = 0;
-
+    bool showProgress = startProgressBar();
     Timer timer;  // Start timing this search.
-
-    // Reset the filter to be empty:
-    base->filter->Fill (0);
-
-    Position * pos = db->game->GetCurrentPos();
-    matSigT msig = matsig_Make (pos->GetMaterial());
-    uint hpSig = pos->GetHPSig();
     uint skipcount = 0;
-    uint updateStart, update;
-    updateStart = update = 5000;  // Update progress bar every 5000 games
 
+    // 1. Cache Search
     bool foundInCache = false;
     // Check if there is a TreeCache file to open:
     base->treeCache->ReadFile (base->fileName);
 
     // Lookup the cache before searching:
-    cachedTreeT * pct = base->treeCache->Lookup (pos);
+    cachedTreeT * pct = base->treeCache->Lookup (db->game->GetCurrentPos());
     if (pct != NULL) {
-        // It was in the cache! Use it to save time:
-        if (pct->cfilter->Size() == base->numGames) {
-            if (pct->cfilter->UncompressTo (base->filter) == OK) {
-                base->tree = pct->tree;
-                tree = &(base->tree);
-                foundInCache = true;
-            }
-        }
+    	// It was in the cache! Use it to save time:
+    	if (pct->cfilter->Size() == base->numGames) {
+    		if (pct->cfilter->UncompressTo (base->filter) == OK) {
+    			base->tree = pct->tree;
+    			foundInCache = true;
+    		}
+    	}
     }
 
     // Lookup the backup cache which is useful for storing recent nodes
     // when the main disk-file cache is full:
     if (! foundInCache) {
-        pct = base->backupCache->Lookup (pos);
-        if (pct != NULL) {
-            // It was in the backup cache! Use it to save time:
-            if (pct->cfilter->Size() == base->numGames) {
-                if (pct->cfilter->UncompressTo (base->filter) == OK) {
-                    base->tree = pct->tree;
-                    tree = &(base->tree);
-                    foundInCache = true;
-                }
-            }
-        }
+    	pct = base->backupCache->Lookup (db->game->GetCurrentPos());
+    	if (pct != NULL) {
+    		// It was in the backup cache! Use it to save time:
+    		if (pct->cfilter->Size() == base->numGames) {
+    			if (pct->cfilter->UncompressTo (base->filter) == OK) {
+    				base->tree = pct->tree;
+    				foundInCache = true;
+    			}
+    		}
+    	}
     }
 
+
 #ifndef WINCE
     // we went back before the saved filter data
     if (base->filter->oldDataTreePly > db->game->GetCurrentPly()) {
-      base->filter->isValidOldDataTree = false;
+    	base->filter->isValidOldDataTree = false;
     }
 
     if ( foundInCache && fastMode ) {
-      base->filter->saveFilterForFastMode(db->game->GetCurrentPly());
+    	base->filter->saveFilterForFastMode(db->game->GetCurrentPly());
     }
 #endif
 
-    if (! foundInCache) {
-        // OK, not in the cache so do the search:
-
-        // First, set up the stored line code matches:
-        uint numStoredLines = StoredLine::Count();
-        byte storedLineMatches [MAX_STORED_LINES];
-        simpleMoveT storedLineMoves [MAX_STORED_LINES];
-        bool storedLineNeverMatches [MAX_STORED_LINES];
-        pieceT * bd = pos->GetBoard();
-        bool isStartPos =
-            (bd[A1]==WR  &&  bd[B1]==WN  &&  bd[C1]==WB  &&  bd[D1]==WQ  &&
-             bd[E1]==WK  &&  bd[F1]==WB  &&  bd[G1]==WN  &&  bd[H1]==WR  &&
-             bd[A2]==WP  &&  bd[B2]==WP  &&  bd[C2]==WP  &&  bd[D2]==WP  &&
-             bd[E2]==WP  &&  bd[F2]==WP  &&  bd[G2]==WP  &&  bd[H2]==WP  &&
-             bd[A7]==BP  &&  bd[B7]==BP  &&  bd[C7]==BP  &&  bd[D7]==BP  &&
-             bd[E7]==BP  &&  bd[F7]==BP  &&  bd[G7]==BP  &&  bd[H7]==BP  &&
-             bd[A8]==BR  &&  bd[B8]==BN  &&  bd[C8]==BB  &&  bd[D8]==BQ  &&
-             bd[E8]==BK  &&  bd[F8]==BB  &&  bd[G8]==BN  &&  bd[H8]==BR);
-
-        for (uint line = 1; line <= numStoredLines; line++) {
-            Game * lineGame = StoredLine::GetGame (line);
-            lineGame->MoveToPly (0);
-            storedLineMatches[line] = 0;
-            storedLineNeverMatches[line] = false;
-            bool b = false;
-            if (lineGame->ExactMatch (pos, NULL, &sm, &b)) {
-                if (sm.from != NULL_SQUARE) {
-                    storedLineMatches[line] = lineGame->GetCurrentPly() + 1;
-                    storedLineMoves[line] = sm;
-                }
-            } else {
-                if (b) { storedLineNeverMatches[line] = true; }
-            }
-        }
-        // Finished setting up stored line results.
-
-#ifndef WINCE
-        const byte * oldFilterData = base->filter->GetOldDataTree();
-#endif
-        // Search through each game:
-        for (uint i=0; i < base->numGames; i++) {
-            if (showProgress) {  // Update the percentage done slider:
-                update--;
-                if (update == 0) {
-                    update = updateStart;
-                    updateProgressBar (ti, i, base->numGames);
-                    if (interruptedProgress()) { break; }
-                }
-            }
+    if (!foundInCache) {
+    	// OK, not in the cache so do the search:
+    	// 2. Set vars
+    	Position* pos = db->game->GetCurrentPos();
+    	treeT* tree = &(base->tree);
+    	tree->moveCount = tree->totalCount = 0;
+    	matSigT msig = matsig_Make (pos->GetMaterial());
+    	uint hpSig = pos->GetHPSig();
+    	simpleMoveT sm;
+    	base->filter->Fill (0); // Reset the filter to be empty
+    	skipcount = 0;
+    	uint updateStart = 5000;  // Update progress bar every 5000 games
+    	uint update = 1;
+
+    	// 3. Set up the stored line code matches:
+    	uint numStoredLines = StoredLine::Count();
+    	byte storedLineMatches [MAX_STORED_LINES];
+    	simpleMoveT storedLineMoves [MAX_STORED_LINES];
+    	bool storedLineNeverMatches [MAX_STORED_LINES];
+    	pieceT * bd = pos->GetBoard();
+    	bool isStartPos =
+    			(bd[A1]==WR  &&  bd[B1]==WN  &&  bd[C1]==WB  &&  bd[D1]==WQ  &&
+    					bd[E1]==WK  &&  bd[F1]==WB  &&  bd[G1]==WN  &&  bd[H1]==WR  &&
+    					bd[A2]==WP  &&  bd[B2]==WP  &&  bd[C2]==WP  &&  bd[D2]==WP  &&
+    					bd[E2]==WP  &&  bd[F2]==WP  &&  bd[G2]==WP  &&  bd[H2]==WP  &&
+    					bd[A7]==BP  &&  bd[B7]==BP  &&  bd[C7]==BP  &&  bd[D7]==BP  &&
+    					bd[E7]==BP  &&  bd[F7]==BP  &&  bd[G7]==BP  &&  bd[H7]==BP  &&
+    					bd[A8]==BR  &&  bd[B8]==BN  &&  bd[C8]==BB  &&  bd[D8]==BQ  &&
+    					bd[E8]==BK  &&  bd[F8]==BB  &&  bd[G8]==BN  &&  bd[H8]==BR);
+
+    	for (uint line = 1; line <= numStoredLines; line++) {
+    		Game * lineGame = StoredLine::GetGame (line);
+    		lineGame->MoveToPly (0);
+    		storedLineMatches[line] = 0;
+    		storedLineNeverMatches[line] = false;
+    		bool b = false;
+    		if (lineGame->ExactMatch (pos, NULL, &sm, &b)) {
+    			if (sm.from != NULL_SQUARE) {
+    				storedLineMatches[line] = lineGame->GetCurrentPly() + 1;
+    				storedLineMoves[line] = sm;
+    			}
+    		} else {
+    			if (b) { storedLineNeverMatches[line] = true; }
+    		}
+    	}
+    	// Finished setting up stored line results.
+
+    	// 4. Search through each game:
+    	for (uint i=0; i < base->numGames; i++) {
+    		if (showProgress) {  // Update the percentage done slider:
+    			update--;
+    			if (update == 0) {
+    				update = updateStart;
+    				updateProgressBar (ti, i, base->numGames);
+    				if (interruptedProgress()) {
+    					Tcl_SetResult (ti, (char*) errMsgSearchInterrupted(ti), TCL_STATIC);
+    					return TCL_OK;
+    				}
+    				if (search_pool.count(&base) == 0) {
+    					Tcl_SetResult (ti, "canceled", TCL_STATIC);
+    					return TCL_OK;
+    				}
+    			}
+    		}
 
 #ifndef WINCE
-          // if the game is not already in the filter, continue
-          if ( fastMode && base->filter->isValidOldDataTree )
-            if ( oldFilterData[i] == 0)
-              continue;
-#endif
-
-            ie = base->idx->FetchEntry (i);
-            if (ie->GetLength() == 0) { skipcount++; continue; }
-            // We do not skip deleted games, so next line is commented out:
-            // if (ie->GetDeleteFlag()) { skipcount++; continue; }
-
-            bool foundMatch = false;
-            uint ply = 0;
-
-            // Check the stored line result for this game:
-            uint storedLine = ie->GetStoredLineCode();
-            if (storedLine > 0  && storedLine < numStoredLines) {
-                if (storedLineMatches[storedLine] != 0) {
-                    foundMatch = true;
-                    ply = storedLineMatches[storedLine];
-                    sm = storedLineMoves[storedLine];
-                } else if (storedLineNeverMatches[storedLine]) {
-                    skipcount++;
-                    continue;
-                }
-            }
-
-            if (!isStartPos  &&  ie->GetNumHalfMoves() == 0) {
-                skipcount++;
-                continue;
-            }
-
-            if (!foundMatch  &&  ! ie->GetStartFlag()) {
-                // Speedups that only apply to standard start games:
-                if (hpSig != HPSIG_StdStart) { // Not the start mask
-                    if (! hpSig_PossibleMatch(hpSig, ie->GetHomePawnData())) {
-                        skipcount++;
-                        continue;
-                    }
-                }
-            }
+    		const byte * oldFilterData = base->filter->GetOldDataTree();
+    		// if the game is not already in the filter, continue
+    		if ( fastMode && base->filter->isValidOldDataTree )
+    			if ( oldFilterData[i] == 0)
+    				continue;
+#endif
+
+    		IndexEntry* ie = base->idx->FetchEntry (i);
+    		if (ie->GetLength() == 0) { skipcount++; continue; }
+    		// We do not skip deleted games, so next line is commented out:
+    		// if (ie->GetDeleteFlag()) { skipcount++; continue; }
+
+    		bool foundMatch = false;
+    		uint ply = 0;
+
+    		// Check the stored line result for this game:
+    		uint storedLine = ie->GetStoredLineCode();
+    		if (storedLine > 0  && storedLine < numStoredLines) {
+    			if (storedLineMatches[storedLine] != 0) {
+    				foundMatch = true;
+    				ply = storedLineMatches[storedLine];
+    				sm = storedLineMoves[storedLine];
+    			} else if (storedLineNeverMatches[storedLine]) {
+    				skipcount++;
+    				continue;
+    			}
+    		}
 
-            if (!foundMatch  &&  msig != MATSIG_StdStart
-                    &&  !matsig_isReachable (msig, ie->GetFinalMatSig(),
-                                             ie->GetPromotionsFlag(),
-                                             ie->GetUnderPromoFlag()))
-            {
-                skipcount++;
-                continue;
-            }
+    		if (!isStartPos  &&  ie->GetNumHalfMoves() == 0) {
+    			skipcount++;
+    			continue;
+    		}
+
+    		if (!foundMatch  &&  ! ie->GetStartFlag()) {
+    			// Speedups that only apply to standard start games:
+    			if (hpSig != HPSIG_StdStart) { // Not the start mask
+    				if (! hpSig_PossibleMatch(hpSig, ie->GetHomePawnData())) {
+    					skipcount++;
+    					continue;
+    				}
+    			}
+    		}
 
-            if (! foundMatch) {
-                if (base->gfile->ReadGame (base->bbuf, ie->GetOffset(),
-                                         ie->GetLength()) != OK) {
-                    return errorResult (ti, "Error reading game file.");
-                }
-                if (g->ExactMatch (pos, base->bbuf, &sm)) {
-                    ply = g->GetCurrentPly() + 1;
-                    //if (ply > 255) { ply = 255; }
-                    foundMatch = true;
-                    //base->filter->Set (i, (byte) ply);
-                }
-            }
+    		if (!foundMatch  &&  msig != MATSIG_StdStart
+    				&&  !matsig_isReachable (msig, ie->GetFinalMatSig(),
+    						ie->GetPromotionsFlag(),
+    						ie->GetUnderPromoFlag()))
+    		{
+    			skipcount++;
+    			continue;
+    		}
+
+    		if (! foundMatch) {
+    			if (base->gfile->ReadGame (base->bbuf, ie->GetOffset(),
+    					ie->GetLength()) != OK) {
+    				search_pool.erase(&base);
+    				return errorResult (ti, "Error reading game file.");
+    			}
+    			Game *g = scratchGame;
+    			if (g->ExactMatch (pos, base->bbuf, &sm)) {
+    				ply = g->GetCurrentPly() + 1;
+    				//if (ply > 255) { ply = 255; }
+    				foundMatch = true;
+    				//base->filter->Set (i, (byte) ply);
+    			}
+    		}
 
-            // If match was found, add it to the list of found moves:
-            if (foundMatch) {
-                if (ply > 255) { ply = 255; }
-                base->filter->Set (i, (byte) ply);
-                uint search;
-                node = tree->node;
-                for (search = 0; search < tree->moveCount; search++, node++) {
-                    if (sm.from == node->sm.from
-                        &&  sm.to == node->sm.to
-                        &&  sm.promote == node->sm.promote) {
-                        break;
-                    }
-                }
+    		// If match was found, add it to the list of found moves:
+    		if (foundMatch) {
+    			if (ply > 255) { ply = 255; }
+    			base->filter->Set (i, (byte) ply);
+    			uint search;
+    			treeNodeT* node = tree->node;
+    			for (search = 0; search < tree->moveCount; search++, node++) {
+    				if (sm.from == node->sm.from
+    						&&  sm.to == node->sm.to
+    						&&  sm.promote == node->sm.promote) {
+    					break;
+    				}
+    			}
 
-                // Now node is the node to update or add.
-                // Check for exceeding max number of nodes:
-                if (search >= MAX_TREE_NODES) {
-                    return errorResult (ti, "Too many moves.");
-                }
+    			// Now node is the node to update or add.
+    			// Check for exceeding max number of nodes:
+    			if (search >= MAX_TREE_NODES) {
+    				search_pool.erase(&base);
+    				return errorResult (ti, "Too many moves.");
+    			}
 
-                if (search == tree->moveCount) {
-                    // A new move to add:
-                    initTreeNode (node);
-                    node->sm = sm;
-                    if (sm.from == NULL_SQUARE) {
-                        strCopy(node->san, "[end]");
-                    } else {
-                        pos->MakeSANString (&sm, node->san, SAN_CHECKTEST);
-                    }
-                    tree->moveCount++;
-                }
-                node->total++;
-                node->freq[ie->GetResult()]++;
-                eloT elo = 0;
-                eloT oppElo = 0;
-                uint year = ie->GetYear();
-                if (pos->GetToMove() == WHITE) {
-                    elo = ie->GetWhiteElo();
-                    oppElo = ie->GetBlackElo();
-                } else {
-                    elo = ie->GetBlackElo();
-                    oppElo = ie->GetWhiteElo();
-                }
-                if (elo > 0) {
-                    node->eloSum += elo;
-                    node->eloCount++;
-                }
-                if (oppElo > 0) {
-                    node->perfSum += oppElo;
-                    node->perfCount++;
-                }
-                if (year != 0) {
-                    node->yearSum += year;
-                    node->yearCount++;
-                }
-                tree->totalCount++;
-            } // end: if (foundMatch) ...
-        } // end: for
+    			if (search == tree->moveCount) {
+    				// A new move to add:
+    				initTreeNode (node);
+    				node->sm = sm;
+    				if (sm.from == NULL_SQUARE) {
+    					strCopy(node->san, "[end]");
+    				} else {
+    					pos->MakeSANString (&sm, node->san, SAN_CHECKTEST);
+    				}
+    				tree->moveCount++;
+    			}
+    			node->total++;
+    			node->freq[ie->GetResult()]++;
+    			eloT elo = 0;
+    			eloT oppElo = 0;
+    			uint year = ie->GetYear();
+    			if (pos->GetToMove() == WHITE) {
+    				elo = ie->GetWhiteElo();
+    				oppElo = ie->GetBlackElo();
+    			} else {
+    				elo = ie->GetBlackElo();
+    				oppElo = ie->GetWhiteElo();
+    			}
+    			if (elo > 0) {
+    				node->eloSum += elo;
+    				node->eloCount++;
+    			}
+    			if (oppElo > 0) {
+    				node->perfSum += oppElo;
+    				node->perfCount++;
+    			}
+    			if (year != 0) {
+    				node->yearSum += year;
+    				node->yearCount++;
+    			}
+    			tree->totalCount++;
+    		} // end: if (foundMatch) ...
+    	} // end: for
     }
 
     // Now we generate the score of each move: it is the expected score per
     // 1000 games. Also generate the ECO code of each move.
 
     DString dstr;
-    node = tree->node;
+    treeT* tree = &(base->tree);
+    treeNodeT* node = tree->node;
     for (uint i=0; i < tree->moveCount; i++, node++) {
-        node->score = (node->freq[RESULT_White] * 2
-                + node->freq[RESULT_Draw] + node->freq[RESULT_None])
-                * 500 / node->total;
-
-        node->ecoCode = 0;
-        if (ecoBook != NULL) {
-            scratchPos->CopyFrom (db->game->GetCurrentPos());
-            if (node->sm.from != NULL_SQUARE) {
-                scratchPos->DoSimpleMove (&(node->sm));
-            }
-            dstr.Clear();
-            if (ecoBook->FindOpcode (scratchPos, "eco", &dstr) == OK) {
-                node->ecoCode = eco_FromString (dstr.Data());
-            }
-        }
+    	node->score = (node->freq[RESULT_White] * 2
+    			+ node->freq[RESULT_Draw] + node->freq[RESULT_None])
+    			* 500 / node->total;
+
+    	node->ecoCode = 0;
+    	if (ecoBook != NULL) {
+    		scratchPos->CopyFrom (db->game->GetCurrentPos());
+    		if (node->sm.from != NULL_SQUARE) {
+    			scratchPos->DoSimpleMove (&(node->sm));
+    		}
+    		dstr.Clear();
+    		if (ecoBook->FindOpcode (scratchPos, "eco", &dstr) == OK) {
+    			node->ecoCode = eco_FromString (dstr.Data());
+    		}
+    	}
     }
 
     // Now we sort the move list:
-    sortTreeMoves (tree, sortMethod, pos->GetToMove());
+    sortTreeMoves (tree, sortMethod, db->game->GetCurrentPos()->GetToMove());
 
     // If it wasn't in the cache, maybe it belongs there:
     // But only add to the cache if not in fastmode
-    if (!foundInCache  &&  !interruptedProgress() && !fastMode) {
-        base->treeCache->Add (pos, tree, base->filter);
-        base->backupCache->Add (pos, tree, base->filter);
+    if (!foundInCache  && !fastMode) {
+    	base->treeCache->Add (db->game->GetCurrentPos(), tree, base->filter);
+    	base->backupCache->Add (db->game->GetCurrentPos(), tree, base->filter);
 #ifndef WINCE
-        base->filter->saveFilterForFastMode(db->game->GetCurrentPly());
+    	base->filter->saveFilterForFastMode(db->game->GetCurrentPly());
 #endif
     }
 
-    if (showProgress) { updateProgressBar (ti, 1, 1); }
+    if (showProgress) { updateProgressBar (ti, 1, 1, true); }
+    search_pool.erase(&base);
 
     DString * output = new DString;
     char temp [200];
@@ -13747,14 +13759,14 @@ sc_tree_search (ClientData cd, Tcl_Inter
         ecoStringT ecoStr;
         eco_ToExtendedString (node->ecoCode, ecoStr);
         uint avgElo = 0;
-        if (node->eloCount >= 10) {
+        if (node->eloCount >= 10) {bool foundInCache = false;
             avgElo = node->eloSum / node->eloCount;
         }
         uint perf = 0;
         if (node->perfCount >= 10) {
             perf = node->perfSum / node->perfCount;
             uint score = (node->score + 5) / 10;
-            if (pos->GetToMove() == BLACK) { score = 100 - score; }
+            if (db->game->GetCurrentPos()->GetToMove() == BLACK) { score = 100 - score; }
 #ifndef WINCE
             perf = Crosstable::Performance (perf, score);
 #endif
@@ -13877,7 +13889,7 @@ sc_tree_search (ClientData cd, Tcl_Inter
         if (perfCount >= 10) {
             perf = perfSum / perfCount;
             uint score = (totalScore + 5) / 10;
-            if (pos->GetToMove() == BLACK) { score = 100 - score; }
+            if (db->game->GetCurrentPos()->GetToMove() == BLACK) { score = 100 - score; }
 #ifndef WINCE
             perf = Crosstable::Performance (perf, score);
 #endif
@@ -13948,7 +13960,7 @@ sc_tree_search (ClientData cd, Tcl_Inter
 #endif
 
     if (! listMode) {
-        Tcl_AppendResult (ti, output->Data(), NULL);
+    	Tcl_AppendResult (ti, output->Data(), NULL);
     }
     delete output;
     base->treeSearchTime = timer.MilliSecs();
Index: tcl/main.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/main.tcl,v
retrieving revision 1.46
diff -u -p -r1.46 main.tcl
--- tcl/main.tcl	28 Feb 2010 13:48:18 -0000	1.46
+++ tcl/main.tcl	19 Apr 2010 14:50:03 -0000
@@ -904,6 +904,8 @@ proc updateBoard {args} {
     updateMenuStates
     moveEntry_Clear
     updateStatusBar
+
+    update idletasks
     
     if {[winfo exists .twinchecker]} { updateTwinChecker }
     if {[winfo exists .pgnWin]} { ::pgn::Refresh $pgnNeedsUpdate }
Index: tcl/move.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/move.tcl,v
retrieving revision 1.7
diff -u -p -r1.7 move.tcl
--- tcl/move.tcl	18 Jan 2010 16:27:13 -0000	1.7
+++ tcl/move.tcl	19 Apr 2010 14:50:03 -0000
@@ -63,8 +63,6 @@ proc ::move::showVarArrows {} {
 }
 
 proc ::move::Start {} {
-  if {$::tree(refresh)} { return }
-  
   if {[winfo exists .coachWin]} {
     set ::tacgame::analysisCoach(paused) 1
     .coachWin.fbuttons.resume configure -state normal
@@ -76,7 +74,6 @@ proc ::move::Start {} {
 }
 
 proc ::move::End {} { 
-  if {$::tree(refresh)} { return }
   sc_move end
   updateBoard
   if {[::move::drawVarArrows]} { ::move::showVarArrows }
@@ -89,7 +86,7 @@ proc ::move::ExitVar {} {
 }
 
 proc ::move::Back {{count 1}} {
-  if {$::tree(refresh)} { return }
+  if {[sc_pos isAt start]} { return } 
   if {[sc_pos isAt vstart]} { ::move::ExitVar; return }
   
   ### todo: if playing, remove this move from hash array S.A ??
@@ -118,8 +115,6 @@ proc ::move::Back {{count 1}} {
 proc ::move::Forward {{count 1}} {
   global autoplayMode
   
-  if {$::tree(refresh)} { return }
-  
   if {[sc_pos isAt end]  ||  [sc_pos isAt vend]} { return }
   
   set bArrows [::move::drawVarArrows]
Index: tcl/windows/tree.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/windows/tree.tcl,v
retrieving revision 1.56
diff -u -p -r1.56 tree.tcl
--- tcl/windows/tree.tcl	13 Apr 2010 19:23:13 -0000	1.56
+++ tcl/windows/tree.tcl	19 Apr 2010 14:50:06 -0000
@@ -427,11 +427,12 @@ proc ::tree::select { move baseNumber } 
 set tree(refresh) 0
 
 ################################################################################
-proc ::tree::refresh { { baseNumber "" }} {
-  
+proc ::tree::refresh { { baseNumber "" }} {  
   set stack [lsearch -glob -inline -all [ wm stackorder . ] ".treeWin*"]
   
   if {$baseNumber == "" } {
+    sc_tree search -cancel all    
+    
     set topwindow [lindex [lsearch -glob -inline -all [ wm stackorder . ] ".treeWin*"] end ]
     set topbase -1
     if { [ catch { scan $topwindow ".treeWin%d" topbase } ] } {
@@ -440,7 +441,7 @@ proc ::tree::refresh { { baseNumber "" }
     }
     for {set i 1 } {$i <= [sc_base count total]} {incr i} {
       if { $i == $topbase } { continue }
-      ::tree::dorefresh $i
+      if { [::tree::dorefresh $i] == "canceled" } { break }
     }
   } else {
     ::tree::dorefresh $baseNumber
@@ -465,8 +466,6 @@ proc ::tree::dorefresh { baseNumber } {
   $w.buttons.stop configure -state normal
   set tree(refresh) 1
   
-  update
-  
   set base $baseNumber
   
   if { $tree(fastmode$baseNumber) == 0 } {
@@ -476,19 +475,6 @@ proc ::tree::dorefresh { baseNumber } {
   }
   
   set moves [sc_tree search -hide $tree(training$baseNumber) -sort $tree(order$baseNumber) -base $base -fastmode $fastmode]
-  displayLines $baseNumber $moves
-  
-  if {[winfo exists .treeBest$baseNumber]} { ::tree::best $baseNumber}
-  
-  # ========================================
-  if { $tree(fastmode$baseNumber) == 2 } {
-    ::tree::status "" $baseNumber
-    sc_progressBar $w.progress bar 251 16
-    set moves [sc_tree search -hide $tree(training$baseNumber) -sort $tree(order$baseNumber) -base $base -fastmode 0]
-    displayLines $baseNumber $moves
-  }
-  # ========================================
-  
   catch {$w.f.tl itemconfigure 0 -foreground darkBlue}
   
   foreach button {best graph training lock close} {
@@ -508,6 +494,19 @@ proc ::tree::dorefresh { baseNumber } {
   ::windows::gamelist::Refresh
   updateTitle
   
+  if { $moves == "canceled" } { return "canceled"}
+  displayLines $baseNumber $moves  
+  if {[winfo exists .treeBest$baseNumber]} { ::tree::best $baseNumber}
+  
+  # ========================================
+  if { $tree(fastmode$baseNumber) == 2 } {
+    ::tree::status "" $baseNumber
+    sc_progressBar $w.progress bar 251 16
+    set moves [sc_tree search -hide $tree(training$baseNumber) -sort $tree(order$baseNumber) -base $base -fastmode 0]
+    displayLines $baseNumber $moves
+  }
+  # ========================================
+  
   # if the Tree base is not the current one, updates the Tree base to the first game in filter : that way it is possible to
   # directly generate an opening report for example
   if {$baseNumber != [sc_base current] } {
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Scid-users mailing list
Scid-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scid-users

Reply via email to