Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, April 2007
Swapping 2 QStandardItem


Message 1 in thread

Hi,

I'm tryinh to swap 2 QStandardItem ( like move up / move down.
It work 2 times, then crash teh app : here is the code i use, and the gdb
backtrace :

Code:
=====

void UIProjectSettingsProxyModel::on_tbUp_clicked()
{
        // got index to move
        QModelIndex i = currentIndex();
        // check if valid to move
        if ( !i.isValid() || i.row() == 0 )
                return;
        // got index row
        int id = i.row();
        //
        QModelIndex iParent = i.parent();
        // move index
        if ( iParent.isValid() )
        {
                QStandardItem* mItem = mProject->itemFromIndex( i );
                QStandardItem* mParentItem = mProject->itemFromIndex( iParent );
                mParentItem->insertRow( mItem->row() -1, mParentItem->takeRow(
mItem->row() ) );
                lvContents->setCurrentIndex( i.parent().child( id -1, 0 ) );
        }
        else
        {
                mProject->insertRow( id -1, mProject->takeRow( id ) ); // crash here, it s
the insert row that is crashing, not the takeRow
                tvScopes->setCurrentIndex( mProxy->mapFromSource( mProject->index( id -1,
0 ) ) );
        }
}

Backtrace:
==========

pasnox@pasnox-desktop:~/Desktop/pparser$ gdb ./parser
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) run
Starting program: /home/pasnox/Desktop/pparser/parser
[Thread debugging using libthread_db enabled]
[New Thread -1223235888 (LWP 17131)]
intersectingStaticSet: row 0 was invalid

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223235888 (LWP 17131)]
0xb7dcad35 in ?? () from /usr/lib/libQtGui.so.4
(gdb) bt
#0  0xb7dcad35 in ?? () from /usr/lib/libQtGui.so.4
#1  0xb7dcd316 in ?? () from /usr/lib/libQtGui.so.4
#2  0xb7dcd5de in ?? () from /usr/lib/libQtGui.so.4
#3  0xb7dcdf13 in QSortFilterProxyModel::qt_metacall ()
from /usr/lib/libQtGui.so.4
#4  0x080767ea in ProjectProxyModel::qt_metacall (this=0x8124f60,
_c=QMetaObject::InvokeMetaMethod, _id=30, _a=0xbf87b184)
    at build/.moc/moc_ProjectProxyModel.cpp:64
#5  0xb781daa8 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#6  0xb781e42a in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#7  0xb783c5cf in QAbstractItemModel::rowsInserted ()
from /usr/lib/libQtCore.so.4
#8  0xb780820b in QAbstractItemModel::endInsertRows ()
from /usr/lib/libQtCore.so.4
#9  0xb7dd2ed0 in ?? () from /usr/lib/libQtGui.so.4
#10 0xb7dd682b in ?? () from /usr/lib/libQtGui.so.4
#11 0xb7dd906c in QStandardItem::insertRow () from /usr/lib/libQtGui.so.4
#12 0xb7dd90c3 in QStandardItemModel::insertRow ()
from /usr/lib/libQtGui.so.4
#13 0x08062d29 in UIProjectSettingsProxyModel::on_tbUp_clicked
(this=0xbf87c4b4) at src/ui/UIProjectSettingsProxyModel.cpp:100
#14 0x08076b2e in UIProjectSettingsProxyModel::qt_metacall (this=0xbf87c4b4,
_c=QMetaObject::InvokeMetaMethod, _id=5, _a=0xbf87b8ec)
    at build/.moc/moc_UIProjectSettingsProxyModel.cpp:84
#15 0xb781daa8 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#16 0xb781dd2f in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#17 0xb7e27e91 in QAbstractButton::clicked () from /usr/lib/libQtGui.so.4
#18 0xb7c46099 in ?? () from /usr/lib/libQtGui.so.4
#19 0xb7c47749 in ?? () from /usr/lib/libQtGui.so.4
#20 0xb7c47962 in QAbstractButton::mouseReleaseEvent ()
from /usr/lib/libQtGui.so.4
#21 0xb7cf369c in QToolButton::mouseReleaseEvent ()
from /usr/lib/libQtGui.so.4
#22 0xb79fde41 in QWidget::event () from /usr/lib/libQtGui.so.4
#23 0xb7c46be5 in QAbstractButton::event () from /usr/lib/libQtGui.so.4
#24 0xb7cf2f84 in QToolButton::event () from /usr/lib/libQtGui.so.4
#25 0xb79b3190 in QApplicationPrivate::notify_helper ()
from /usr/lib/libQtGui.so.4
#26 0xb79b5bf3 in QApplication::notify () from /usr/lib/libQtGui.so.4
#27 0xb7a0e639 in ?? () from /usr/lib/libQtGui.so.4
#28 0xb7a0d1c8 in QApplication::x11ProcessEvent ()
from /usr/lib/libQtGui.so.4
#29 0xb7a31f34 in ?? () from /usr/lib/libQtGui.so.4
#30 0xb7393df2 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#31 0xb7396dcf in ?? () from /usr/lib/libglib-2.0.so.0
#32 0x080aac90 in ?? ()
#33 0x00000000 in ?? ()

Thanks, P@sNox,

-- 
 [ signature omitted ]