Bug 342101 - Lockup when using vanishing point ruler assistants left of the canvas
Summary: Lockup when using vanishing point ruler assistants left of the canvas
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools (other bugs)
Version First Reported In: git master (please specify the git hash!)
Platform: Mint (Ubuntu based) Linux
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
: 342220 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-21 23:42 UTC by Victor Pellen
Modified: 2015-01-07 22:16 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Pellen 2014-12-21 23:42:18 UTC
This one is kind of particular. When you have a vanishing point far off the left edge of the canvas (which is something that's often desirable) and you horizontally align your cursor with the vanishing point, Krita locks up.

It only seems to happen when the vanishing point is to the left, and not the right. In addition, it only happens horizontally, not vertically. This makes me think it might be something to do with the threshold where angle=0. Division by 0 maybe? It only seems to trigger when the vanishing point is both outside the canvas AND outside the view, although if it's outside the view but still inside the canvas, I've noticed slight hiccups when crossing the threshold. Might be my imagination. The handles on the vanishing point don't seem to matter, only the position of the vanishing point itself.

Reproducible: Always

Steps to Reproduce:
1. Create a new canvas, preferably screen size
2. Create a single vanishing point far outside the left side of the canvas, roughly in the middle.
3. Shift the view to the center of the canvas, so that the vanishing point is far off to the left.
4. Select the brush tool.
5. Align the mouse cursor horizontally with the off-screen vanishing point.

Actual Results:  
Krita hangs.

Expected Results:  
Krita should probably not hang.

Bugs aside, I absolutely love the feature. Ruler assistants are an incredibly useful tool.
Comment 1 pcchou 2014-12-23 14:34:14 UTC
I'm a google code-in who is trying to do bug triaging task.
Can you provide which version that you're using?
Comment 2 Victor Pellen 2014-12-23 21:41:18 UTC
(In reply to pcchou from comment #1)
> I'm a google code-in who is trying to do bug triaging task.
> Can you provide which version that you're using?

This thing:
https://launchpad.net/~dimula73/+archive/ubuntu/krita

Short answer, "Beta 1". That's all I can give you. The about window isn't specific on version numbering.
Comment 3 Dmitry Kazakov 2014-12-26 10:06:33 UTC
Confirmed.
Comment 4 Dmitry Kazakov 2014-12-26 10:13:23 UTC
The bug happens due to numerical instability of some calculations in the backtrace below. drawPreview() gets a task to paint a line of size 1e10 pixels.


Entering drawPreview path = QPainterPath: Element count=3
 -> MoveTo(x=9856, y=1408)
 -> LineTo(x=3440, y=1420)
 -> LineTo(x=-1.70109e+06, y=4608)

Entering drawPreview path = QPainterPath: Element count=3
 -> MoveTo(x=-2784, y=1696)
 -> LineTo(x=3440, y=1408)
 -> LineTo(x=8108, y=1192)

Entering drawPreview path = QPainterPath: Element count=3
 -> MoveTo(x=9856, y=1408)
 -> LineTo(x=3440, y=1408)
 -> LineTo(x=-1.30469e+10, y=1192)

^C
Program received signal SIGINT, Interrupt.
0x00007ffff0e58231 in pointAt (t=<unavailable>, this=0x7fffffffaef0) at ../../src/corelib/tools/qline.h:372
372         return QPointF(pt1.x() + vx * t, pt1.y() + vy * t);
(gdb) bt
#0  0x00007ffff0e58231 in pointAt (t=<unavailable>, this=0x7fffffffaef0) at ../../src/corelib/tools/qline.h:372
#1  QDashStroker::processCurrentSubpath (this=0x9146ba0) at painting/qstroker.cpp:1219
#2  0x00007ffff0e54760 in QStrokerOps::end (this=0x9146ba0) at painting/qstroker.cpp:227
#3  0x00007ffff4d11da1 in end (this=0x9146ba0) at ../../src/gui/painting/qstroker_p.h:387
#4  QDashedStrokeProcessor::process (this=0x9146b80, path=<optimized out>, pen=<optimized out>, clip=<optimized out>) at gl2paintengineex/qtriangulatingstroker.cpp:584
#5  0x00007ffff4d08bea in QGL2PaintEngineExPrivate::stroke (this=0x9146790, path=..., pen=...) at gl2paintengineex/qpaintengineex_opengl2.cpp:1220
#6  0x00007ffff4d09048 in QGL2PaintEngineEx::stroke (this=0x39daa00, path=..., pen=...) at gl2paintengineex/qpaintengineex_opengl2.cpp:1184
#7  0x00007ffff0df883d in QPaintEngineEx::draw (this=0x39daa00, path=...) at painting/qpaintengineex.cpp:601
#8  0x00007ffff73397da in KisPaintingAssistant::drawPreview (painter=..., path=...) at /home/devel/kde-src/calligra/krita/ui/kis_painting_assistant.cc:204
#9  0x00007fffd5bf1713 in VanishingPointAssistant::drawAssistant (this=0x87c92c0, gc=..., updateRect=..., converter=0x75e0980, cached=true, canvas=0x75d8670, assistantVisible=true, previewVisible=true)
    at /home/devel/kde-src/calligra/krita/plugins/assistants/RulerAssistant/VanishingPointAssistant.cc:124
#10 0x00007ffff734579f in KisPaintingAssistantsDecoration::drawDecoration (this=0x809e2c0, gc=..., updateRect=..., converter=0x75e0980, canvas=0x75d8670)
    at /home/devel/kde-src/calligra/krita/ui/kis_painting_assistants_decoration.cpp:118
#11 0x00007ffff71bd502 in KisCanvasDecoration::paint (this=0x809e2c0, gc=..., updateArea=..., converter=0x75e0980, canvas=0x75d8670) at /home/devel/kde-src/calligra/krita/ui/canvas/kis_canvas_decoration.cc:81
#12 0x00007ffff719f96b in KisCanvasWidgetBase::drawDecorations (this=0x7957d08, gc=..., updateWidgetRect=...) at /home/devel/kde-src/calligra/krita/ui/canvas/kis_canvas_widget_base.cpp:143
#13 0x00007ffff74134f1 in KisOpenGLCanvas2::renderDecorations (this=0x7957ce0, painter=0x7fffffffc1e0) at /home/devel/kde-src/calligra/krita/ui/opengl/kis_opengl_canvas2.cpp:646
#14 0x00007ffff741a69f in KisOpenGLCanvas2::paintGL (this=0x7957ce0) at /home/devel/kde-src/calligra/krita/ui/opengl/kis_opengl_canvas2.cpp:251
#15 0x00007ffff4cb80a0 in QGLWidget::glDraw (this=0x7957ce0) at qgl.cpp:4521
#16 0x00007ffff4cb7a39 in QGLWidget::paintEvent (this=0x7957ce0) at qgl.cpp:4319
#17 0x00007ffff0d15268 in QWidget::event (this=0x7957ce0, event=0x7fffffffcb00) at kernel/qwidget.cpp:8441
#18 0x00007ffff4cbcc01 in QGLWidget::event (this=0x7957ce0, e=0x7fffffffcb00) at qgl.cpp:4302
#19 0x00007ffff0cc4be4 in notify_helper (e=0x7fffffffcb00, receiver=0x7957ce0, this=0x743cd0) at kernel/qapplication.cpp:4481
#20 QApplicationPrivate::notify_helper (this=0x743cd0, receiver=0x7957ce0, e=0x7fffffffcb00) at kernel/qapplication.cpp:4453
#21 0x00007ffff0cc9a71 in QApplication::notify (this=0x7fffffffd8a0, receiver=0x7957ce0, e=0x7fffffffcb00) at kernel/qapplication.cpp:4360
#22 0x00007ffff754890e in KisApplication::notify (this=<optimized out>, receiver=0x7957ce0, event=0x7fffffffcb00) at /home/devel/kde-src/calligra/krita/ui/KisApplication.cpp:522
#23 0x00007ffff02e681c in QCoreApplication::notifyInternal (this=0x7fffffffd8a0, receiver=0x7957ce0, event=0x7fffffffcb00) at kernel/qcoreapplication.cpp:787
#24 0x00007ffff0d12176 in sendSpontaneousEvent (event=0x7fffffffcb00, receiver=0x7957ce0) at ../../src/corelib/kernel/qcoreapplication.h:218
#25 QWidgetPrivate::drawWidget (this=0x7957590, pdev=0x7957cf0, rgn=..., offset=..., flags=3, sharedPainter=0x0, backingStore=0x0) at kernel/qwidget.cpp:5528
#26 0x00007ffff0ecc147 in QWidgetPrivate::repaint_sys (this=0x7957590, rgn=...) at painting/qbackingstore.cpp:1617
#27 0x00007ffff0d08964 in QWidgetPrivate::syncBackingStore (this=0x7957590) at kernel/qwidget.cpp:1854
#28 0x00007ffff0d1577c in QWidget::event (this=0x7957ce0, event=0x8ff3d70) at kernel/qwidget.cpp:8588
#29 0x00007ffff4cbcc01 in QGLWidget::event (this=0x7957ce0, e=0x8ff3d70) at qgl.cpp:4302
#30 0x00007ffff0cc4be4 in notify_helper (e=0x8ff3d70, receiver=0x7957ce0, this=0x743cd0) at kernel/qapplication.cpp:4481
#31 QApplicationPrivate::notify_helper (this=0x743cd0, receiver=0x7957ce0, e=0x8ff3d70) at kernel/qapplication.cpp:4453
#32 0x00007ffff0cc9a71 in QApplication::notify (this=0x7fffffffd8a0, receiver=0x7957ce0, e=0x8ff3d70) at kernel/qapplication.cpp:4360
#33 0x00007ffff754890e in KisApplication::notify (this=<optimized out>, receiver=0x7957ce0, event=0x8ff3d70) at /home/devel/kde-src/calligra/krita/ui/KisApplication.cpp:522
#34 0x00007ffff02e681c in QCoreApplication::notifyInternal (this=0x7fffffffd8a0, receiver=0x7957ce0, event=0x8ff3d70) at kernel/qcoreapplication.cpp:787
#35 0x00007ffff02e9bf8 in sendEvent (event=0x8ff3d70, receiver=0x7957ce0) at kernel/qcoreapplication.h:215
#36 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x60e720) at kernel/qcoreapplication.cpp:1428
#37 0x00007ffff0d68b7a in sendPostedEvents () at ../../src/corelib/kernel/qcoreapplication.h:220
#38 QEventDispatcherX11::processEvents (this=0x60df00, flags=...) at kernel/qeventdispatcher_x11.cpp:75
#39 0x00007ffff02e5a22 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#40 0x00007ffff02e5c1f in QEventLoop::exec (this=0x7fffffffd860, flags=...) at kernel/qeventloop.cpp:201
#41 0x00007ffff02e9de7 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1064
#42 0x00007ffff7ae7183 in kdemain (argc=<optimized out>, argv=<optimized out>) at /home/devel/kde-src/calligra/krita/main.cc:110
#43 0x00007fffeefb223d in __libc_start_main () from /lib64/libc.so.6
#44 0x0000000000400911 in _start () at ../sysdeps/x86_64/elf/start.S:113
Comment 5 Dmitry Kazakov 2014-12-26 10:22:03 UTC
The cause seems to be in this code:

        QLineF snapLine= QLineF(startPoint, mousePos);
        if (mousePos.y()>startPoint.y()) {
            snapLine.intersect(QLineF(gcp3, gcp4 ), &endPoint);
            }
        else if (mousePos.y()<startPoint.y()) {
            snapLine.intersect(QLineF(gcp1, gcp2 ), &endPoint);
            }
        else if (mousePos.x()>startPoint.x()) {
            snapLine.intersect(QLineF(gcp2, gcp4 ), &endPoint);
            }
        else if (mousePos.x()<startPoint.x()) {
            snapLine.intersect(QLineF(gcp1, gcp3 ), &endPoint);
            }
        else {
            startPoint=*handles()[0];
            endPoint=mousePos;
            dbgFile<<"ruler can't find canvas borders."<<canvas;
            }

If snapLine is parallel to any side of the viewport, then the intersection happens at the infinity point.
Comment 6 Dmitry Kazakov 2014-12-29 08:50:01 UTC
*** Bug 342220 has been marked as a duplicate of this bug. ***
Comment 7 wolthera 2015-01-07 22:16:20 UTC
Git commit 9727ef37a87663424623d223f999189e56db7d2b by Wolthera van Hovell.
Committed on 07/01/2015 at 22:16.
Pushed by woltherav into branch 'calligra/2.9'.

Fix bug 342101

Fix some issues with view-port intersection by using the kis_algebra_2d
function.

M  +6    -26   krita/plugins/assistants/RulerAssistant/InfiniteRulerAssistant.cc
M  +9    -27   krita/plugins/assistants/RulerAssistant/ParallelRulerAssistant.cc
M  +27   -21   krita/plugins/assistants/RulerAssistant/PerspectiveAssistant.cc
M  +14   -27   krita/plugins/assistants/RulerAssistant/VanishingPointAssistant.cc

http://commits.kde.org/calligra/9727ef37a87663424623d223f999189e56db7d2b