Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-3_22] Fix incorrect return code from QgsProcessingModelAlgorithm::fromFile when file does not exist #47162

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2085,7 +2085,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 @@ -9607,6 +9608,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