diff --git a/python/PyQt6/core/auto_generated/processing/qgsprocessingregistry.sip.in b/python/PyQt6/core/auto_generated/processing/qgsprocessingregistry.sip.in index 2a1b6fea7d3..a4341672b30 100644 --- a/python/PyQt6/core/auto_generated/processing/qgsprocessingregistry.sip.in +++ b/python/PyQt6/core/auto_generated/processing/qgsprocessingregistry.sip.in @@ -87,7 +87,7 @@ Returns ``False`` if the provider could not be removed (eg provider does not exi .. seealso:: :py:func:`addProvider` %End - QgsProcessingProvider *providerById( const QString &id ) /HoldGIL/; + QgsProcessingProvider *providerById( const QString &id ) const /HoldGIL/; %Docstring Returns a matching provider by provider ID. %End diff --git a/python/core/auto_generated/processing/qgsprocessingregistry.sip.in b/python/core/auto_generated/processing/qgsprocessingregistry.sip.in index 2e100885d9e..65d37a5e796 100644 --- a/python/core/auto_generated/processing/qgsprocessingregistry.sip.in +++ b/python/core/auto_generated/processing/qgsprocessingregistry.sip.in @@ -87,7 +87,7 @@ Returns ``False`` if the provider could not be removed (eg provider does not exi .. seealso:: :py:func:`addProvider` %End - QgsProcessingProvider *providerById( const QString &id ) /HoldGIL/; + QgsProcessingProvider *providerById( const QString &id ) const /HoldGIL/; %Docstring Returns a matching provider by provider ID. %End diff --git a/python/plugins/grassprovider/Grass7AlgorithmProvider.py b/python/plugins/grassprovider/Grass7AlgorithmProvider.py index 5b6687442b9..a18511aa7fe 100644 --- a/python/plugins/grassprovider/Grass7AlgorithmProvider.py +++ b/python/plugins/grassprovider/Grass7AlgorithmProvider.py @@ -139,7 +139,7 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): return 'GRASS GIS ({})'.format(version) if version is not None else "GRASS GIS" def id(self): - return 'grass7' + return 'grass' def helpId(self): return 'grass7' diff --git a/src/core/processing/qgsprocessingregistry.cpp b/src/core/processing/qgsprocessingregistry.cpp index 9e5e725801a..1a5495b9afc 100644 --- a/src/core/processing/qgsprocessingregistry.cpp +++ b/src/core/processing/qgsprocessingregistry.cpp @@ -103,7 +103,7 @@ bool QgsProcessingRegistry::addProvider( QgsProcessingProvider *provider ) if ( !provider ) return false; - if ( mProviders.contains( provider->id() ) ) + if ( providerById( provider->id() ) ) { QgsLogger::warning( QStringLiteral( "Duplicate provider %1 registered" ).arg( provider->id() ) ); delete provider; @@ -156,9 +156,17 @@ bool QgsProcessingRegistry::removeProvider( const QString &providerId ) return removeProvider( p ); } -QgsProcessingProvider *QgsProcessingRegistry::providerById( const QString &id ) +QgsProcessingProvider *QgsProcessingRegistry::providerById( const QString &id ) const { - return mProviders.value( id, nullptr ); + auto it = mProviders.constFind( id ); + if ( it != mProviders.constEnd() ) + return it.value(); + + // transparently map old references to "grass7" provider to "grass" provider + if ( id.compare( QLatin1String( "grass7" ), Qt::CaseInsensitive ) == 0 ) + return providerById( QStringLiteral( "grass" ) ); + + return nullptr; } QList< const QgsProcessingAlgorithm * > QgsProcessingRegistry::algorithms() const @@ -201,7 +209,7 @@ const QgsProcessingAlgorithm *QgsProcessingRegistry::algorithmById( const QStrin const QRegularExpressionMatch match = reSplitProviderId.match( id ); if ( match.hasMatch() ) { - if ( QgsProcessingProvider *provider = mProviders.value( match.captured( 1 ) ) ) + if ( QgsProcessingProvider *provider = providerById( match.captured( 1 ) ) ) { if ( const QgsProcessingAlgorithm *algorithm = provider->algorithm( match.captured( 2 ) ) ) return algorithm; diff --git a/src/core/processing/qgsprocessingregistry.h b/src/core/processing/qgsprocessingregistry.h index 3ef54837652..478ed58f206 100644 --- a/src/core/processing/qgsprocessingregistry.h +++ b/src/core/processing/qgsprocessingregistry.h @@ -105,7 +105,7 @@ class CORE_EXPORT QgsProcessingRegistry : public QObject /** * Returns a matching provider by provider ID. */ - QgsProcessingProvider *providerById( const QString &id ) SIP_HOLDGIL; + QgsProcessingProvider *providerById( const QString &id ) const SIP_HOLDGIL; /** * Returns a list of all available algorithms from registered providers.