Skip to content
Permalink
Browse files

Merge pull request #38594 from nyalldawson/fix_38562_project_load

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 8976fda4cf45452162009a7b979b3aaf008c38e6
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/core/qgsproject.cpp
@@ -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();

0 comments on commit 8976fda

Please sign in to comment.
You can’t perform that action at this time.