[Qt-interest] removeRows() crash.
phil prentice
philp.cheer at talktalk.net
Fri Apr 24 00:47:35 CEST 2009
Hi Stephen
Thanks for that...no I did'nt notice that. In fact just for interest I
added the check in my selectionCommand() method and I dont appear to get
anymore crashes!! The code now looks like:-
QItemSelectionModel::SelectionFlags BottomFacilityListView::selectionCommand
( const QModelIndex & index, const QEvent *event) const
{
/*
If item is present under mouse & we have a mouse button press then check
if mouse is positioned inside facility arrow. Also check if ctrl+Alt is
pressed for adding selections to the current selection list.
*/
if ((index.isValid()) && (event != NULL) &&
(event->type() == QEvent::MouseButtonPress))
{
const QMouseEvent *mouseEvent = static_cast<const QMouseEvent*>(event);
if(mouseEvent->button() == Qt::LeftButton)
{
if((mouseEvent->y() > 20) && (mouseEvent->y() < 40))
/* I know; should be enums. */
{
QItemSelectionModel *selModel = selectionModel();
if(m_addSelection == false)
{
selModel->clear(); /* Clear all selections. */
}
return QItemSelectionModel::Toggle;
/* Add to current selection list. */
}
}
}
return QItemSelectionModel::NoUpdate;
}
Thanks for noticing that....just need to understand...
why is selectionCommand being called with event = NULL??
At least I have a work-around(??) for now. Any ideas on how best I could
investigate further? I guess a cut down in code might be called for.
Your help much appreciated; Thanks again
Phil
On Thursday 23 April 2009 18:44, Stephen Jackson wrote:
> On 23/04/09, phil prentice wrote:
> > The end of the stack trace from the debugger shows:-
> >
> > /* CRASH!!!! */
> > #0 0x0805bf1a in QEvent::type (this=0x0)
> > at /usr/local/Trolltech/Qt-4.2.1/include/QtCore/qcoreevent.h:221
> > #1 0x0805b993 in BottomFacilityListView::selectionCommand
> > (this=0x85119a0, index=@0xbfb8f86c, event=0x0) at
> > bottomFacilityListView.cpp:79 #2 0x00affe8e in
> > QAbstractItemView::setCurrentIndex (this=0x85119a0, index=@0xbfb8f86c) at
> > itemviews/qabstractitemview.cpp:767
>
> First things first. In BottomFacilityListView::selectionCommand you
> are calling event->type() but event is a null pointer. Does this get
> you anywhere?
>
> Regards,
>
> Stephen Jackson
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list