Bug 131693

Summary: Crash when resizing plot with legend
Product: [Applications] kst Reporter: Andrew Walker <arwalker>
Component: generalAssignee: kst
Status: RESOLVED WORKSFORME    
Severity: crash    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Andrew Walker 2006-08-02 00:04:23 UTC
Version:           HEAD (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
When resizing a plot with a contained legend Kst may crash

STEPS TO REPRODUCE:
Start Kst
Create a plot and show the legend
Switch to layout mode
Resize the plot from one of the central resize points either horizontally or vertically
Shrink the plot down to its smallest possible size

RESULTS:
Crash

QPainter::begin: Cannot paint null pixmap
QPainter::setPen: Will be reset by begin()
QPainter::setFont: Will be reset by begin()
QPainter::setWorldMatrix: Will be reset by begin()
QPainter::setPen: Will be reset by begin()
KCrash: Application 'kst' crashing...

EXPECTED RESULTS:
No crash
Comment 1 Andrew Walker 2006-08-02 00:18:51 UTC
SVN commit 568678 by arwalker:

BUG:131693 Don't try to paint to an empty bitmap as it causes a crash.

 M  +10 -8     kstviewlegend.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #568677:568678
@@ -219,14 +219,16 @@
   setDirty(false);
 
   _backBuffer.buffer().resize(contentsRect().size());
-  _backBuffer.buffer().fill(backgroundColor());
-  KstPainter p;
-  p.begin(&_backBuffer.buffer());
-  QPen pen;
-  pen.setColor(foregroundColor());
-  p.setPen(pen);
-  drawToPainter(p);
-  p.end();
+  if (!contentsRect().size().isEmpty()) {
+    _backBuffer.buffer().fill(backgroundColor());
+    KstPainter p;
+    p.begin(&_backBuffer.buffer());
+    QPen pen;
+    pen.setColor(foregroundColor());
+    p.setPen(pen);
+    drawToPainter(p);
+    p.end();
+  }
 }
 
 
Comment 2 Andrew Walker 2006-08-02 01:04:38 UTC
Fix was reverted
Comment 3 Adam Treat 2006-10-17 00:06:08 UTC
Can't reproduce with trunk.