Skip to content

Commit

Permalink
Merge pull request #38594 from nyalldawson/fix_38562_project_load
Browse files Browse the repository at this point in the history
Fix project never completes loading layers when a layer has a missing dependancy
  • Loading branch information
nyalldawson committed Sep 7, 2020
2 parents dd3cc12 + dd82478 commit 8976fda
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/qgsproject.cpp
Expand Up @@ -1065,14 +1065,18 @@ bool QgsProject::_getMapLayers( const QDomDocument &doc, QList<QDomNode> &broken

bool returnStatus = true;

emit layerLoaded( 0, nl.count() );

// order layers based on their dependencies
QgsScopedRuntimeProfile profile( tr( "Sorting layers" ), QStringLiteral( "projectload" ) );
QgsLayerDefinition::DependencySorter depSorter( doc );
if ( depSorter.hasCycle() || depSorter.hasMissingDependency() )
if ( depSorter.hasCycle() )
return false;

// Missing a dependency? We still load all the layers, otherwise the project is completely broken!
if ( depSorter.hasMissingDependency() )
returnStatus = false;

emit layerLoaded( 0, nl.count() );

const QVector<QDomNode> sortedLayerNodes = depSorter.sortedLayerNodes();
const int totalLayerCount = sortedLayerNodes.count();

Expand Down

0 comments on commit 8976fda

Please sign in to comment.