Bug 114788 - Problem when resizing window with label
Summary: Problem when resizing window with label
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: George Staikos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-21 00:35 UTC by Andrew Walker
Modified: 2005-10-22 07:25 UTC (History)
1 user (show)

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 Andrew Walker 2005-10-21 00:35:20 UTC
Version:           HEAD (using KDE KDE 3.4.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
When a window is resized a shadow of any text label is left.

STEPS TO REPRODUCE:
* Create a window with some number of plots
* Create a label with some text of reasonable text (eg 10 characters)
* Maximize Kst
* Restore Kst and reduce to a small fraction of the display size but still big enough to see the text
* Maximize and restore Kst

RESULTS:
Artifacts of the text label are clearly visible

EXPECTED RESULTS:
No artifcats should be visible
Comment 1 George Staikos 2005-10-21 07:09:42 UTC
Confirmed
Comment 2 George Staikos 2005-10-22 07:02:08 UTC
At least one problem is that the geometry of the labels is not updated yet 
(they're auto-adjusted), so the mask for the toplevel view is wrong.  Maybe 
it should paint last.  I will test this.
Comment 3 George Staikos 2005-10-22 07:25:20 UTC
SVN commit 472825 by staikos:

paint objects top->down instead of bottom->up to make sure we don't get inproper
geometries or artifacts.  As a side effect, painting goes from O(n^2) to O(n)
which is nice.
BUG: 114788


 M  +4 -2      ksttoplevelview.cpp  
 M  +8 -10     kstviewobject.cpp  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #472824:472825
@@ -180,10 +180,13 @@
 
 
 void KstTopLevelView::paint(KstPaintType type, const QRegion& bounds) {
-  QRegion boundary = bounds;
   QPainter p;
   p.begin(_w);
   p.setViewXForm(true);
+  // Paint everything else first so that geometries are properly updated.
+  paint(type, p, bounds);
+
+  QRegion boundary = bounds;
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
     boundary -= (*i)->clipRegion();
   }
@@ -191,7 +194,6 @@
     p.setClipRegion(boundary);
     p.fillRect(geometry(), QBrush(_backgroundColor));
     p.setClipping(false);
-    paint(type, p, bounds);
   }
   p.end();
   
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #472824:472825
@@ -309,29 +309,27 @@
     }
   }
 
-  if (!maximized) {
-    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+  if (!maximized && !_children.isEmpty()) {
+    QRegion clipRegion = oldRegion;
+    KstViewObjectList::Iterator begin = _children.begin();
+    for (KstViewObjectList::Iterator i = _children.fromLast();; --i) {
       if (nullBounds || !bounds.intersect(QRegion((*i)->geometry())).isEmpty()) {
 #ifdef BENCHMARK
         QTime t;
         t.start();
 #endif
-        QRegion clipRegion = oldRegion;
-        KstViewObjectList::Iterator j = i;
-        for (++j; j != _children.end(); ++j) {
-          clipRegion -= (*j)->clipRegion();
-        }
         (*i)->_lastClipRegion = clipRegion;
         p.setClipRegion(clipRegion);
         (*i)->paint(type, p, bounds);
+        clipRegion -= (*i)->clipRegion();
 #ifdef BENCHMARK
         int x = t.elapsed();
         kstdDebug() << "   -> object " << (*i)->tagName() << " took " << x << "ms" << endl;
 #endif
-        if ((*i)->_maximized) {
-          break;
-        }
       }
+      if (i == begin) {
+        break;
+      }
     }
   }