Skip to content
Permalink
Browse files
Don't return empty layer names for mdal sublayers
  • Loading branch information
nyalldawson committed Jul 12, 2021
1 parent d7d50c5 commit 829ef1f7a48534826959db4c5f1f5b57e508fe1f
Showing with 6 additions and 1 deletion.
  1. +5 −0 src/providers/mdal/qgsmdalprovider.cpp
  2. +1 −1 tests/src/core/testqgsmeshlayer.cpp
@@ -1087,6 +1087,11 @@ QList<QgsProviderSublayerDetails> QgsMdalProviderMetadata::querySublayers( const

// strip the driver name and path from the MDAL uri to get the layer name
details.setName( layerUri.mid( layerUri.indexOf( uri ) + uri.length() + 2 ) );
if ( details.name().isEmpty() )
{
// use file name as layer name if no layer name available from mdal
details.setName( info.completeBaseName() );
}

res << details;

@@ -1606,7 +1606,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers()
res = mdalMetadata->querySublayers( mDataDir + "/quad_and_triangle.2dm" );
QCOMPARE( res.count(), 1 );
QCOMPARE( res.at( 0 ).layerNumber(), 0 );
QCOMPARE( res.at( 0 ).name(), QString( ) );
QCOMPARE( res.at( 0 ).name(), QStringLiteral( "quad_and_triangle" ) );
QCOMPARE( res.at( 0 ).uri(), QStringLiteral( "2DM:\"%1/quad_and_triangle.2dm\"" ).arg( mDataDir ) );
QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "mdal" ) );
QCOMPARE( res.at( 0 ).type(), QgsMapLayerType::MeshLayer );

0 comments on commit 829ef1f

Please sign in to comment.