[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Dec 8 07:18:14 CET 2004


CVS commit by staikos: 

remove unnecessary updates, especially in the GUI thread.  Fixes issue in 1.0
where dialogs would freeze after OK for a short period.

Should I backport this to 1.0.1?


  M +0 -1      kst.cpp   1.264
  M +40 -22    kstdoc.cpp   1.141
  M +1 -0      kstdoc.h   1.38
  M +1 -1      threadevents.h   1.5
  M +3 -1      updatethread.cpp   1.35


--- kdeextragear-2/kst/kst/kst.cpp  #1.263:1.264
@@ -766,5 +766,4 @@ void KstApp::initDocument() {
 void KstApp::forceUpdate() {
   _updateThread->forceUpdate();
-  QTimer::singleShot(0, doc, SIGNAL(updateDialogs()));
 }
 

--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.140:1.141
@@ -60,4 +60,5 @@ KstDoc::KstDoc(QWidget *parent, const ch
   _stopping = false;
   _updateDelay = 5;
+  _nextEventPaint = false;
 }
 
@@ -450,4 +451,6 @@ bool KstDoc::openDocument(const KURL& ur
   kapp->dcopClient()->setAcceptCalls(true);
 
+  _nextEventPaint = true;
+
   emit updateDialogs();
 
@@ -735,5 +738,4 @@ void KstDoc::wasModified() {
   _modified = true;
   forceUpdate();
-  KstApp::inst()->paintAll();
 }
 
@@ -799,4 +801,5 @@ void KstDoc::purge() {
 
 void KstDoc::forceUpdate() {
+  _nextEventPaint = false;
   static_cast<KstApp*>(parent())->forceUpdate();
 }
@@ -813,12 +816,16 @@ bool KstDoc::event(QEvent *e) {
 
     ThreadEvent *te = static_cast<ThreadEvent*>(e);
-    if (te->_eventType == ThreadEvent::UpdateDataDialogs) {
+    switch (te->_eventType) {
+      case ThreadEvent::UpdateDataDialogs:
       //kdDebug() << "Update data dialogs" << endl;
       emit dataChanged();
       KstApp::inst()->paintAll();
-    } else if (te->_eventType == ThreadEvent::UpdateAllDialogs) {
+        break;
+      case ThreadEvent::UpdateAllDialogs:
       //kdDebug() << "Update ALL dialogs" << endl;
 
-      if (KstApp::inst()) {
+        if (KstApp::inst()) { // If KstApp::inst() is null, we have big
+                              // problems since this is a QObject child of
+                              // KstApp
         KMdiIterator<KMdiChildView*>* it = KstApp::inst()->createIterator();
         if (it) {
@@ -835,9 +842,20 @@ bool KstDoc::event(QEvent *e) {
 
       emit updateDialogs();
-    } else if (te->_eventType == ThreadEvent::Repaint) {
+        break;
+      case ThreadEvent::Done:
+        break;
+      case ThreadEvent::Repaint:
+        KstApp::inst()->paintAll();
+        break;
+      case ThreadEvent::NoUpdate:
+        if (_nextEventPaint) {
       KstApp::inst()->paintAll();
-    } else if (te->_eventType == ThreadEvent::Done) {
+        }
+        break;
+      default:
+        break;
     }
 
+    _nextEventPaint = false;
     QTimer::singleShot(0, this, SLOT(enableUpdates()));
 

--- kdeextragear-2/kst/kst/kstdoc.h  #1.37:1.38
@@ -108,4 +108,5 @@ private:
   int _lock;
   bool _updating;
+  bool _nextEventPaint;
 
 signals:

--- kdeextragear-2/kst/kst/threadevents.h  #1.4:1.5
@@ -23,5 +23,5 @@
 class ThreadEvent : public QEvent {
   public:
-    enum ThreadEventType { Unknown = 0, UpdateDataDialogs, UpdateAllDialogs, Repaint, Done };
+    enum ThreadEventType { Unknown = 0, UpdateDataDialogs, UpdateAllDialogs, Repaint, Done, NoUpdate };
 
     ThreadEvent(ThreadEventType et) : QEvent(QEvent::Type(KstEventTypeThread)), _eventType(et) {}

--- kdeextragear-2/kst/kst/updatethread.cpp  #1.34:1.35
@@ -110,4 +110,6 @@ void UpdateThread::run() {
         usleep(1000);
       }
+    } else {
+      QApplication::postEvent(_doc, new ThreadEvent(ThreadEvent::NoUpdate));
     }
   }





More information about the Kst mailing list