Skip to content

Commit 09a5283

Browse files
committed
Browser GRASS multilayer map fix
1 parent f5315fe commit 09a5283

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/qgsdataitem.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ void QgsDataItem::setParent( QgsDataItem* parent )
493493

494494
void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
495495
{
496+
Q_ASSERT( child );
496497
QgsDebugMsg( QString( "path = %1 add child #%2 - %3 - %4" ).arg( mPath ).arg( mChildren.size() ).arg( child->mName ).arg( child->mType ) );
497498

498499
int i;
@@ -551,6 +552,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
551552
{
552553
for ( int i = 0; i < items.size(); i++ )
553554
{
555+
Q_ASSERT_X( items[i], "findItem", QString( "item %1 is NULL" ).arg( i ).toAscii() );
554556
QgsDebugMsgLevel( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath, 2 );
555557
if ( items[i]->equal( item ) )
556558
return i;

src/providers/grass/qgsgrassprovidermodule.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,24 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
117117
layerType = QgsLayerItem::Polygon;
118118

119119
QString layerPath = mapPath + QDir::separator() + layerName;
120-
if ( layerNames.size() == 1 )
120+
if ( !map )
121121
{
122122
/* This may happen (one layer only) in GRASS 7 with points (no topo layers) */
123123
QgsLayerItem *layer = new QgsLayerItem( this, name + " " + baseLayerName, layerPath, uri, layerType, "grass" );
124124
layer->setState( Populated );
125125
items.append( layer );
126126
}
127-
else if ( map )
127+
else
128128
{
129129
QgsLayerItem *layer = new QgsGrassVectorLayerItem( map, name, baseLayerName, layerPath, uri, layerType, "grass" );
130130
map->addChild( layer );
131131
}
132132
}
133-
if ( layerNames.size() != 1 )
133+
if ( map )
134+
{
135+
map->setState( Populated );
134136
items.append( map );
137+
}
135138
}
136139

137140
QStringList rasterNames = QgsGrass::rasters( mDirPath );

0 commit comments

Comments
 (0)