Skip to content

Commit 701011c

Browse files
author
rblazek
committedDec 13, 2006
fixed ticket 437, crash when the first item is deleted and recreated
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6250 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8d0e068 commit 701011c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/plugins/grass/qgsgrassmodel.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ QString QgsGrassModelItem::uri ()
456456

457457
QgsGrassModelItem *QgsGrassModelItem::child ( int i )
458458
{
459+
Q_ASSERT(i >= 0 );
459460
Q_ASSERT(i < mChildren.size());
460461
//return &(mChildren[i]);
461462
return mChildren[i];
@@ -592,7 +593,7 @@ void QgsGrassModel::addItems(QgsGrassModelItem *item, QStringList list, int type
592593

593594
if ( insertAt >= 0 )
594595
{
595-
std::cerr << "-> add " << name.ascii() << std::endl;
596+
std::cerr << "insert " << name.ascii() << " at " << insertAt << std::endl;
596597
beginInsertRows( index, insertAt, insertAt );
597598
QgsGrassModelItem *newItem = new QgsGrassModelItem();
598599
item->mChildren.insert( insertAt, newItem );
@@ -739,6 +740,12 @@ QModelIndex QgsGrassModel::index( int row, int column,
739740
{
740741
//std::cerr << "QgsGrassModel::index row = " << row
741742
// << " column = " << column << std::endl;
743+
744+
// It is strange(?) but Qt can call this method with row < 0
745+
// for example if beginInsertRows(,0,0) is called and the first
746+
// item was previously deleted => check if row < 0
747+
// and return empty QModelIndex, but is it correct?
748+
if ( row < 0 ) return QModelIndex ();
742749

743750
QgsGrassModelItem *item;
744751
if (!parent.isValid()) {

0 commit comments

Comments
 (0)