mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
strore layer id instead of pointer to layer
This commit is contained in:
parent
ab5f9d0539
commit
4d9b3b2b80
@ -63,19 +63,21 @@ void QgsApplyLayerStyleAlgorithm::initAlgorithm( const QVariantMap & )
|
||||
|
||||
bool QgsApplyLayerStyleAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback * )
|
||||
{
|
||||
mLayer.reset( parameterAsLayer( parameters, QStringLiteral( "INPUT" ), context ) );
|
||||
QgsMapLayer *layer = parameterAsLayer( parameters, QStringLiteral( "INPUT" ), context );
|
||||
QString style = parameterAsFile( parameters, QStringLiteral( "STYLE" ), context );
|
||||
|
||||
if ( !mLayer )
|
||||
if ( !layer )
|
||||
throw QgsProcessingException( QObject::tr( "Invalid input layer" ) );
|
||||
|
||||
mLayerId = layer->id();
|
||||
|
||||
bool ok = false;
|
||||
QString msg = mLayer->loadNamedStyle( style, ok );
|
||||
QString msg = layer->loadNamedStyle( style, ok );
|
||||
if ( !ok )
|
||||
{
|
||||
throw QgsProcessingException( QObject::tr( "Failed to apply style. Error: %1" ).arg( msg ) );
|
||||
}
|
||||
mLayer->triggerRepaint();
|
||||
layer->triggerRepaint();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -86,7 +88,7 @@ QVariantMap QgsApplyLayerStyleAlgorithm::processAlgorithm( const QVariantMap &pa
|
||||
Q_UNUSED( context );
|
||||
|
||||
QVariantMap results;
|
||||
results.insert( QStringLiteral( "OUTPUT" ), mLayer->id() );
|
||||
results.insert( QStringLiteral( "OUTPUT" ), mLayerId );
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class QgsApplyLayerStyleAlgorithm : public QgsProcessingAlgorithm
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr< QgsMapLayer > mLayer;
|
||||
QString mLayerId;
|
||||
};
|
||||
|
||||
///@endcond PRIVATE
|
||||
|
Loading…
x
Reference in New Issue
Block a user