Skip to content
Permalink
Browse files

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
  • Loading branch information
rblazek
rblazek committed Dec 13, 2006
1 parent 8d0e068 commit 701011c05a89e572b2215c2148a7be905b79aef8
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/plugins/grass/qgsgrassmodel.cpp
@@ -456,6 +456,7 @@ QString QgsGrassModelItem::uri ()

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

if ( insertAt >= 0 )
{
std::cerr << "-> add " << name.ascii() << std::endl;
std::cerr << "insert " << name.ascii() << " at " << insertAt << std::endl;
beginInsertRows( index, insertAt, insertAt );
QgsGrassModelItem *newItem = new QgsGrassModelItem();
item->mChildren.insert( insertAt, newItem );
@@ -739,6 +740,12 @@ QModelIndex QgsGrassModel::index( int row, int column,
{
//std::cerr << "QgsGrassModel::index row = " << row
// << " column = " << column << std::endl;

// It is strange(?) but Qt can call this method with row < 0
// for example if beginInsertRows(,0,0) is called and the first
// item was previously deleted => check if row < 0
// and return empty QModelIndex, but is it correct?
if ( row < 0 ) return QModelIndex ();

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

0 comments on commit 701011c

Please sign in to comment.
You can’t perform that action at this time.