Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 5.0.2 & 5.1.0 Drag and Drop crash

Qt 5.0.2 & 5.1.0 Drag and Drop crash

Scheduled Pinned Locked Moved General and Desktop
25 Posts 7 Posters 13.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SoulSharer
    wrote on last edited by
    #1

    Updated information with callstack at the bottom of the topic

    Hello there, I've been using Qt for a while and it is great, however I encountered a problem in the newer version.
    When I start dragging and drop immediately - application just crashes with an error message "Access violation reading location", I swear I checked everything twice, made a lot if/else for sanity checks, still nothing. (looked into sample code, documentation, everything)

    It crashes before it gets a chance to call dropEvent() function, even though dragEnterEvent() and dragMoveEvent() being called.
    What could it be? I have no debugging symbols and call stack is just helpless.
    Drag and drop action happens between two QMainWindows that are owned by the main QMainWindow (dragging from QListWidget and dropping to QTableWidget that are inherited by custom classes).
    It is crashing in both Debug and Release.

    P.s. if I wait a little before dropping all seems to be working

    !http://i.imgur.com/VJre463.png(Screen_of_the_call_stack)! (probably worthless) :(
    http://i.imgur.com/IAdr8CW.png New, captured with application verifier on. (all options enabled except for "Low resource simulation")
    Looks like a similar issue: http://stackoverflow.com/questions/15050300/visual-studio-2010-access-violation-reading-location-debuging-not-much-info

    Don't know if that will help, but here is what verifier outputted.
    @First-chance exception at 0x664d1d9a in pleaseWork.exe: 0xC0000005: Access violation reading location 0x00000004.

    ===========================================================
    VERIFIER STOP 0000000000000013: pid 0x6454: first chance access violation for current stack trace

    0000000000000004 : Invalid address being accessed
    00000000664D1D9A : Code performing invalid access
    00000000001CEA00 : Exception record. Use .exr to display it.
    00000000001CE510 : Context record. Use .cxr to display it.

    This verifier stop is continuable.
    After debugging it use 'go' to continue.

    =======================================
    VERIFIER STOP 00000013: pid 0x6454: First chance access violation for current stack trace.

    00000004 : Invalid address causing the exception.
    664D1D9A : Code address executing the invalid access.
    002EB0A8 : Exception record.
    002EB0F8 : Context record.
    @

    Thanks for any help!

    ---Environment
    Windows 7 x64 SP1
    Qt 5.0.0 (one that is provided with installer)
    Visual Studio 2010 SP1

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SoulSharer
      wrote on last edited by
      #2

      Added additional information, spent a day debugging, still out of luck. :(

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SoulSharer
        wrote on last edited by
        #3

        -Finally managed to temporary fix this issue with-
        @setAttribute(Qt::WA_DontCreateNativeAncestors, true); @
        -Just in case someone will run into the same problem.-

        Was wrong, still the same thing..

        P.s. I updated to 5.0.2 and it didn't help

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bodzio131
          wrote on last edited by
          #4

          Hi,
          Could you load *.pdb files for Qt binaries and then provide callstack?
          As far as I can see you use visual leak detector (vld_x86.dll). Do you encounter your problems without it?
          Could you try to build your program on linux and use valgrind?

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            can you show some lines of code ... or even share your project for inspection?

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SoulSharer
              wrote on last edited by
              #6

              Thanks for replies guys, I did try to turn off visual leak detector (and it is off by default in release) - same situation and I don't have a chance to build it on Linux I'm afraid. (mostly because I depend on Microsofts stuff, like DirectX for example)

              Not sure where would I get .pdb files for binaries, other than by compiling myself which is a pain for Qt 5 with this new libraries (icu, angle) as far as I see.

              [quote author="raven-worx" date="1365878204"]can you show some lines of code ... or even share your project for inspection?[/quote]
              There is a lot of code and a lot of unrelated to the issue (also it is a closed project so I can't open the whole thing to the public, even if I want to), so I can only provide small snippets from it I guess, not sure what is need though. So I will post what I'm doing with drag and drop.

              Starting with (SpriteDBList : QListWidget):
              @void SpriteDBList::mousePressEvent( QMouseEvent *event )
              {
              QListWidget::mousePressEvent(event);

              if (this->selectedItems().count() == 0) return;

              if (event->button() == Qt::LeftButton)
              dragStartPosition = event->pos();
              }

              void SpriteDBList::mouseMoveEvent( QMouseEvent *event )
              {
              if (selectedItems().count() == 0 || !(event->buttons() & Qt::LeftButton) || (event->pos() - dragStartPosition).manhattanLength()
              < QApplication::startDragDistance())
              {
              QListWidget::mouseMoveEvent(event);
              return;
              }

              if (!currentItem()) {
              return;
              }

              seString spriteFrameName = currentItem()->text().toStdString();
              seString spriteFrameFullPath = m_dbWidget->GetCurrentDir() + "\" + spriteFrameName;

              QDrag *drag = new QDrag(this);
              QMimeData *mimeData = new QMimeData();
              QByteArray data(spriteFrameFullPath.c_str());
              mimeData->setData("joi/spriteframe_path", data);
              drag->setMimeData(mimeData);
              drag->setPixmap(currentItem()->icon().pixmap(80, 80)); //icon with which we will move
              drag->setHotSpot(QPoint(drag->pixmap().width()/2,
              drag->pixmap().height()/2)); //where our cursor will be relative to topleft of pixmap

              Qt::DropAction dropAction = drag->exec(Qt::CopyAction, Qt::CopyAction);
              }
              @
              and ending in (AnimationFrameTable : QTableWidget):
              @
              void AnimationFrameTable::dragEnterEvent(QDragEnterEvent *event) {
              Qt::DropAction action = event->proposedAction();

              if (action == Qt::IgnoreAction) {
              event->ignore();
              return;
              }

              QObject* source = event->source();

              if (event->mimeData() == NULL) {
              event->ignore();
              return;
              } else {
              const QMimeData* mime = event->mimeData();

              if (mime->hasFormat("joi/spriteframe_path")) {
              event->accept(); //looks like crash happens after this line
              } else {
              event->ignore();
              }
              }
              }

              void AnimationFrameTable::dragMoveEvent(QDragMoveEvent *e) {
              Qt::DropAction action = e->proposedAction();
              if (action == Qt::IgnoreAction) {
              e->ignore();
              return;
              }

              QObject* source = e->source();
              const QMimeData* mime = e->mimeData();
              if (mime == NULL) {
              e->ignore();
              } else if (mime->hasFormat("joi/spriteframe_path")) {
              e->accept();
              } else {
              e->ignore();
              }
              }

              void AnimationFrameTable::dropEvent(QDropEvent *event) {
              Qt::DropAction action = event->proposedAction();
              if (action == Qt::IgnoreAction) {
              event->ignore();
              return;
              }

              if (event->mimeData() == NULL || !event->mimeData()->hasFormat("joi/spriteframe_path")) {
              event->ignore();
              return;
              }

              QByteArray data = event->mimeData()->data("joi/spriteframe_path");
              QString fullpath = data;
              m_animWindow->AddSpriteFrame(fullpath.toStdString());

              event->accept();
              }@

              There are a lot of checks just because I wanted to nail down the issue, still didn't help at all.
              I checked everything in what I've posted. For example I commented strings just to see whether it is a heap corruption and passed mimeData with empty QByteArray, didn't help either.

              And it crashes before it gets to dropEvent() function as I've mentioned before

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SoulSharer
                wrote on last edited by
                #7

                Ok, I've managed to load in .pdb and here is a callstack, now it looks useful:

                Updated callstacks:
                http://i.imgur.com/BAoL8mC.png
                http://i.imgur.com/XIEbyvp.png

                and where it stopped
                http://i.imgur.com/BJdc8SP.png

                • looks like scoped pointer was destroyed or something
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  Hope you don't mind me asking that, but would aren't you reinventing the wheel ? Drag and Drop support are already supported in QTableWidget and QListWidget.

                  You might better go overloading "QTableWidget::dropMimeData":http://qt-project.org/doc/qt-4.8/qtablewidget.html#dropMimeData and "QListWidget::mimeData":http://qt-project.org/doc/qt-4.8/qlistwidget.html#mimeData

                  You would then only have to care about your data.

                  Hope it helps

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SoulSharer
                    wrote on last edited by
                    #9

                    [quote author="SGaist" date="1365890494"]Hi,

                    Hope you don't mind me asking that, but would aren't you reinventing the wheel ? Drag and Drop support are already supported in QTableWidget and QListWidget.

                    You might better go overloading "QTableWidget::dropMimeData":http://qt-project.org/doc/qt-4.8/qtablewidget.html#dropMimeData and "QListWidget::mimeData":http://qt-project.org/doc/qt-4.8/qlistwidget.html#mimeData

                    You would then only have to care about your data.

                    Hope it helps[/quote]

                    Didn't know about that, thanks. I might use it for most of the stuff, but I still want to find out what's wrong with current code if possible.

                    1 Reply Last reply
                    0
                    • raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #10

                      This code looks good so far ... the problem must be somewhere else.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        bodzio131
                        wrote on last edited by
                        #11

                        Do you manage QObject descendants by yourself? Maybe you delete such objects directly (instead of deleteLater) or you use smart pointers with such objects. It could be a real problem if you interfere with Qt objects management model.

                        I think you need to narrow your project by cutting whatever you can step by step, or try to use the same drag-drop logic in simpler app. However, I suppose the problem can be far away from part which shows crash :(

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SoulSharer
                          wrote on last edited by
                          #12

                          Thanks for the help.

                          [quote author="Bogdan" date="1365933102"]Do you manage QObject descendants by yourself? Maybe you delete such objects directly (instead of deleteLater) or you use smart pointers with such objects. It could be a real problem if you interfere with Qt objects management model.

                          I think you need to narrow your project by cutting whatever you can step by step, or try to use the same drag-drop logic in simpler app. However, I suppose the problem can be far away from part which shows crash :([/quote]

                          No I don't manage anything related to QObject myself and don't use smart pointers at all. The maximum I do is subclassing existing widgets to reimplement drag and drop actions.

                          And yeah I will try to cut it into something testable.

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SoulSharer
                            wrote on last edited by
                            #13

                            For some reason in notifyInternal() receiver is NULL (0) after dropping, which causes all of this. Still trying to recreate this issue.

                            1 Reply Last reply
                            0
                            • raven-worxR Offline
                              raven-worxR Offline
                              raven-worx
                              Moderators
                              wrote on last edited by
                              #14

                              this means that you probably deleting objects before the drag has finished.
                              Or creating them on the wrong storage location (e.g. stack).

                              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                              If you have a question please use the forum so others can benefit from the solution in the future

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SoulSharer
                                wrote on last edited by
                                #15

                                Thing is I don't allocate on stack or delete them at all, my windows are allocated on heap and are not deleted until main window closes.
                                -Checked it once more, everything alright

                                Could it be because of some broken relationship between QMainWindows or QWidgets?

                                And Dropping does work if I don't do it fast, if I do it fast it gets reciever that is null and so it crashes.

                                1 Reply Last reply
                                0
                                • raven-worxR Offline
                                  raven-worxR Offline
                                  raven-worx
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  Hard to tell if you can't show more code...

                                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                  If you have a question please use the forum so others can benefit from the solution in the future

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SoulSharer
                                    wrote on last edited by
                                    #17

                                    Never mind, thanks for help anyway.

                                    1 Reply Last reply
                                    0
                                    • W Offline
                                      W Offline
                                      wizzhard
                                      wrote on last edited by
                                      #18

                                      Hello,

                                      I also experience a crash during drag n drop with the very same callstack after the crash.

                                      In my case the crash occurs in a qtreeview when i drag n drop item internally.

                                      In fact everything works fine until I double click an item of the view to rename it.

                                      1 - I fill the item delegate with the new name
                                      2 - Press enter to validate
                                      3 - setData of the model is called (but does nothing).
                                      4 - I try to drag & drop an item
                                      5 - dragEnterEvent is called once.
                                      6 - dragMoveEvent is called once
                                      7 - program crash in QScopedPointer line134

                                      @0 QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::data qscopedpointer.h 134 0x651f1d4a
                                      1 qGetPtrHelper<QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> > > qglobal.h 991 0x651df58b
                                      2 QObject::d_func qobject.h 119 0x651f0323
                                      3 QCoreApplication::notifyInternal qcoreapplication.cpp 764 0x65468230
                                      4 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 206 0x65577098
                                      5 QWidgetWindow::handleDropEvent qwidgetwindow.cpp 566 0x65d3e759
                                      6 QWidgetWindow::event qwidgetwindow.cpp 195 0x65d3d30c
                                      7 QApplicationPrivate::notify_helper qapplication.cpp 3398 0x65cc291e
                                      8 QApplication::notify qapplication.cpp 2829 0x65cc035a
                                      9 QCoreApplication::notifyInternal qcoreapplication.cpp 767 0x65468264
                                      10 QCoreApplication::sendEvent qcoreapplication.h 203 0x6546d5e9
                                      11 QGuiApplicationPrivate::processDrop qguiapplication.cpp 2228 0x66673045
                                      12 QWindowSystemInterface::handleDrop qwindowsysteminterface.cpp 556 0x6665860c
                                      13 QWindowsOleDropTarget::Drop qwindowsdrag.cpp 683 0x64eef4dd
                                      14 CPrivDragDrop::PrivDragDrop getif.cxx 960 0x770f2b79
                                      15 PrivDragDrop getif.cxx 1099 0x770f2d78
                                      16 CDropTarget::Drop drag.cpp 2492 0x770ca04d
                                      17 CDragOperation::CompleteDrop drag.cpp 1601 0x770c9ede
                                      18 DoDragDrop drag.cpp 1964 0x770ca8dd
                                      19 QWindowsDrag::drag qwindowsdrag.cpp 802 0x64eef9fa
                                      20 QDragManager::drag qdnd.cpp 143 0x666831c8
                                      21 QDrag::exec qdrag.cpp 282 0x66681daa
                                      22 QAbstractItemView::startDrag qabstractitemview.cpp 3581 0x65faf1a5
                                      23 QAbstractItemView::mouseMoveEvent qabstractitemview.cpp 1761 0x65fa9d9b
                                      24 QTreeView::mouseMoveEvent qtreeview.cpp 1924 0x65ff6a8b
                                      25 QWidget::event qwidget.cpp 7842 0x65d0a0ed
                                      26 QFrame::event qframe.cpp 534 0x65e67772
                                      27 QAbstractScrollArea::viewportEvent qabstractscrollarea.cpp 1163 0x65f089c4
                                      28 QAbstractItemView::viewportEvent qabstractitemview.cpp 1680 0x65fa971b
                                      29 QTreeView::viewportEvent qtreeview.cpp 1260 0x65ff3ece
                                      30 QAbstractScrollAreaPrivate::viewportEvent qabstractscrollarea_p.h 105 0x65caaf28
                                      31 QAbstractScrollAreaFilter::eventFilter qabstractscrollarea_p.h 121 0x65f0a919
                                      32 QCoreApplicationPrivate::sendThroughObjectEventFilters qcoreapplication.cpp 863 0x654684f3
                                      33 QApplicationPrivate::notify_helper qapplication.cpp 3394 0x65cc2902
                                      34 QApplication::notify qapplication.cpp 2962 0x65cc098c
                                      35 QCoreApplication::notifyInternal qcoreapplication.cpp 767 0x65468264
                                      36 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 206 0x65577098
                                      37 QApplicationPrivate::sendMouseEvent qapplication.cpp 2469 0x65cbfab5
                                      38 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 403 0x65d3dd00
                                      39 QWidgetWindow::event qwidgetwindow.cpp 155 0x65d3d274
                                      40 QApplicationPrivate::notify_helper qapplication.cpp 3398 0x65cc291e
                                      41 QApplication::notify qapplication.cpp 2829 0x65cc035a
                                      42 QCoreApplication::notifyInternal qcoreapplication.cpp 767 0x65468264
                                      43 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 206 0x65577098
                                      44 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 1417 0x6666ffe4
                                      45 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1249 0x6666f852
                                      46 QWindowSystemInterface::sendWindowSystemEventsImplementation qwindowsysteminterface.cpp 536 0x66658561
                                      47 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 516 0x666584e9
                                      48 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 86 0x64ecc014
                                      49 qt_internal_proc qeventdispatcher_win.cpp 423 0x654f08d7
                                      50 InternalCallWinProc USER32 0x766662fa
                                      51 UserCallWinProcCheckWow USER32 0x76666d3a
                                      52 DispatchMessageWorker USER32 0x766677c4
                                      53 DispatchMessageW USER32 0x7666788a
                                      54 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 744 0x654f19c3
                                      55 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 78 0x64ecbf7e
                                      56 QEventLoop::processEvents qeventloop.cpp 137 0x65464ea1
                                      57 QEventLoop::exec qeventloop.cpp 212 0x65464ffe
                                      58 QCoreApplication::exec qcoreapplication.cpp 1020 0x6546879d
                                      59 QGuiApplication::exec qguiapplication.cpp 1184 0x6666f5e8
                                      60 QApplication::exec qapplication.cpp 2674 0x65cc0009
                                      61 main main.cpp 20 0xbaf6fe
                                      62 WinMain qtmain_win.cpp 131 0xc5f5ea
                                      63 __tmainCRTStartup crtexe.c 547 0xc5d440
                                      64 WinMainCRTStartup crtexe.c 371 0xc5d1cf
                                      65 BaseThreadInitThunk kernel32 0x775f33aa
                                      66 __RtlUserThreadStart ntdll32 0x77bd9f72
                                      67 _RtlUserThreadStart ntdll32 0x77bd9f45 @

                                      1 Reply Last reply
                                      0
                                      • W Offline
                                        W Offline
                                        wizzhard
                                        wrote on last edited by
                                        #19

                                        I just found something that seems to fix the issue here.

                                        http://stackoverflow.com/questions/17373591/qt5-custom-lineedit-widget-qlineedit-subclass-private-variable-crashes-applica

                                        I have unchecked acceptDrop on the qtreeview that own the items and it doesn't crash anymore.

                                        EDIT : it doesn't works finally, it was the interruption of the debugger that prevented the problem to occur by interrupting the item delegate validation.

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SoulSharer
                                          wrote on last edited by
                                          #20

                                          Well, I've updated to 5.1.0, it still crashes. But now it also outputs this:

                                          bq. QAccessibleTree::indexFromLogical: invalid index: 1 0 for QTreeWidget(0x4b06408)
                                          Cannot creat accessible child interface for object: QTreeWidget(0x4b06408) index: 1
                                          QAccessibleTree::indexFromLogical: invalid index: 2 0 for LayersTreeWidget(0x4a69668, name = "treeWidget")
                                          Cannot creat accessible child interface for object: LayersTreeWidget(0x4a69668, name = "treeWidget") index: 2
                                          QAccessibleTree::indexFromLogical: invalid index: 2 0 for LayersTreeWidget(0x4a69668, name = "treeWidget")
                                          Cannot creat accessible child interface for object: LayersTreeWidget(0x4a69668, name = "treeWidget") index: 2
                                          First-chance exception at 0x74c2c41f in JOI_Editor.exe: 0x80010001: Вызов был отклонен.
                                          QAccessibleTree::indexFromLogical: invalid index: 3 0 for LayersTreeWidget(0x4a69668, name = "treeWidget")
                                          Cannot creat accessible child interface for object: LayersTreeWidget(0x4a69668, name = "treeWidget") index: 3
                                          First-chance exception at 0x6631232a in JOI_Editor.exe: 0xC0000005: Access violation reading location 0x00000004.
                                          Unhandled exception at 0x770815de in JOI_Editor.exe: 0xC0000005: Access violation reading location 0x00000004.
                                          The program '[7544] JOI_Editor.exe: Native' has exited with code -1073741819 (0xc0000005).

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved