@@ -675,7 +675,10 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
675
675
bool returnStatus = true ;
676
676
677
677
emit layerLoaded ( 0 , nl.count () );
678
- QList<QgsVectorLayer*> vLayerList; // collect
678
+
679
+ // Collect vector layers with joins.
680
+ // They need to refresh join caches and symbology infos after all layers are loaded
681
+ QList< QPair< QgsVectorLayer*, QDomElement > > vLayerList;
679
682
680
683
for ( int i = 0 ; i < nl.count (); i++ )
681
684
{
@@ -716,9 +719,9 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
716
719
{
717
720
mapLayer = QgsMapLayerRegistry::instance ()->addMapLayer ( mapLayer );
718
721
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
719
- if ( vLayer )
722
+ if ( vLayer && vLayer-> vectorJoins (). size () > 0 )
720
723
{
721
- vLayerList.push_back ( vLayer );
724
+ vLayerList.push_back ( qMakePair ( vLayer, element ) );
722
725
}
723
726
}
724
727
else
@@ -736,11 +739,17 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
736
739
737
740
// Update field map of layers with joins and create join caches if necessary
738
741
// Needs to be done here once all dependent layers are loaded
739
- QList<QgsVectorLayer*>::iterator vIt = vLayerList.begin ();
742
+ QString errorMessage;
743
+ QList< QPair< QgsVectorLayer*, QDomElement > >::iterator vIt = vLayerList.begin ();
740
744
for ( ; vIt != vLayerList.end (); ++vIt )
741
745
{
742
- ( *vIt )->createJoinCaches ();
743
- ( *vIt )->updateFieldMap ();
746
+ vIt->first ->createJoinCaches ();
747
+ vIt->first ->updateFieldMap ();
748
+ // for old symbology, it is necessary to read the symbology again after having the complete field map
749
+ if ( !vIt->first ->isUsingRendererV2 () )
750
+ {
751
+ vIt->first ->readSymbology ( vIt->second , errorMessage );
752
+ }
744
753
}
745
754
746
755
return qMakePair ( returnStatus, brokenNodes );
0 commit comments