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
Forum Updated to NodeBB v4.3 + New Features

Qt 5.0.2 & 5.1.0 Drag and Drop crash

Scheduled Pinned Locked Moved General and Desktop
25 Posts 7 Posters 13.6k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bodzio131
    wrote on 13 Apr 2013, 18:24 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
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 13 Apr 2013, 18:36 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 13 Apr 2013, 20:27 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 13 Apr 2013, 20:55 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 13 Apr 2013, 22:01 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 14 Apr 2013, 06:23 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
              • R Offline
                R Offline
                raven-worx
                Moderators
                wrote on 14 Apr 2013, 09:39 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 14 Apr 2013, 09:51 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 14 Apr 2013, 10:37 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 16 Apr 2013, 09:00 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
                      • R Offline
                        R Offline
                        raven-worx
                        Moderators
                        wrote on 16 Apr 2013, 09:04 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 16 Apr 2013, 09:17 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
                          • R Offline
                            R Offline
                            raven-worx
                            Moderators
                            wrote on 16 Apr 2013, 09:56 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 16 Apr 2013, 16:34 last edited by
                              #17

                              Never mind, thanks for help anyway.

                              1 Reply Last reply
                              0
                              • W Offline
                                W Offline
                                wizzhard
                                wrote on 18 Aug 2013, 11:20 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 18 Aug 2013, 12:59 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 19 Aug 2013, 16:30 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
                                    • W Offline
                                      W Offline
                                      wizzhard
                                      wrote on 20 Aug 2013, 17:41 last edited by
                                      #21

                                      I have debugged a little in qt's code and there is something weird.

                                      Before I rename an item everything works fine and the function QWindowsOleDropTarget::Drop qwindowsdrag.cpp 683 is called only when I release the mouse button over the item I want to do the drop on.
                                      After I have renamed an item I start a drag, the dragEnterEvent occurs one time, then dragMoveEvent occurs one time too and the program crashes under QWindowsOleDropTarget::Drop qwindowsdrag.cpp 683 but I never released the button so this drop should not have occured.
                                      If , after I renamed an item (so the app should crash the next time I drag an item in the treeview), I open an explorer windows, start to drag an item in it and press escape to cancel the drag then come back to my application and start a drag I don't crash and everything works fine.

                                      I am on Windows 7 x64 with Qt 5.1.0 (vs2010)

                                      QtCreator designer has a very similar problem, I can't drag widget from the toolbox until I canceled a drag with ESC in an explorer window. If I delete a widget in the designer the pb reappear and I must cancel a drag again in an explorer window.

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 20 Aug 2013, 20:56 last edited by
                                        #22

                                        Hi,

                                        Can you write a little test program showing the problem ? You could then open a "bug report":http://bugreports.qt-project.org/issues/ with it

                                        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
                                          smartopworks
                                          wrote on 21 Dec 2013, 08:41 last edited by
                                          #23

                                          The issue still exists in QT 5.2 for Ubuntu and it does not only affect QTreeView but also the QPlainTextEdit affected or others.

                                          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