Bug 96764 - kst with multiple tabs is slow
Summary: kst with multiple tabs is slow
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: view objects (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: George Staikos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-11 06:06 UTC by Matthew Truch
Modified: 2005-01-11 09:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2005-01-11 06:06:03 UTC
Version:           1.1.0_dr1 (using KDE KDE 3.3.2)
OS:                Linux

If I create a window with multiple tabs, kst will be as slow as if each tab was opened in its own kst instance.  kst should instead do the minimum work required to display the info only in the visible tab(s).  All hidden tabs (or windows or whatever) should do no more than possibly keeping the vectors up to date with live data (if applicable).   They should definatly not do things like calculate hidden PSDs or other CPU intensive tasks.  

This is most prevalent when we are plotting BLAST detectors.  Imagine 8 (or more) tabs, each has either 24 curves on 24 plots at 100Hz for 500 points, or 24 curves on 3 plots on the left column with corresponding psds on the right.
Comment 1 George Staikos 2005-01-11 08:49:31 UTC
I have bits of this implemented, but it's tricky to get right.  It will take some time.
Comment 2 George Staikos 2005-01-11 09:29:15 UTC
CVS commit by staikos: 

This is a bit of a fix for updating of hidden tabs.  It avoids painting or
drawing tabs that aren't visible.  It may be buggy so feedback is appreciated.
This stuff is very complex.  Updating of data objects that are "hidden" still
happens since we don't really know what is or is not hidden in the update
thread.  It also requires much more complex dependency walking than we are even
capable of doing right now.  I am going to close the bug as fixed and leave the
rest as "LATER" to be part of update redesign.  Reopen if tabs are still being
painted when they shouldn't be, or if this fix breaks things.
BUG: 96764


  M +34 -13    kst.cpp   1.275
  M +10 -4     kstviewwidget.cpp   1.64
  M +3 -1      kstviewwidget.h   1.21


--- kdeextragear-2/kst/kst/kst.cpp  #1.274:1.275
@@ -1406,10 +1406,13 @@ void KstApp::paintAll(KstPaintType pt) {
   t.start();
 #endif
+  if (mdiMode() == KMdi::TabPageMode) {
+    KstViewWindow *view = dynamic_cast<KstViewWindow*>(activeWindow());
+    if (pt == P_DATA) { // what about P_PLOT?  I think it's not needed anyway
   KMdiIterator<KMdiChildView*> *it = createIterator();
   if (it) {
     while (it->currentItem()) {
-      KstViewWindow *pView = dynamic_cast<KstViewWindow*>(it->currentItem());
-      if (pView) {
-        pView->view()->paint(pt);
+          KstViewWindow *v = dynamic_cast<KstViewWindow*>(it->currentItem());
+          if (v && v != view) {
+            v->view()->widget()->nextUpdateDo(pt);
       }
       it->next();
@@ -1417,4 +1420,22 @@ void KstApp::paintAll(KstPaintType pt) {
     deleteIterator(it);
   }
+    }
+
+    if (view) {
+      view->view()->paint(pt);
+    }
+  } else {
+    KMdiIterator<KMdiChildView*> *it = createIterator();
+    if (it) {
+      while (it->currentItem()) {
+        KstViewWindow *view = dynamic_cast<KstViewWindow*>(it->currentItem());
+        if (view) {
+          view->view()->paint(pt);
+        }
+        it->next();
+      }
+      deleteIterator(it);
+    }
+  }
 #ifdef PAINTTIMER
   int x = t.elapsed();
@@ -1424,8 +1445,8 @@ void KstApp::paintAll(KstPaintType pt) {
 
 void KstApp::showPlotDialog() {
-  KMdiChildView *pWindow = activeWindow();
+  KMdiChildView *win = activeWindow();
 
-  if (_plotDialog->isHidden() && pWindow) {
-    _plotDialog->show_I(pWindow->caption(), QString::null);
+  if (win && _plotDialog->isHidden()) {
+    _plotDialog->show_I(win->caption(), QString::null);
   } else {
     _plotDialog->show_I();
@@ -1433,6 +1454,6 @@ void KstApp::showPlotDialog() {
 }
 
-void KstApp::showPlotDialog(const QString& strWindow, const QString& strPlot) {
-  _plotDialog->show_I(strWindow, strPlot);
+void KstApp::showPlotDialog(const QString& window, const QString& plot) {
+  _plotDialog->show_I(window, plot);
 }
 

--- kdeextragear-2/kst/kst/kstviewwidget.cpp  #1.63:1.64
@@ -28,4 +27,5 @@
 KstViewWidget::KstViewWidget(KstTopLevelViewPtr view, QWidget *parent, const char *name, WFlags w)
 : QWidget(parent, name, WStyle_Customize | w), _view(view), _menu(0L) {
+  _nextUpdate = P_PAINT;
   setDragEnabled(true);
   setDropEnabled(true);
@@ -282,5 +282,6 @@ void KstViewWidget::paintEvent(QPaintEve
 #endif
   if (e) {  // Resize/expose/etc triggered by X11
-    _view->paint(P_PAINT);
+    _view->paint(_nextUpdate);
+    _nextUpdate = P_PAINT;
 #ifdef BENCHMARK
     int x = t.elapsed();
@@ -440,4 +441,9 @@ KstTopLevelViewPtr KstViewWidget::viewOb
 }
 
+
+void KstViewWidget::nextUpdateDo(KstPaintType updateType) {
+  _nextUpdate = updateType;
+}
+
 #include "kstviewwidget.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstviewwidget.h  #1.20:1.21
@@ -39,4 +39,5 @@ class KstViewWidget : public QWidget {
     void paint();
 
+    void nextUpdateDo(KstPaintType updateType);
 
     KstViewObjectPtr findChildFor(const QPoint& pos);
@@ -64,9 +65,10 @@ class KstViewWidget : public QWidget {
   private:
     KstTopLevelViewPtr _view;
-    KstViewObject*     _vo_datamode;
+    KstViewObject *_vo_datamode;
     bool _dropEnabled : 1;
     bool _dragEnabled : 1;
     KPopupMenu *_menu;
     QDragObject *_drag;
+    KstPaintType _nextUpdate;
 };