Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[processing] Fix crash when running model from file through qgis_process
- Loading branch information
Showing
with
24 additions
and
3 deletions.
-
+7
−3
src/process/qgsprocess.cpp
-
+17
−0
tests/src/python/test_qgsprocessexecutable.py
|
@@ -885,9 +885,13 @@ int QgsProcessingExec::execute( const QString &id, const QVariantMap ¶ms, co |
|
|
algorithmDetails.insert( QStringLiteral( "id" ), alg->id() ); |
|
|
addAlgorithmInformation( algorithmDetails, alg ); |
|
|
json.insert( QStringLiteral( "algorithm_details" ), algorithmDetails ); |
|
|
QVariantMap providerJson; |
|
|
addProviderInformation( providerJson, alg->provider() ); |
|
|
json.insert( QStringLiteral( "provider_details" ), providerJson ); |
|
|
|
|
|
if ( alg->provider() ) |
|
|
{ |
|
|
QVariantMap providerJson; |
|
|
addProviderInformation( providerJson, alg->provider() ); |
|
|
json.insert( QStringLiteral( "provider_details" ), providerJson ); |
|
|
} |
|
|
} |
|
|
|
|
|
std::unique_ptr< QgsProject > project; |
|
|
|
@@ -249,6 +249,23 @@ def testModelRun(self): |
|
|
self.assertIn('results', output.lower()) |
|
|
self.assertTrue(os.path.exists(output_file)) |
|
|
|
|
|
def testModelRunJson(self): |
|
|
output_file = self.TMP_DIR + '/model_output2.shp' |
|
|
rc, output, err = self.run_process(['run', TEST_DATA_DIR + '/test_model.model3', '--json', '--', 'FEATS={}'.format(TEST_DATA_DIR + '/polys.shp'), 'native:centroids_1:CENTROIDS={}'.format(output_file)]) |
|
|
if os.environ.get('TRAVIS', '') != 'true': |
|
|
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt |
|
|
self.assertFalse(err) |
|
|
self.assertEqual(rc, 0) |
|
|
|
|
|
res = json.loads(output) |
|
|
self.assertIn('gdal_version', res) |
|
|
self.assertIn('geos_version', res) |
|
|
self.assertIn('proj_version', res) |
|
|
self.assertIn('qt_version', res) |
|
|
self.assertIn('qgis_version', res) |
|
|
self.assertEqual(res['algorithm_details']['id'], 'Test model') |
|
|
self.assertTrue(os.path.exists(output_file)) |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
# look for qgis bin path |
|
|