|
|
Hi,
I'm using the QTreeView in qt4, and am running into an
assertion (trace posted at end of message). I have a
function that gets called when a user activates an
item, that potentially resets the model (think double
clicking on a directory in a custom file browser)
which seems to invalidate an internal index causing
the assertion.
Here's where it's happening (XXX comments are mine):
qtreeview.cpp:
void QTreeView::mouseDoubleClickEvent(QMouseEvent *e)
{
...
i = d->item(e->y());
if (i == -1)
return;
// signal handlers may change the model
QModelIndex index = d->viewItems.at(i).index;
int column = d->header->logicalIndexAt(e->x());
QPersistentModelIndex persistent =
index.sibling(index.row(), column);
emit doubleClicked(persistent);
if (edit(persistent, DoubleClicked, e) || state()
!= NoState)
return; // the double click triggered editing
if
(!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick))
// XXX model may be reset, "viewItems" now
undefined?
emit activated(persistent);
// XXX "i" is about to access the old "viewItems"
and go boom.
if (d->itemsExpandable &&
model()->hasChildren(d->viewItems.at(i).index)) {
...
}
Any thoughts?
Here's the trace (FreeBSD 5.4, Qt 4.0.1):
#0 0x8927137b in kill () from /lib/libc.so.5
#1 0x89207b8f in raise () from
/usr/lib/libpthread.so.1
#2 0x892d8c1b in abort () from /lib/libc.so.5
#3 0x88ed1c08 in qt_message_output
(msgType=QtFatalMsg,
buf=0xbfbfbd10 "ASSERT failure in QVector<T>::at:
\"index out of range\", file
../../include/QtCore/../../src/corelib/tools/qvector.h,
line 210")
at global/qglobal.cpp:1784
#4 0x88ed2079 in qFatal (
msg=0x88fa3d80 "ASSERT failure in %s: \"%s\", file
%s, line %d")
at global/qglobal.cpp:2000
#5 0x88ed17e2 in qt_assert_x (where=0x88af66f6
"QVector<T>::at",
what=0x88af66e3 "index out of range",
file=0x88af66ac
"../../include/QtCore/../../src/corelib/tools/qvector.h",
line=210) at global/qglobal.cpp:1559
#6 0x88a7b9a3 in QVector<QTreeViewItem>::at
(this=0x81ab1b8, i=0)
at qvector.h:210
#7 0x88a75fdc in QTreeView::mouseDoubleClickEvent
(this=0x816f820,
e=0xbfbfe320) at itemviews/qtreeview.cpp:840
#8 0x88731b45 in QWidget::event (this=0x816f820,
e=0xbfbfe320)
at kernel/qwidget.cpp:4841
#9 0x889f42a6 in QAbstractScrollArea::viewportEvent
(this=0x816f820,
e=0xbfbfe320) at
widgets/qabstractscrollarea.cpp:397
#10 0x88a4e022 in QAbstractItemView::viewportEvent
(this=0x816f820,
event=0xbfbfe320) at
itemviews/qabstractitemview.cpp:906
#11 0x889f4aab in
QAbstractScrollAreaPrivate::viewportEvent
(this=0x81ab000,
e=0xbfbfe320) at
widgets/qabstractscrollarea.cpp:89
#12 0x889f2e28 in QAbstractScrollAreaHelper::event
(this=0x816fd20,
e=0xbfbfe320) at
widgets/qabstractscrollarea.cpp:100
#13 0x886e8a19 in QApplicationPrivate::notify_helper
(this=0x8050100,
receiver=0x816fd20, e=0xbfbfe320) at
kernel/qapplication.cpp:2988
#14 0x886e7aef in QApplication::notify
(this=0xbfbfe80c, receiver=0x816fd20,
e=0xbfbfe320) at kernel/qapplication.cpp:2772
#15 0x8830d5cd in
QCoreApplication::sendSpontaneousEvent
(receiver=0x816fd20,
event=0xbfbfe320) at qcoreapplication.h:174
#16 0x88746d55 in QETWidget::translateMouseEvent
(this=0x816fd20,
event=0xbfbfe600) at
kernel/qapplication_x11.cpp:3498
#17 0x887443e3 in QApplication::x11ProcessEvent
(this=0xbfbfe80c,
event=0xbfbfe600) at
kernel/qapplication_x11.cpp:2653
#18 0x8875ceff in QEventDispatcherX11::processEvents
(this=0x804f520, flags=
{i = 4}) at kernel/qeventdispatcher_x11.cpp:112
#19 0x88f6befd in QEventLoop::processEvents
(this=0xbfbfe780, flags={i = 4})
---Type <return> to continue, or q <return> to quit---
at kernel/qeventloop.cpp:111
#20 0x88f6bfe6 in QEventLoop::exec (this=0xbfbfe780,
flags={i = 0})
at kernel/qeventloop.cpp:151
#21 0x88f6f99c in QCoreApplication::exec () at
kernel/qcoreapplication.cpp:638
#22 0x886e71d3 in QApplication::exec () at
kernel/qapplication.cpp:2587
#23 0x880c9c5f in djGuiBaseApp::exec (this=0xbfbfe80c)
at guiApp.cxx:169
#24 0x0804a948 in main (argc=1, argv=0xbfbfe8fc) at
fileBrowser.cxx:45
|
|