Skip to content

Commit

Permalink
Check for null project in hoverLeaveEvent
Browse files Browse the repository at this point in the history
Otherwise we get a crash when running the following tests:

   saveTilesetProject saveAsAndLoadTilesetProject

AddressSanitizer:DEADLYSIGNAL
=================================================================
==146641==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000028 (pc 0x7efcf80e5d5f bp 0x7ffed1dae970 sp 0x7ffed1dae960 T0)
==146641==The signal is caused by a READ memory access.
==146641==Hint: address points to the zero page.
    #0 0x7efcf80e5d5e in Project::hasLoaded() const /home/mitch/dev/slate/lib/project.cpp:118
    #1 0x7efcf8076734 in ImageCanvas::hoverLeaveEvent(QHoverEvent*) /home/mitch/dev/slate/lib/imagecanvas.cpp:3229
    #2 0x7efcf8181340 in TileCanvas::hoverLeaveEvent(QHoverEvent*) /home/mitch/dev/slate/lib/tilecanvas.cpp:576
    #3 0x7efcf4c7dcd6 in QQuickItem::event(QEvent*) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/items/qquickitem.cpp:8450
    #4 0x7efcf806fd04 in ImageCanvas::event(QEvent*) /home/mitch/dev/slate/lib/imagecanvas.cpp:2872
    #5 0x7efcf671794c in QApplicationPrivate::notify_helper(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/widgets/kernel/qapplication.cpp:3396
    #6 0x7efcf67130ca in QApplication::notify(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/widgets/kernel/qapplication.cpp:2758
    #7 0x7efceffda779 in QCoreApplication::notifyInternal2(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1061
    #8 0x7efceffdbf2f in QCoreApplication::sendEvent(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1469
    #9 0x7efcf529c40d in QQuickDeliveryAgentPrivate::sendHoverEvent(QEvent::Type, QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:947
    #10 0x7efcf529dfc6 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:1008
    #11 0x7efcf529d706 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:977
    #12 0x7efcf529d706 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:977
    #13 0x7efcf529d706 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:977
    #14 0x7efcf529d706 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:977
    #15 0x7efcf529d706 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:977
    #16 0x7efcf529d706 in QQuickDeliveryAgentPrivate::deliverHoverEvent(QQuickItem*, QPointF const&, QPointF const&, QFlags<Qt::KeyboardModifier>, unsigned long, bool&) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:977
    #17 0x7efcf52a41f7 in QQuickDeliveryAgentPrivate::flushFrameSynchronousEvents(QQuickWindow*) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/util/qquickdeliveryagent.cpp:1427
    #18 0x7efcf4f5ad86 in QQuickWindowPrivate::flushFrameSynchronousEvents() /home/mitch/dev/qt-dev/qtdeclarative/src/quick/items/qquickwindow.cpp:1610
    #19 0x7efcf56f8952 in QSGThreadedRenderLoop::polishAndSync(QSGThreadedRenderLoop::Window*, bool) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/scenegraph/qsgthreadedrenderloop.cpp:1516
    #20 0x7efcf56f66fa in QSGThreadedRenderLoop::handleUpdateRequest(QQuickWindow*) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/scenegraph/qsgthreadedrenderloop.cpp:1383
    #21 0x7efcf4f5a6f0 in QQuickWindow::event(QEvent*) /home/mitch/dev/qt-dev/qtdeclarative/src/quick/items/qquickwindow.cpp:1502
    #22 0x7efcf671794c in QApplicationPrivate::notify_helper(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/widgets/kernel/qapplication.cpp:3396
    #23 0x7efcf67130ca in QApplication::notify(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/widgets/kernel/qapplication.cpp:2758
    #24 0x7efceffda779 in QCoreApplication::notifyInternal2(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1061
    #25 0x7efceffdbf2f in QCoreApplication::sendEvent(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1469
    #26 0x7efcf161ec36 in QPlatformWindow::deliverUpdateRequest() /home/mitch/dev/qt-dev/qtbase/src/gui/kernel/qplatformwindow.cpp:810
    #27 0x7efcf161c4af in QPlatformWindow::windowEvent(QEvent*) /home/mitch/dev/qt-dev/qtbase/src/gui/kernel/qplatformwindow.cpp:490
    #28 0x7efce8271187 in QXcbWindow::windowEvent(QEvent*) /home/mitch/dev/qt-dev/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp:2313
    #29 0x7efcf1547c48 in QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/gui/kernel/qguiapplication.cpp:1997
    #30 0x7efcf6712bdb in QApplication::notify(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/widgets/kernel/qapplication.cpp:2660
    #31 0x7efceffda779 in QCoreApplication::notifyInternal2(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1061
    #32 0x7efceffdbf2f in QCoreApplication::sendEvent(QObject*, QEvent*) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1469
    #33 0x7efcf05690eb in QTimerInfoList::activateTimers() /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qtimerinfo_unix.cpp:639
    #34 0x7efcf08563c7 in timerSourceDispatch /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:185
    #35 0x7efcee59f17c in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5217c)
    #36 0x7efcee59f3ff  (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x523ff)
    #37 0x7efcee59f4a2 in g_main_context_iteration (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x524a2)
    #38 0x7efcf0857faa in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:429
    #39 0x7efce81dd296 in QXcbGlibEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) /home/mitch/dev/qt-dev/qtbase/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:132
    #40 0x7efceffdb6b2 in QCoreApplication::processEvents(QFlags<QEventLoop::ProcessEventsFlag>, int) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1321
    #41 0x7efcf01708fe in QTest::qWait(int) /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qtestsupport_core.cpp:119
    #42 0x563b462ffd0c in TestHelper::updateVariables(bool, Project::Type) /home/mitch/dev/slate/tests/shared/testhelper.cpp:2447
    #43 0x563b462f142d in TestHelper::loadProject(QUrl const&, QRegularExpression const&) /home/mitch/dev/slate/tests/shared/testhelper.cpp:2393
    #44 0x563b45f75772 in tst_App::saveAsAndLoadTilesetProject() /home/mitch/dev/slate/tests/auto/tst_app.cpp:456
    #45 0x563b460ba5fe in tst_App::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/mitch/dev/slate-qt_dev_debug-Debug/Debug_qt_dev_d_9f073821014d7ede/test-app.99bdad93/qt.headers/tst_app.moc:641
    #46 0x7efcf0024842 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qmetaobject.cpp:2384
    #47 0x7efcf84940af in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/mitch/dev/qt-dev/qtbase/src/corelib/kernel/qmetaobject.h:126
    #48 0x7efcf847e7e9 in QTest::TestMethods::invokeTestOnData(int) const /home/mitch/dev/qt-dev/qtbase/src/testlib/qtestcase.cpp:941
    #49 0x7efcf84809c3 in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/mitch/dev/qt-dev/qtbase/src/testlib/qtestcase.cpp:1173
    #50 0x7efcf8483f1a in QTest::TestMethods::invokeTests(QObject*) const /home/mitch/dev/qt-dev/qtbase/src/testlib/qtestcase.cpp:1516
    #51 0x7efcf84854eb in QTest::qRun() /home/mitch/dev/qt-dev/qtbase/src/testlib/qtestcase.cpp:1943
    #52 0x7efcf84848e4 in QTest::qExec(QObject*, int, char**) /home/mitch/dev/qt-dev/qtbase/src/testlib/qtestcase.cpp:1851
    #53 0x563b460ba418 in main /home/mitch/dev/slate/tests/auto/tst_app.cpp:6856
    #54 0x7efcef62e0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #55 0x563b45f531dd in _start (/home/mitch/dev/slate-qt_dev_debug-Debug/Debug_qt_dev_d_9f073821014d7ede/install-root/usr/local/test-app+0x631dd)
  • Loading branch information
mitchcurtis committed Jun 19, 2021
1 parent 1a0224e commit 676db77
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions lib/imagecanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3225,9 +3225,6 @@ void ImageCanvas::hoverLeaveEvent(QHoverEvent *event)
QQuickItem::hoverLeaveEvent(event);

setContainsMouse(false);

if (!mProject->hasLoaded())
return;
}

void ImageCanvas::keyPressEvent(QKeyEvent *event)
Expand Down
2 changes: 1 addition & 1 deletion lib/tilecanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ void TileCanvas::hoverLeaveEvent(QHoverEvent *event)
{
ImageCanvas::hoverLeaveEvent(event);

if (!mTilesetProject->hasLoaded())
if (!mTilesetProject || !mTilesetProject->hasLoaded())
return;

// Don't reset the cursor position here, because it looks jarring.
Expand Down

0 comments on commit 676db77

Please sign in to comment.