Skip to content

Commit

Permalink
Merge pull request #47161 from nyalldawson/model_from_file_return
Browse files Browse the repository at this point in the history
Fix incorrect return code from QgsProcessingModelAlgorithm::fromFile when file does not exist
  • Loading branch information
alexbruy committed Feb 3, 2022
2 parents 00daed0 + 12953ca commit 3ae5e9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/processing/models/qgsprocessingmodelalgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,10 @@ bool QgsProcessingModelAlgorithm::fromFile( const QString &path )

file.close();
}
else
{
return false;
}

QVariant props = QgsXmlUtils::readVariant( doc.firstChildElement() );
return loadVariant( props );
Expand Down
5 changes: 4 additions & 1 deletion tests/src/analysis/testqgsprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,8 @@ void TestQgsProcessing::createFeatureSink()
QCOMPARE( f.geometry().asWkt( 1 ), QStringLiteral( "PointZ (1 2 3)" ) );
QVERIFY( it.nextFeature( f ) );
QCOMPARE( f.attributes().at( 1 ).toString(), QStringLiteral( "val2" ) );
QCOMPARE( f.geometry().asWkt( 0 ), QStringLiteral( "Point (-10199761 -4017774)" ) );
QGSCOMPARENEAR( f.geometry().asPoint().x(), -10199761, 10 );
QGSCOMPARENEAR( f.geometry().asPoint().y(), -4017774, 10 );
delete layer;
//windows style path
destination = "d:\\temp\\create_feature_sink.tab";
Expand Down Expand Up @@ -10880,6 +10881,8 @@ void TestQgsProcessing::modelScope()

QgsProcessingModelAlgorithm alg( "test", "testGroup" );

QVERIFY( !alg.fromFile( QStringLiteral( "not a file" ) ) );

QVariantMap variables;
variables.insert( QStringLiteral( "v1" ), 5 );
variables.insert( QStringLiteral( "v2" ), QStringLiteral( "aabbccd" ) );
Expand Down

0 comments on commit 3ae5e9a

Please sign in to comment.