Skip to content
Permalink
Browse files

Fix loading of joined layers with old symbology, #121

git-svn-id: http://svn.osgeo.org/qgis/trunk@15450 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Mar 12, 2011
1 parent 906c7dd commit 489e34bc705931a8e7edbc572591ffa61f24e523
@@ -675,7 +675,10 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
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++ )
{
@@ -716,9 +719,9 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
{
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 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do

//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 );
@@ -205,7 +205,7 @@ int QgsContinuousColorRenderer::readXML( const QDomNode& rnode, QgsVectorLayer&
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 );

@@ -268,10 +268,10 @@ int QgsGraduatedSymbolRenderer::readXML( const QDomNode& rnode, QgsVectorLayer&
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 );

@@ -228,7 +228,7 @@ int QgsUniqueValueRenderer::readXML( const QDomNode& rnode, QgsVectorLayer& vl )
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 );

0 comments on commit 489e34b

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