Skip to content

Commit

Permalink
Make QgsProcessingContext::temporaryLayerStore() return a pointer to …
Browse files Browse the repository at this point in the history
…store
  • Loading branch information
nyalldawson committed May 2, 2017
1 parent d2ce9c6 commit 32e06f4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/core/processing/qgsprocessingcontext.sip
Expand Up @@ -75,7 +75,7 @@ class QgsProcessingContext
Sets the expression ``context``.
%End

QgsMapLayerStore &temporaryLayerStore();
QgsMapLayerStore *temporaryLayerStore();
%Docstring
Returns a reference to the layer store used for storing temporary layers during
algorithm execution.
Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/qgsprocessingcontext.h
Expand Up @@ -93,7 +93,7 @@ class CORE_EXPORT QgsProcessingContext
* Returns a reference to the layer store used for storing temporary layers during
* algorithm execution.
*/
QgsMapLayerStore &temporaryLayerStore() { return tempLayerStore; }
QgsMapLayerStore *temporaryLayerStore() { return &tempLayerStore; }

/**
* Returns the behavior used for checking invalid geometries in input layers.
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingutils.cpp
Expand Up @@ -183,7 +183,7 @@ QgsMapLayer *QgsProcessingUtils::mapLayerFromString( const QString &string, QgsP
return layer;
}

layer = mapLayerFromStore( string, &context.temporaryLayerStore() );
layer = mapLayerFromStore( string, context.temporaryLayerStore() );
if ( layer )
return layer;

Expand All @@ -193,7 +193,7 @@ QgsMapLayer *QgsProcessingUtils::mapLayerFromString( const QString &string, QgsP
layer = loadMapLayerFromString( string );
if ( layer )
{
context.temporaryLayerStore().addMapLayer( layer );
context.temporaryLayerStore()->addMapLayer( layer );
return layer;
}
else
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsprocessing.cpp
Expand Up @@ -438,7 +438,7 @@ void TestQgsProcessing::mapLayerFromString()
// check that layers in context temporary store are used
QgsVectorLayer *v5 = new QgsVectorLayer( "Polygon", "V5", "memory" );
QgsVectorLayer *v6 = new QgsVectorLayer( "Point", "v6", "memory" );
c.temporaryLayerStore().addMapLayers( QList<QgsMapLayer *>() << v5 << v6 );
c.temporaryLayerStore()->addMapLayers( QList<QgsMapLayer *>() << v5 << v6 );
QCOMPARE( QgsProcessingUtils::mapLayerFromString( "V5", c ), v5 );
QCOMPARE( QgsProcessingUtils::mapLayerFromString( "v6", c ), v6 );
QCOMPARE( QgsProcessingUtils::mapLayerFromString( v5->id(), c ), v5 );
Expand All @@ -455,7 +455,7 @@ void TestQgsProcessing::mapLayerFromString()
QVERIFY( loadedLayer->isValid() );
QCOMPARE( loadedLayer->type(), QgsMapLayer::RasterLayer );
// should now be in temporary store
QCOMPARE( c.temporaryLayerStore().mapLayer( loadedLayer->id() ), loadedLayer );
QCOMPARE( c.temporaryLayerStore()->mapLayer( loadedLayer->id() ), loadedLayer );

// since it's now in temporary store, should be accessible even if we deny loading new layers
QCOMPARE( QgsProcessingUtils::mapLayerFromString( newRaster, c, false ), loadedLayer );
Expand Down

0 comments on commit 32e06f4

Please sign in to comment.