Bug 131679 - Invalid coordinates when moving end point of line
Summary: Invalid coordinates when moving end point of line
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: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-01 19:48 UTC by Andrew Walker
Modified: 2006-08-02 01:39 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2006-08-01 19:48:49 UTC
Version:           HEAD (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
Kst may crash when the user moves one end-point of a line

STEPS TO REPRODUCE:
Start Kst
Create a line in the default window
Switch to layout mode
Select the line
Move one end point of the line outside of the left edge of the window
Release the left mouse button 

RESULTS:
Kst crashes

EXPECTED RESULTS:
The line is drawn totally within the window
Comment 1 Andrew Walker 2006-08-01 20:21:05 UTC
The problem is in KstGfxMouseHandlerUtils::newLine(...) which makes attempt to keep the end point of a line within its parent. This needs to be done and should be done cleverly (i.e. don't just clip the x and y values but find the point on the line that just lies within the parent).
Comment 2 George Staikos 2006-08-01 20:37:58 UTC
assert() is not a crash.
Comment 3 Duncan Hanson 2006-08-01 20:57:26 UTC
SVN commit 568625 by dhanson:

CCBUG:131679 fix assertion error when creating newLines. the problem when resizing lines does not occur in the viewaspect branch. something must have been backed out when merging, probably the patch for resize behaviour. currently, a 2 line change in KstTopLevelView::pressMoveLayoutModeEndPoint similar to the one commited is all that's necessary to fix the problem for moving lines, but i'll wait until we figure out what to do about the resizing behaviour before submitting it.

 M  +2 -1      kstgfxmousehandlerutils.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxmousehandlerutils.cpp #568624:568625
@@ -186,7 +186,8 @@
 QRect KstGfxMouseHandlerUtils::newLine(const QPoint& pos, const QPoint& mouseOrigin, bool specialAspect, const QRect& bounds) {
 
   if (KDE_ISLIKELY(!specialAspect)) {
-    return QRect(mouseOrigin,pos);
+    QPoint npos = KstGfxMouseHandlerUtils::findNearestPtOnLine(mouseOrigin, pos, pos, bounds);
+    return QRect(mouseOrigin, npos);
   } else { //want special 45deg, or vertical, or horizontal line. 
     QPoint npos;
     QPoint mouseDisplacement(pos - mouseOrigin); // for picking type of line..
Comment 4 Duncan Hanson 2006-08-02 01:15:29 UTC
George- I think that when you changed the QMIN/QMAX to kMin/kMax in
KstTopLevelView::pressMoveLayoutModeEndPoint you changed npos to pos- so
that npos inside the bounds is not correctly ensured. Changing this back
will fix the assert crash when moving line endpoints.

dh.

On Tue, 2006-08-01 at 18:57 +0000, Duncan Hanson wrote:
[bugs.kde.org quoted mail]
Comment 5 George Staikos 2006-08-02 01:18:36 UTC
  Odd.  I just did a diff off the branch and then "s/QMAX/kMax/g" and the same 
for QMIN.  Can you adjust that as necessary in trunk?
Comment 6 Duncan Hanson 2006-08-02 01:39:47 UTC
SVN commit 568692 by dhanson:

BUG:131679 restore correct pos. odd indeed- we'll have to keep an eye out for any other miss-diffs.

 M  +4 -4      ksttoplevelview.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.cpp #568691:568692
@@ -785,10 +785,10 @@
   QPoint npos(pos);
 
   //pos must be inside the parent
-  npos.setX(kMax(pos.x(), bounds.left()));
-  npos.setX(kMin(pos.x(), bounds.right()));
-  npos.setY(kMin(pos.y(), bounds.bottom()));
-  npos.setY(kMax(pos.y(), bounds.top()));
+  npos.setX(kMax(npos.x(), bounds.left()));
+  npos.setX(kMin(npos.x(), bounds.right()));
+  npos.setY(kMin(npos.y(), bounds.bottom()));
+  npos.setY(kMax(npos.y(), bounds.top()));
 
   if (KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget)) {
     QPoint movePoint, anchorPoint;