Bug 131620

Summary: Aspect for fixed aspect view objects can drift on resize
Product: [Applications] kst Reporter: Netterfield <netterfield>
Component: generalAssignee: Duncan Hanson <duncan.hanson>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Netterfield 2006-07-31 23:36:26 UTC
Version:           1.3.0_devel (using KDE 3.5.3, Kubuntu Package 4:3.5.3-0ubuntu0.2 dapper)
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.15-26-386

Create a plot
in the plot, make an image with fixed aspect

Repeatedly enlarge and shrink the window (quickly).  After a while, the aspect will drift (either wider or narrower).  Edit/apply the image will reset the fixed aspect to the correct thing.
Comment 1 Duncan Hanson 2006-08-01 18:30:08 UTC
sounds like resize is being called when it should be parentResize.
Comment 2 Duncan Hanson 2006-08-01 19:14:04 UTC
SVN commit 568580 by dhanson:

CCBUG:131620 fixed. the problem was the myOldGeom did not necessarily have the proper aspect ratio, particularly if _geom.setSize(_geom.size().expandedTo(_minimumSize)); had been called.

 M  +2 -1      kstviewobject.cpp  
 M  +1 -0      kstviewobject.h  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.cpp #568579:568580
@@ -565,6 +565,7 @@
   _aspect.x = xc; // restore position.
   _aspect.y = yc;
   updateFromAspect();
+  _idealSize = _geom.size();
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
     (*i)->parentResized();
   }
@@ -1412,7 +1413,7 @@
     _geom.setBottom(geom.top() + int((_aspect.y + _aspect.h) * geom.height()) - 1);
 
     if (_maintainAspect == true) {
-      QSize maintaining_size(myOldGeom.size());
+      QSize maintaining_size(_idealSize);
       maintaining_size.scale(_geom.size(),QSize::ScaleMin);
       _geom.setSize(maintaining_size);
     }
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.h #568579:568580
@@ -322,6 +322,7 @@
     QGuardedPtr<KstViewObject> _parent; // danger!!
     Q_UINT32 _standardActions, _layoutActions;
     KstAspectRatio _aspect;
+    QSize _idealSize; //ideal size for object. useful when _maintainAspect==true
     KstAspectRatio _aspectOldZoomedObject;
     QString _type;
     QRegion _clipMask; // The mask of this object
Comment 3 Duncan Hanson 2006-08-01 19:16:09 UTC
*** Bug has been marked as fixed ***.
Comment 4 Duncan Hanson 2006-08-01 19:42:55 UTC
SVN commit 568594 by dhanson:

CCBUG:131620 add _idealSize to saved session.

 M  +10 -3     kstviewobject.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.cpp #568593:568594
@@ -104,6 +104,7 @@
   _foregroundColor = viewObject._foregroundColor;
   _backgroundColor = viewObject._backgroundColor;
   _aspect = viewObject._aspect;
+  _idealSize = viewObject._idealSize;
   _standardActions = viewObject._standardActions;
   _layoutActions = viewObject._layoutActions;
   _maximized = false;
@@ -156,6 +157,9 @@
         _aspect.y = el.attribute("y", "0.0").toDouble();
         _aspect.w = el.attribute("w", "1.0").toDouble();
         _aspect.h = el.attribute("h", "1.0").toDouble();
+      } else if (el.tagName() == "idealsize") {
+        _idealSize.setWidth(el.attribute("w", "1").toInt());
+        _idealSize.setHeight(el.attribute("h", "1").toInt());
       }
     }
     n = n.nextSibling();
@@ -289,6 +293,9 @@
     "\" w=\"" << aspect.w <<
     "\" h=\"" << aspect.h << "\" />" << endl;
 
+  ts << indent << "<idealsize w=\"" << _idealSize.width() <<
+    "\" h=\"" << _idealSize.height() <<"\" />" << endl;
+
   // save all properties
   for (int i = 0; i < metaObject()->numProperties(true); i++) {
     ts << indent << "<" << metaObject()->property(i, true)->name() << ">";
@@ -565,7 +572,6 @@
   _aspect.x = xc; // restore position.
   _aspect.y = yc;
   updateFromAspect();
-  _idealSize = _geom.size();
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
     (*i)->parentResized();
   }
@@ -1453,6 +1459,7 @@
 
 
 void KstViewObject::updateAspect() {
+  _idealSize = _geom.size();
   updateAspectSize();
   updateAspectPos();
   setDirty();
@@ -1570,7 +1577,7 @@
   str << tagName();
   str << _geom << _backgroundColor << _foregroundColor;
   // _parent should not be sent since it is meaningless in a drag context
-  str << _standardActions << _layoutActions << _aspect;
+  str << _standardActions << _layoutActions << _aspect << _idealSize;
 
   str << _children.count();
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
@@ -1592,7 +1599,7 @@
   kstdDebug() << "Decoding " << tagName << " from drag." << endl;
   // FIXME: rename objects if they cause a namespace conflict
   str >> _geom >> _backgroundColor >> _foregroundColor;
-  str >> _standardActions >> _layoutActions >> _aspect;
+  str >> _standardActions >> _layoutActions >> _aspect >> _idealSize;
 
   _children.clear();
   uint cc = 0;