Bug 102221 - Crash when resizing plot group
Summary: Crash when resizing plot group
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-23 00:32 UTC by Andrew Walker
Modified: 2005-03-23 04:40 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 Andrew Walker 2005-03-23 00:32:31 UTC
Version:           HEAD (using KDE KDE 3.3.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
Kst crashes when resizing a plot group

STEPS TO REPRODUCE:
Start Kst
Create eight plots within a single window
Edit one of the plots and re-grid to 10
Enter layout mode and create a single group from all the individual plots
Resize the group object to near-zero horizontal width

RESULTS:
Crash

EXPECTED RESULTS:
Resize is permitted

Stack trace:
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -174471488 (LWP 7687)]
[New Thread -178676816 (LWP 7688)]
[Thread debugging using libthread_db enabled]
[New Thread -174471488 (LWP 7687)]
[New Thread -178676816 (LWP 7688)]
[Thread debugging using libthread_db enabled]
[New Thread -174471488 (LWP 7687)]
[New Thread -178676816 (LWP 7688)]
[KCrash handler]
#4  0xf6fe97a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#5  0xf5b0e955 in raise () from /lib/tls/libc.so.6
#6  0xf5b10319 in abort () from /lib/tls/libc.so.6
#7  0xf5b07f41 in __assert_fail () from /lib/tls/libc.so.6
#8  0x080aeaf9 in Kst2DPlot::draw (this=0xa52f488) at qpixmap.h:271
#9  0x080aeb6f in Kst2DPlot::paint (this=0xa52f488, type=P_PAINT, 
    p=@0xfef212a0) at kst2dplot.cpp:2113
#10 0x080c13dc in KstViewObject::paint (this=0xa532460, type=P_PAINT, 
    p=@0xfef212a0) at kstsharedptr.h:110
#11 0x080c7b99 in KstBorderedViewObject::paint (this=0xa532460, type=P_PAINT, 
    p=@0xfef212a0) at kstborderedviewobject.cpp:80
#12 0x080c6629 in KstPlotGroup::paint (this=0xa532460, type=P_PAINT, 
    p=@0xfef212a0) at kstplotgroup.cpp:166
#13 0x080c13dc in KstViewObject::paint (this=0xa4e1a48, type=P_PAINT, 
    p=@0xfef212a0) at kstsharedptr.h:110
#14 0x080cc551 in KstTopLevelView::paint (this=0xa4e1a48, type=P_PAINT, 
    p=@0xfef212a0) at ksttoplevelview.cpp:101
#15 0x080ca40a in KstTopLevelView::paint (this=0xa4e1a48, type=P_PAINT)
    at ksttoplevelview.cpp:144
#16 0x080cbbf2 in KstTopLevelView::releasePress (this=0xa4e1a48, 
    pos=@0xfef21bfc, shift=252) at ksttoplevelview.cpp:645
#17 0x080bac89 in KstViewWidget::mouseReleaseEvent (this=0xa45ba10, 
    e=0xfef21bf0) at kstsharedptr.h:132
#18 0xf60f1cfa in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#19 0xf605d249 in QApplication::internalNotify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#20 0xf605d489 in QApplication::notify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#21 0xf66a54c8 in KApplication::notify () from /usr/lib/libkdecore.so.4
#22 0xf5ffc3de in QETWidget::translateMouseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#23 0xf5ffac78 in QApplication::x11ProcessEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#24 0xf600d086 in QEventLoop::processEvents ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#25 0xf6072875 in QEventLoop::enterLoop ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#26 0xf60727ce in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#27 0xf605c44b in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#28 0x0814e13a in main (argc=1, argv=0xfef22bf4) at main.cpp:740
Comment 1 George Staikos 2005-03-23 04:40:54 UTC
CVS commit by staikos: 

How to fix 102221 properly, but not really fully or properly done.  There's lots
of tweaking to be done, especially on the UI side.  We should stop the resize
at minimumSize(), for instance.  There are also some interesting hacks in there.
BUG: 102221


  M +21 -3     kstviewobject.cpp   1.125
  M +5 -1      kstviewobject.h   1.96


--- kdeextragear-2/kst/kst/kstviewobject.cpp  #1.124:1.125
@@ -51,4 +51,5 @@ KstViewObject::KstViewObject(const QStri
   _foregroundColor = KstSettings::globalSettings()->foregroundColor;
   _backgroundColor = KstSettings::globalSettings()->backgroundColor;
+  setMinimumSize(QSize(1, 1));
 }
 
@@ -58,4 +59,5 @@ KstViewObject::KstViewObject(const QDomE
   _backgroundColor = KstSettings::globalSettings()->backgroundColor;
   _parent = 0L;
+  setMinimumSize(QSize(1, 1));
   load(e);
 }
@@ -75,4 +77,5 @@ KstViewObject::KstViewObject(const KstVi
   _selected = false;
   _geom = viewObject._geom;
+  setMinimumSize(QSize(1, 1));
 
   setContentsRect(viewObject.contentsRect());
@@ -364,7 +367,6 @@ KstViewObjectList& KstViewObject::childr
 
 void KstViewObject::resize(const QSize& size) {
-  assert(size.width() > 0);
-  assert(size.height() > 0);
-  _geom.setSize(size);
+  setMinimumSize(minimumSize().expandedTo(QSize(_children.count(), _children.count())));
+  _geom.setSize(size.expandedTo(_minimumSize));
   updateAspect();
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
@@ -981,4 +985,5 @@ void KstViewObject::copyTo(int id) {
 void KstViewObject::updateFromAspect() {
   // FIXME: eliminate _parent!!
+  setMinimumSize(minimumSize().expandedTo(QSize(_children.count(), _children.count())));
   if (_parent) {
     _geom.setLeft(_parent->geometry().left() + int(_aspect.x * _parent->geometry().width()));
@@ -987,4 +992,7 @@ void KstViewObject::updateFromAspect() {
     _geom.setBottom(_parent->geometry().top() + int((_aspect.y + _aspect.h) * _parent->geometry().height()) - 1);
   }
+  if (_geom.width() >= _minimumSize.width() || _geom.height() >= _minimumSize.height()) {
+    _geom.setSize(_geom.size().expandedTo(_minimumSize));
+  }
   assert(_geom.left() >= 0 && _geom.top() >= 0);
 }
@@ -1275,4 +1283,14 @@ const QString& KstViewObject::type() con
 }
 
+
+void KstViewObject::setMinimumSize(const QSize& sz) {
+  _minimumSize = sz.expandedTo(QSize(3, 3)); // 3,3 is the absolute minimum
+}
+
+
+const QSize& KstViewObject::minimumSize() const {
+  return _minimumSize;
+}
+
 #include "kstviewobject.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstviewobject.h  #1.95:1.96
@@ -181,4 +181,7 @@ class KstViewObject : public KstObject {
     virtual QString menuTitle() const;
     
+    void setMinimumSize(const QSize& sz);
+    const QSize& minimumSize() const;
+
   public slots:
     virtual void paint(KstPaintType type, QPainter& p);
@@ -238,4 +241,5 @@ class KstViewObject : public KstObject {
     QMap<int, QString> _moveToMap;
     QMap<int, QString> _copyToMap;
+    QSize _minimumSize;
 };