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

Qt-interest Archive, October 2006
Re: QAbstractItemModel lockup during removeRows


Message 1 in thread

Are you able to make a small test application that can cause this crash?

-Benjamin Meyer

On Friday 22 September 2006 18:35, Tobias Rundström wrote:
> Hello,
>
> I have this very strange problem with my AbstractItemModel, it seems
> to (under heavy load) lock up and kill the whole application. The
> backtrace is visible here:
>
> Program received signal SIGTSTP, Stopped (user).
> 0x02c25f4b in QAbstractItemModelPrivate::rowsAboutToBeRemoved ()
> (gdb) bt
> #0  0x02c25f4b in QAbstractItemModelPrivate::rowsAboutToBeRemoved ()
> #1  0x02c2618b in QAbstractItemModel::beginRemoveRows ()
> #2  0x00022a29 in PlaylistModel::handle_change (this=0x2e44d40,
> chg=@0x2e9b720) at playlistmodel.cpp:99
>
> (whole backtrace at: http://30cc58de1e452665.paste.se/)
>
> the relevant code snipplet:
>
> bool
> PlaylistModel::handle_change (const Xmms::Dict &chg)
> {
> 	int32_t change = chg.get<int32_t> ("type");
> 	int32_t pos = 0, npos = 0;
> 	uint32_t id = 0;
> 	try {
> 		pos = chg.get<int32_t> ("position");
> 		id = chg.get<uint32_t> ("id");
> 	} catch (Xmms::no_such_key_error) {
> 	}
>
> 	QModelIndex idx = QModelIndex ();
>
> 	switch (change) {
> 		case XMMS_PLAYLIST_CHANGED_ADD:
> 			beginInsertRows (idx, pos, pos);
> 			m_plist.append (id);
> 			endInsertRows ();
> 			break;
> 		case XMMS_PLAYLIST_CHANGED_INSERT:
> 			beginInsertRows (idx, pos, pos);
> 			m_plist.insert (pos, id);
> 			endInsertRows ();
> 			break;
> 		case XMMS_PLAYLIST_CHANGED_MOVE:
> 			beginRemoveRows (idx, pos, pos);
> 			m_plist.removeAt (pos);
> 			endRemoveRows ();
>
> 			npos = chg.get<uint32_t> ("newposition");
> 			beginInsertRows (idx, npos, npos);
> 			m_plist.insert (npos, id);
> 			endInsertRows ();
> 			break;
> 		case XMMS_PLAYLIST_CHANGED_REMOVE:
> 			beginRemoveRows (idx, pos, pos);
> 			m_plist.removeAt (pos);
> 			endRemoveRows ();
> 			break;
> 		case XMMS_PLAYLIST_CHANGED_SHUFFLE:
> 		case XMMS_PLAYLIST_CHANGED_SORT:
> 		case XMMS_PLAYLIST_CHANGED_CLEAR:
> 			m_client->playlist.list (Xmms::bind (&PlaylistModel::handle_list,
> this));
> 			break;
> 	}
>
> 	return true;
> }
>
> it only happens in CHANGED_REMOVE case above.
>
> I am doing anything wrong with my model or could this be a bug in Qt
> (4.1.4 btw).
>
> Thanks
> Tobias
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]