Skip to content

Commit

Permalink
handle ogr sublayers with colon
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 24, 2015
1 parent 048aff0 commit 2b703e3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,15 @@ bool QgisApp::addVectorLayers( const QStringList &theLayerQStringList, const QSt
QStringList sublayers = layer->dataProvider()->subLayers();
QStringList elements = sublayers.at( 0 ).split( ":" );
if ( layer->storageType() != "GeoJSON" )
{
while ( elements.size() > 4 )
{
elements[1] += ":" + elements[2];
elements.removeAt( 2 );
}

layer->setLayerName( elements.at( 1 ) );
}
myList << layer;
}
else
Expand Down Expand Up @@ -3320,8 +3328,20 @@ void QgisApp::loadOGRSublayers( QString layertype, QString uri, QStringList list
for ( int i = 0; i < list.size(); i++ )
{
QString composedURI;
QString layerName = list.at( i ).split( ':' ).value( 0 );
QString layerType = list.at( i ).split( ':' ).value( 1 );
QStringList elements = list.at( i ).split( ":" );
while ( elements.size() > 2 )
{
elements[0] += ":" + elements[1];
elements.removeAt( 1 );
}

QString layerName = elements.value( 0 );
QString layerType = elements.value( 1 );
if ( layerType == "any" )
{
layerType = "";
list.removeAt( 1 );
}

if ( layertype != "GRASS" )
{
Expand Down
14 changes: 13 additions & 1 deletion src/gui/qgssublayersdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,16 @@ QStringList QgsSublayersDialog::selectionNames()
count++;
}
}

if ( count > 1 )
{
name += ":" + layersTable->selectedItems().at( i )->text( 3 );
}
else
{
name += ":any";
}

list << name;
}
return list;
Expand All @@ -104,7 +110,13 @@ void QgsSublayersDialog::populateLayerTable( QStringList theList, QString delim
{
foreach ( QString item, theList )
{
layersTable->addTopLevelItem( new QTreeWidgetItem( item.split( delim ) ) );
QStringList elements = item.split( delim );
while ( elements.size() > 4 )
{
elements[1] += delim + elements[2];
elements.removeAt( 2 );
}
layersTable->addTopLevelItem( new QTreeWidgetItem( elements ) );
}

// resize columns
Expand Down

2 comments on commit 2b703e3

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 2b703e3 Jun 25, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I assume) this commit makes QGIS crash at

QString name = list.at( i );
when loading http://download.geofabrik.de/north-america/greenland-latest.osm.pbf

@jef-n
Copy link
Member Author

@jef-n jef-n commented on 2b703e3 Jun 25, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in d875011

Please sign in to comment.