Skip to content

Commit

Permalink
defer readMapLayer signal for layers with joins to let editor widgets…
Browse files Browse the repository at this point in the history
… pickup joined fields
  • Loading branch information
jef-n committed Feb 18, 2015
1 parent 342a0cb commit 39d3765
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/core/qgsproject.cpp
Expand Up @@ -680,6 +680,18 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
vIt->first->updateFields();
}

QSet<QgsVectorLayer *> notified;
for ( vIt = vLayerList.begin(); vIt != vLayerList.end(); ++vIt )
{
if ( notified.contains( vIt->first ) )
continue;

notified << vIt->first;
emit readMapLayer( vIt->first, vIt->second );
}



return qMakePair( returnStatus, brokenNodes );
} // _getMapLayers

Expand Down Expand Up @@ -715,16 +727,17 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList<QDomNode> &broken
// have the layer restore state that is stored in Dom node
if ( mapLayer->readLayerXML( layerElem ) && mapLayer->isValid() )
{
emit readMapLayer( mapLayer, layerElem );
// postpone readMapLayer signal for vector layers with joins
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
if ( !vLayer || vLayer->vectorJoins().size() == 0 )
emit readMapLayer( mapLayer, layerElem );
else
vectorLayerList.push_back( qMakePair( vLayer, layerElem ) );

QList<QgsMapLayer *> myLayers;
myLayers << mapLayer;
QgsMapLayerRegistry::instance()->addMapLayers( myLayers );
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
if ( vLayer && vLayer->vectorJoins().size() > 0 )
{
vectorLayerList.push_back( qMakePair( vLayer, layerElem ) );
}

return true;
}
else
Expand Down

0 comments on commit 39d3765

Please sign in to comment.