Skip to content

Commit

Permalink
Browser GRASS multilayer map fix
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Feb 19, 2015
1 parent f5315fe commit 09a5283
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.cpp
Expand Up @@ -493,6 +493,7 @@ void QgsDataItem::setParent( QgsDataItem* parent )

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

int i;
Expand Down Expand Up @@ -551,6 +552,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
{
for ( int i = 0; i < items.size(); i++ )
{
Q_ASSERT_X( items[i], "findItem", QString( "item %1 is NULL" ).arg( i ).toAscii() );
QgsDebugMsgLevel( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath, 2 );
if ( items[i]->equal( item ) )
return i;
Expand Down
9 changes: 6 additions & 3 deletions src/providers/grass/qgsgrassprovidermodule.cpp
Expand Up @@ -117,21 +117,24 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
layerType = QgsLayerItem::Polygon;

QString layerPath = mapPath + QDir::separator() + layerName;
if ( layerNames.size() == 1 )
if ( !map )
{
/* This may happen (one layer only) in GRASS 7 with points (no topo layers) */
QgsLayerItem *layer = new QgsLayerItem( this, name + " " + baseLayerName, layerPath, uri, layerType, "grass" );
layer->setState( Populated );
items.append( layer );
}
else if ( map )
else
{
QgsLayerItem *layer = new QgsGrassVectorLayerItem( map, name, baseLayerName, layerPath, uri, layerType, "grass" );
map->addChild( layer );
}
}
if ( layerNames.size() != 1 )
if ( map )
{
map->setState( Populated );
items.append( map );
}
}

QStringList rasterNames = QgsGrass::rasters( mDirPath );
Expand Down

0 comments on commit 09a5283

Please sign in to comment.