[Kst] kdeextragear-2/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Fri Jul 9 18:07:24 CEST 2004


CVS commit by netterfield: 

Real time updating was not working, because the paint events were not actually being
processed before giving the 'all clear' to the ui thread.  This fixes that, and
improves on the clarity of the comments in the update thread.


  M +9 -9      kst.cpp   1.180
  M +2 -1      kstdoc.cpp   1.97
  M +10 -10    updatethread.cpp   1.22


--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.96:1.97
@@ -797,5 +797,6 @@ bool KstDoc::event(QEvent *e) {
     } else if (te->_eventType == ThreadEvent::Done) {
     }
-    _updating = false; // ok, we're done...
+    kapp->processEvents(); // actually do the paints and check for inputs
+    _updating = false; // ok, we're done... update thread can send us a new event.
 
     return true;

--- kdeextragear-2/kst/kst/updatethread.cpp  #1.21:1.22
@@ -85,16 +85,17 @@ void UpdateThread::run() {
       // which would block UI thread by filling it with un-processable requests.
       bool do_wait = false;
-      // FIXME: race condition, updating() is not synchronized
-      // GrUMPY Barth says there's nothing to fix...
-      while (_doc->updating()) {
+      // Race warning: Syncronization of updating() is not assured, but updating() will always
+      // return a valid answer which was true 'close' to when we asked.  This will safely keep
+      // the update thread from over filling the UI thread.
+      while (_doc->updating()) {  // wait for the UI to finish old events
         do_wait = true;
-        usleep(1000);
+        usleep(1000); // 1 ms on 2.6 kernel.  NOTE: on 2.4 kernel, the minimum usleep is 10ms,
+                      // So this will run more coarsly on 2.4.  Should be OK though.
       }
-      if (do_wait) {
+      if (do_wait) { // one extra usleep in case something was pending.
         usleep(1000);
       }
-      // FIXME: race condition, updating() is not synchronized
-      // GrUMPY Barth says there's nothing to fix...
-      while (_doc->updating()) { // check again...
+      while (_doc->updating()) { // check again... not strictly needed given implicit repaint below,
+                                 // but it should just return false, so no harm done.
         usleep(1000);
       }
@@ -102,5 +103,5 @@ void UpdateThread::run() {
       if (gotData) {
         QApplication::postEvent(_doc, new ThreadEvent(ThreadEvent::UpdateDataDialogs));
-        // implicit repaint
+        // this event also triggers an implicit repaint
       } else {
         QApplication::postEvent(_doc, new ThreadEvent(ThreadEvent::Repaint));





More information about the Kst mailing list