@@ -578,6 +578,15 @@ QgsProjectVersion getVersion( const QDomDocument& doc )
578
578
return projectVersion;
579
579
}
580
580
581
+ void QgsProject::processLayerJoins ( QgsVectorLayer* layer )
582
+ {
583
+ if ( !layer )
584
+ return ;
585
+
586
+ layer->createJoinCaches ();
587
+ layer->updateFields ();
588
+ }
589
+
581
590
bool QgsProject::_getMapLayers ( const QDomDocument& doc, QList<QDomNode>& brokenNodes )
582
591
{
583
592
// Layer order is set by the restoring the legend settings from project file.
@@ -641,8 +650,7 @@ bool QgsProject::_getMapLayers( const QDomDocument& doc, QList<QDomNode>& broken
641
650
QList< QPair< QgsVectorLayer*, QDomElement > >::iterator vIt = vLayerList.begin ();
642
651
for ( ; vIt != vLayerList.end (); ++vIt )
643
652
{
644
- vIt->first ->createJoinCaches ();
645
- vIt->first ->updateFields ();
653
+ processLayerJoins ( vIt->first );
646
654
}
647
655
648
656
QSet<QgsVectorLayer *> notified;
@@ -975,7 +983,24 @@ bool QgsProject::read( QDomNode &layerNode )
975
983
{
976
984
QList<QDomNode> brokenNodes;
977
985
QList< QPair< QgsVectorLayer*, QDomElement > > vectorLayerList;
978
- return addLayer ( layerNode.toElement (), brokenNodes, vectorLayerList );
986
+ if ( addLayer ( layerNode.toElement (), brokenNodes, vectorLayerList ) )
987
+ {
988
+ // have to try to update joins for all layers now - a previously added layer may be dependant on this newly
989
+ // added layer for joins
990
+ QVector<QgsVectorLayer*> vectorLayers = QgsMapLayerRegistry::instance ()->layers <QgsVectorLayer*>();
991
+ Q_FOREACH ( QgsVectorLayer* layer, vectorLayers )
992
+ {
993
+ processLayerJoins ( layer );
994
+ }
995
+
996
+ if ( !vectorLayerList.isEmpty () )
997
+ {
998
+ emit readMapLayer ( vectorLayerList.at ( 0 ).first , vectorLayerList.at ( 0 ).second );
999
+ }
1000
+
1001
+ return true ;
1002
+ }
1003
+ return false ;
979
1004
}
980
1005
981
1006
bool QgsProject::write ( QFileInfo const &file )
0 commit comments