Sometimes i move very fast in a game with the mouse wheel or keeping pressed 
the left arrow on the keyboard.
Scid can be very slow if i have the pgn window opened or a tree window opened 
or a chess engine running.
In that cases many updateBoard calls were queued.
The idea of this patch is to process all user input before calling refresh in 
the other windows.
Please try this and share your opinions.
Bye,
Fulvio
Index: tcl/main.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/main.tcl,v
retrieving revision 1.56
diff -u -r1.56 main.tcl
--- tcl/main.tcl	9 Jan 2011 10:29:47 -0000	1.56
+++ tcl/main.tcl	13 Feb 2011 10:19:43 -0000
@@ -832,19 +832,31 @@
 #    If a parameter "-animate" is specified, board changes are animated.
 #
 proc updateBoard {args} {
-    global boardSize gameInfo
+    global boardSize
     set pgnNeedsUpdate 0
     set animate 0
     foreach arg $args {
         if {! [string compare $arg "-pgn"]} { set pgnNeedsUpdate 1 }
         if {! [string compare $arg "-animate"]} { set animate 1 }
     }
-   
+
+    if {$pgnNeedsUpdate} { ::pgn::Refresh $pgnNeedsUpdate }
+
     ::board::resize .main.board $boardSize
     ::board::setmarks .main.board [sc_pos getComment]
     ::board::update .main.board [sc_pos board] $animate
-    
-    # Update the status of each navigation button:
+
+    after cancel updateNavButtons
+    after cancel refreshWindows
+
+    update idletasks
+
+    after idle updateNavButtons
+    after idle refreshWindows
+}
+
+# Update the status of each navigation button:
+proc updateNavButtons {} {
     if {[sc_pos isAt start]} {
         .main.fbutton.button.start configure -state disabled
     } else { .main.fbutton.button.start configure -state normal }
@@ -884,7 +896,23 @@
     } else {
         .main.fbutton.button.exitVar configure -state normal
     }
-    
+
+    wm withdraw .tooltip
+    set comment [sc_pos getComment]
+    # remove technical comments, notify only human readable ones
+    regsub -all {\[%.*\]} $comment {} comment
+    if {$comment != ""} {
+         .main.fbutton.button.comment configure -image comment_avail -relief flat
+         ::utils::tooltip::Set .main.fbutton.button.comment $comment
+    } else {
+         .main.fbutton.button.comment configure -image comment_unavail -relief flat
+         ::utils::tooltip::UnSet .main.fbutton.button.comment
+    }
+}
+
+proc refreshWindows {} {
+    global gameInfo
+
     if {![sc_base inUse]  ||  $::trialMode  ||  [sc_base isReadOnly]} {
         .main.tb.save configure -state disabled
     } else {
@@ -903,38 +931,28 @@
     } else {
         .main.gameInfo configure -wrap none
     }
+
     .main.gameInfo configure -state disabled
+
+#TODO
+#Each function should be safe and check the appropriate "winfo exists" at the start
+#Change the order of refreshs: for example ::pgn::Refresh should be done before UpdatePlayerPhotos 
+ 
     updatePlayerPhotos
     updateEpdWins
     if {[winfo exists .analysisWin1]} { updateAnalysis 1 }
     if {[winfo exists .analysisWin2]} { updateAnalysis 2 }
-    # if {[winfo exists .treeWin]} { ::tree::refresh }
     ::tree::refresh
-    if {[winfo exists .commentWin]} { ::commenteditor::Refresh }
+    ::commenteditor::Refresh
     if {[::tb::isopen]} { ::tb::results }
     updateMenuStates
     moveEntry_Clear
-    updateStatusBar
-
-    update idletasks
-    
+    updateStatusBar    
     if {[winfo exists .twinchecker]} { updateTwinChecker }
-    if {[winfo exists .pgnWin]} { ::pgn::Refresh $pgnNeedsUpdate }
+    ::pgn::Refresh
     if {[winfo exists .bookWin]} { ::book::refresh }
     if {[winfo exists .bookTuningWin]} { ::book::refreshTuning }
-    if {[winfo exists .noveltyWin]} { updateNoveltyWin }
-
-	 wm withdraw .tooltip
-    set comment [sc_pos getComment]
-    # remove technical comments, notify only human readable ones
-    regsub -all {\[%.*\]} $comment {} comment
-    if {$comment != ""} {
-         .main.fbutton.button.comment configure -image comment_avail -relief flat
-         ::utils::tooltip::Set .main.fbutton.button.comment $comment
-    } else {
-         .main.fbutton.button.comment configure -image comment_unavail -relief flat
-         ::utils::tooltip::UnSet .main.fbutton.button.comment
-    }
+    if {[winfo exists .noveltyWin]} { updateNoveltyWin }	
 }
 
 # Set up player photos:
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Scid-users mailing list
Scid-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scid-users

Reply via email to