File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
src/core/processing/models Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -930,6 +930,16 @@ bool QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( const QList<int>
930
930
outputType == QgsProcessing::TypeVectorPolygon ) ) );
931
931
}
932
932
933
+ void QgsProcessingModelAlgorithm::reattachAlgorithms () const
934
+ {
935
+ QMap< QString, QgsProcessingModelChildAlgorithm >::const_iterator childIt = mChildAlgorithms .constBegin ();
936
+ for ( ; childIt != mChildAlgorithms .constEnd (); ++childIt )
937
+ {
938
+ if ( !childIt->algorithm () )
939
+ childIt->reattach ();
940
+ }
941
+ }
942
+
933
943
bool QgsProcessingModelAlgorithm::toFile ( const QString &path ) const
934
944
{
935
945
QDomDocument doc = QDomDocument ( QStringLiteral ( " model" ) );
@@ -1182,6 +1192,7 @@ QSet< QString > QgsProcessingModelAlgorithm::dependsOnChildAlgorithms( const QSt
1182
1192
1183
1193
bool QgsProcessingModelAlgorithm::canExecute ( QString *errorMessage ) const
1184
1194
{
1195
+ reattachAlgorithms ();
1185
1196
QMap< QString, QgsProcessingModelChildAlgorithm >::const_iterator childIt = mChildAlgorithms .constBegin ();
1186
1197
for ( ; childIt != mChildAlgorithms .constEnd (); ++childIt )
1187
1198
{
Original file line number Diff line number Diff line change @@ -416,6 +416,11 @@ class CORE_EXPORT QgsProcessingModelAlgorithm : public QgsProcessingAlgorithm
416
416
*/
417
417
static bool vectorOutputIsCompatibleType ( const QList<int > &acceptableDataTypes, QgsProcessing::SourceType outputType );
418
418
419
+ /* *
420
+ * Tries to reattach all child algorithms to their linked algorithms.
421
+ */
422
+ void reattachAlgorithms () const ;
423
+
419
424
friend class TestQgsProcessing ;
420
425
};
421
426
Original file line number Diff line number Diff line change @@ -5750,7 +5750,14 @@ void TestQgsProcessing::modelerAlgorithm()
5750
5750
alg2.addChildAlgorithm ( c6 );
5751
5751
QVERIFY ( !alg2.canExecute () );
5752
5752
5753
-
5753
+ // test that children are re-attached before testing for canExecute
5754
+ QgsProcessingModelAlgorithm alg2a ( " test" , " testGroup" );
5755
+ QgsProcessingModelChildAlgorithm c5a;
5756
+ c5a.setAlgorithmId ( " native:centroids" );
5757
+ alg2a.addChildAlgorithm ( c5a );
5758
+ // simulate initially missing provider or algorithm (e.g. another model as a child algorithm)
5759
+ alg2a.mChildAlgorithms .begin ().value ().mAlgorithm .reset ();
5760
+ QVERIFY ( alg2a.canExecute () );
5754
5761
5755
5762
// dependencies
5756
5763
QgsProcessingModelAlgorithm alg3 ( " test" , " testGroup" );
You can’t perform that action at this time.
0 commit comments