Skip to content

Commit

Permalink
[processing] Don't try to load algorithms for disabled providers
Browse files Browse the repository at this point in the history
Fixes #18488

(cherry-picked from 9ab4d96)
  • Loading branch information
nyalldawson committed Mar 20, 2018
1 parent e70982a commit 21605a1
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 @@ -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;

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 21605a1

Please sign in to comment.