[QGIS Commit] r15450 - in trunk/qgis/src/core: . renderer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Mar 12 10:45:52 EST 2011


Author: mhugent
Date: 2011-03-12 07:45:52 -0800 (Sat, 12 Mar 2011)
New Revision: 15450

Modified:
   trunk/qgis/src/core/qgsproject.cpp
   trunk/qgis/src/core/renderer/qgscontinuouscolorrenderer.cpp
   trunk/qgis/src/core/renderer/qgsgraduatedsymbolrenderer.cpp
   trunk/qgis/src/core/renderer/qgsuniquevaluerenderer.cpp
Log:
Fix loading of joined layers with old symbology, #121

Modified: trunk/qgis/src/core/qgsproject.cpp
===================================================================
--- trunk/qgis/src/core/qgsproject.cpp	2011-03-12 10:37:02 UTC (rev 15449)
+++ trunk/qgis/src/core/qgsproject.cpp	2011-03-12 15:45:52 UTC (rev 15450)
@@ -675,8 +675,11 @@
   bool returnStatus = true;
 
   emit layerLoaded( 0, nl.count() );
-  QList<QgsVectorLayer*> vLayerList; //collect
 
+  //Collect vector layers with joins.
+  //They need to refresh join caches and symbology infos after all layers are loaded
+  QList< QPair< QgsVectorLayer*, QDomElement > > vLayerList;
+
   for ( int i = 0; i < nl.count(); i++ )
   {
     QDomNode node = nl.item( i );
@@ -716,9 +719,9 @@
     {
       mapLayer = QgsMapLayerRegistry::instance()->addMapLayer( mapLayer );
       QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
-      if ( vLayer )
+      if ( vLayer && vLayer->vectorJoins().size() > 0 )
       {
-        vLayerList.push_back( vLayer );
+        vLayerList.push_back( qMakePair( vLayer, element ) );
       }
     }
     else
@@ -736,11 +739,17 @@
 
   //Update field map of layers with joins and create join caches if necessary
   //Needs to be done here once all dependent layers are loaded
-  QList<QgsVectorLayer*>::iterator vIt = vLayerList.begin();
+  QString errorMessage;
+  QList< QPair< QgsVectorLayer*, QDomElement > >::iterator vIt = vLayerList.begin();
   for ( ; vIt != vLayerList.end(); ++vIt )
   {
-    ( *vIt )->createJoinCaches();
-    ( *vIt )->updateFieldMap();
+    vIt->first->createJoinCaches();
+    vIt->first->updateFieldMap();
+    //for old symbology, it is necessary to read the symbology again after having the complete field map
+    if( !vIt->first->isUsingRendererV2() )
+    {
+      vIt->first->readSymbology( vIt->second, errorMessage );
+    }
   }
 
   return qMakePair( returnStatus, brokenNodes );

Modified: trunk/qgis/src/core/renderer/qgscontinuouscolorrenderer.cpp
===================================================================
--- trunk/qgis/src/core/renderer/qgscontinuouscolorrenderer.cpp	2011-03-12 10:37:02 UTC (rev 15449)
+++ trunk/qgis/src/core/renderer/qgscontinuouscolorrenderer.cpp	2011-03-12 15:45:52 UTC (rev 15450)
@@ -205,7 +205,7 @@
   int classificationId = theProvider->fieldNameIndex( classificationField );
   if ( classificationId == -1 )
   {
-    return 2; //@todo: handle gracefully in gui situation where user needs to nominate field
+    //go on. Because with joins, it might be the joined layer is not loaded yet
   }
   setClassificationField( classificationId );
 

Modified: trunk/qgis/src/core/renderer/qgsgraduatedsymbolrenderer.cpp
===================================================================
--- trunk/qgis/src/core/renderer/qgsgraduatedsymbolrenderer.cpp	2011-03-12 10:37:02 UTC (rev 15449)
+++ trunk/qgis/src/core/renderer/qgsgraduatedsymbolrenderer.cpp	2011-03-12 15:45:52 UTC (rev 15450)
@@ -268,10 +268,10 @@
     mMode = QgsGraduatedSymbolRenderer::EqualInterval;
   }
 
-  int classificationId = theProvider->fieldNameIndex( classificationField );
+  int classificationId = vl.fieldNameIndex( classificationField );
   if ( classificationId == -1 )
   {
-    return 2; //@todo: handle gracefully in gui situation where user needs to nominate field
+    //go on. Because with joins, it might be the joined layer is not loaded yet
   }
   setClassificationField( classificationId );
 

Modified: trunk/qgis/src/core/renderer/qgsuniquevaluerenderer.cpp
===================================================================
--- trunk/qgis/src/core/renderer/qgsuniquevaluerenderer.cpp	2011-03-12 10:37:02 UTC (rev 15449)
+++ trunk/qgis/src/core/renderer/qgsuniquevaluerenderer.cpp	2011-03-12 15:45:52 UTC (rev 15450)
@@ -228,7 +228,7 @@
   int classificationId = theProvider->fieldNameIndex( classificationField );
   if ( classificationId == -1 )
   {
-    return 2; //@todo: handle gracefully in gui situation where user needs to nominate field
+    //go on. Because with joins, it might be the joined layer is not loaded yet
   }
   setClassificationField( classificationId );
 



More information about the QGIS-commit mailing list