Make QgsProcessingContext::temporaryLayerStore() return a pointer to store

This commit is contained in:
Nyall Dawson 2017-05-03 07:49:32 +10:00
parent d2ce9c69b1
commit 32e06f486a
4 changed files with 6 additions and 6 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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;
@ -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

View File

@ -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 );
@ -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 );