Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Don't try to load algorithms for disabled providers
Fixes #18488
  • Loading branch information
nyalldawson committed Mar 20, 2018
1 parent fadf0b1 commit 9ab4d96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/processing/qgsprocessingprovider.cpp
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/src/analysis/testqgsprocessing.cpp
Expand Up @@ -323,6 +323,12 @@ class DummyProvider : public QgsProcessingProvider
return supportsNonFileOutputs;
}

bool isActive() const override
{
return active;
}

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

Expand Down Expand Up @@ -1079,6 +1085,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 );
Expand Down

0 comments on commit 9ab4d96

Please sign in to comment.