PDA

View Full Version : QtCored5.dll crashes when "dragging" TableItems



unsortedTable
8th January 2019, 15:30
Hi,
I've subclassed QAbstractTableModel and reimplemented the neccessary functions for it. It contains a 2-dimensional-Array of QTableWidgetItems* that hold the Data to be displayed.
The QTableView, that holds the Model gets modified with "setSelectionBehavior(QAbstractItemView::SelectRows )" and "setSelectionMode(QAbstractItemView::SingleSelectio n)".
My biggest concern right now is the "dragging"(holding left click on an Item and moving the Mouse/Cursor). Even if the cursor only moves 1 pixel the application crashes with an exception in Qt5Cored.dll (Accessviolation).
This Crash does not occur, when i comment out the SingleSelection.

I've also disabled every drag-drop option I could find (setDragDropMode, setDragEnabled, setDragDropoverwriteMode, viewport()->setAcceptDrops()) though, that didn't help.
My Question now is: What function could Qt also try while "dragging" a QTableWidgetItem? What can I change, that the crash won't occur while stil having SingleSelection?

d_stranz
8th January 2019, 16:16
The crash is probably due to your code making a call using a null or uninitialized pointer, writing or reading past the end of an array and causing memory corruption, trying to use a pointer to an object that has already been deletedetc.. If you aren't checking to see that pointers are valid before using them or checking that array accesses are within bounds, it will cause an access violation if the pointer is not valid.

It is simply a coincidence that the crash occurs in QtCore5.dll. It may not even have anything to do with drag and drop either; whatever has been done earlier to corrupt memory might not appear until that point. Something you are doing in your code is causing the crash, not Qt.

unsortedTable
8th January 2019, 16:40
Don't know if this is a duplicate Messege from me, but the firstone seemingly dissappeard.
I'm not 100% certain, that I don't do something terribly wrong with the pointers. Still the problem needs to be linked with "setSelectionBehavior(QAbstractItemView::SingleSele ction)" because if that line isn't in the Code, it won't crash.

d_stranz
8th January 2019, 17:15
Then you will have to build your application in Debug mode and use the debugger to examine what is happening when the crash occurs. Look at the call stack and see where the calls leave your code and go into Qt DLL code. Put a breakpoint at the beginning of your method, re-run the code and step through it line-by-line when it hits the brakpoint. Examine every pointer and variable to make sure it is what you expect it to be, both local variables (in the method) and member variables of the class your call is in.

unsortedTable
9th January 2019, 14:19
I've tried it out for some time, but didn't get very far. Some files like qcoreapplication.cpp couldn't be opened. The last line where i could set the breakpoint in my code was a.exec(). The last not atomic part of the code that i could find was "sendSpontaeousEvent".
Now I've given up and reverted back to an old point of my software with an QTableWidget and I'll work around the differences between sorted frontend and backend.
Anyway, thank you very much for trying to help me, but I'll guess the error is one step above my league(or stupidity ^^).

d_stranz
9th January 2019, 16:11
It is pretty hard to give anything more than suggestions about what could be wrong based on just a description of the problem. Without source code, all we can do is guess.

anda_skoa
11th January 2019, 18:38
I've subclassed QAbstractTableModel and reimplemented the neccessary functions for it. It contains a 2-dimensional-Array of QTableWidgetItems* that hold the Data to be displayed.


That is a contradiction.

You are either using a QAbstractTableModel derived class or QTableWidgetItems.

Cheers,
_