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
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).
assert() is not a crash.
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..
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]
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?
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;