PDA

View Full Version : QSortFilterProxyModel crashed at mapToSource function in Qt 4.8.4



lovehouye
16th July 2013, 12:00
I use QFileSystemModel to show the directory and files. Also own class FileListModel inherits QSortFilterProxyModel. I want to only show the "html" files in my QTreeView.

I added a SLOT to connect with doubleClicked(QModelIndex) signal. In the slot:



QModel index = proxyModel->mapToSource(currentIndex);
if(!index.isValid())
{
return;
}


But if I click the QTreeView items quickly, it maybe crash at


proxyModel->mapToSource(currentIndex);


I don't know why.

And here is the call stack and screenshots:
92949295



> QtGuid4.dll!QSortFilterProxyModelPrivate::index_to _iterator(const QModelIndex & proxy_index) Line 193 + 0x8 bytes C++
QtGuid4.dll!QSortFilterProxyModelPrivate::proxy_to _source(const QModelIndex & proxy_index) Line 369 C++
QtGuid4.dll!QSortFilterProxyModel::mapToSource(con st QModelIndex & proxyIndex) Line 2519 + 0x10 bytes C++
TBXXA.exe!MainWindow::onSaveBtnClicked() Line 341 + 0x2a bytes C++
TBXXA.exe!MainWindow::onTreeViewDoubleClicked(cons t QModelIndex & index) Line 452 C++
TBXXA.exe!MainWindow::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 84 C++
QtCored4.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3539 + 0x2e bytes C++
QtGuid4.dll!QAbstractItemView::doubleClicked(const QModelIndex & _t1) Line 355 + 0x15 bytes C++
QtGuid4.dll!QTreeView::mouseDoubleClickEvent(QMous eEvent * event) Line 1878 C++
QtGuid4.dll!QWidget::event(QEvent * event) Line 8380 C++
QtGuid4.dll!QFrame::event(QEvent * e) Line 557 + 0xc bytes C++
QtGuid4.dll!QAbstractScrollArea::viewportEvent(QEv ent * e) Line 1043 + 0xc bytes C++
QtGuid4.dll!QAbstractItemView::viewportEvent(QEven t * event) Line 1645 C++
QtGuid4.dll!QTreeView::viewportEvent(QEvent * event) Line 1258 C++
QtGuid4.dll!QAbstractScrollAreaPrivate::viewportEv ent(QEvent * event) Line 100 + 0x28 bytes C++
QtGuid4.dll!QAbstractScrollAreaFilter::eventFilter (QObject * o, QEvent * e) Line 116 + 0x29 bytes C++
QtCored4.dll!QCoreApplicationPrivate::sendThroughO bjectEventFilters(QObject * receiver, QEvent * event) Line 1056 + 0x15 bytes C++
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject * receiver, QEvent * e) Line 4558 + 0x11 bytes C++
QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4105 + 0x2f bytes C++
QtCored4.dll!QCoreApplication::notifyInternal(QObj ect * receiver, QEvent * event) Line 946 + 0x15 bytes C++
QtCored4.dll!QCoreApplication::sendSpontaneousEven t(QObject * receiver, QEvent * event) Line 234 + 0x38 bytes C++
QtGuid4.dll!QApplicationPrivate::sendMouseEvent(QW idget * receiver, QMouseEvent * event, QWidget * alienWidget, QWidget * nativeWidget, QWidget * * buttonDown, QPointer<QWidget> & lastMouseReceiver, bool spontaneous) Line 3171 + 0xe bytes C++
QtGuid4.dll!QETWidget::translateMouseEvent(const tagMSG & msg) Line 3365 + 0x2a bytes C++
QtGuid4.dll!QtWndProc(HWND__ * hwnd, unsigned int message, unsigned int wParam, long lParam) Line 1698 + 0xc bytes C++
user32.dll!7689c4e7()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!7689c5e7()
user32.dll!7689c590()
user32.dll!7689cc19()
user32.dll!7689cc70()
QtCored4.dll!QEventDispatcherWin32::processEvents( QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 810 C++
QtGuid4.dll!QGuiEventDispatcherWin32::processEvent s(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1204 + 0x15 bytes C++
QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 150 C++
QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 204 + 0x2d bytes C++
QtCored4.dll!QCoreApplication::exec() Line 1218 + 0x15 bytes C++
QtGuid4.dll!QApplication::exec() Line 3824 C++
TBXXA.exe!main(int argc, char * * argv) Line 32 + 0x6 bytes C++
TBXXA.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131 + 0x12 bytes C++
TBXXA.exe!__tmainCRTStartup() Line 547 + 0x2c bytes C
TBXXA.exe!WinMainCRTStartup() Line 371 C
kernel32.dll!75fbed6c()
ntdll.dll!76e6377b()
ntdll.dll!76e6374e()

rockdemon
18th July 2013, 11:26
I've had this working. Would need to see some code though to know more of what you're doing.

Added after 42 minutes:

I'm guessing that your model is returning NULL or an invalid item for the passed index?