Skip to content
Permalink
Browse files

[processing] Don't try to load algorithms for disabled providers

Fixes #18488

(cherry-picked from 9ab4d96)
  • Loading branch information
nyalldawson committed Mar 20, 2018
1 parent e70982a commit 21605a1a4eb367dbbb943c30b624a9262f716d12
Showing with 21 additions and 2 deletions.
  1. +5 −2 src/core/processing/qgsprocessingprovider.cpp
  2. +16 −0 tests/src/analysis/testqgsprocessing.cpp
@@ -60,8 +60,11 @@ void QgsProcessingProvider::refreshAlgorithms()
{
qDeleteAll( mAlgorithms );
mAlgorithms.clear();
loadAlgorithms();
emit algorithmsLoaded();
if ( isActive() )
{
loadAlgorithms();
emit algorithmsLoaded();
}
}

QList<const QgsProcessingAlgorithm *> QgsProcessingProvider::algorithms() const
@@ -322,6 +322,12 @@ class DummyProvider : public QgsProcessingProvider
return supportsNonFileOutputs;
}

bool isActive() const override
{
return active;
}

bool active = true;
bool *unloaded = nullptr;
bool supportsNonFileOutputs = false;

@@ -972,6 +978,16 @@ void TestQgsProcessing::algorithm()
QCOMPARE( providerRefreshed.count(), 2 + i );
}

// inactive provider, should not load algorithms
p->active = false;
p->refreshAlgorithms();
QCOMPARE( providerRefreshed.count(), 3 );
QVERIFY( p->algorithms().empty() );
p->active = true;
p->refreshAlgorithms();
QCOMPARE( providerRefreshed.count(), 4 );
QVERIFY( !p->algorithms().empty() );

QgsProcessingRegistry r;
r.addProvider( p );
QCOMPARE( r.algorithms().size(), 2 );

0 comments on commit 21605a1

Please sign in to comment.
You can’t perform that action at this time.