mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Fix joins are not recreated when loading project with bad layers (fix #10500)
This commit is contained in:
parent
92830a2509
commit
b1450802b9
@ -578,6 +578,15 @@ QgsProjectVersion getVersion( const QDomDocument& doc )
|
||||
return projectVersion;
|
||||
}
|
||||
|
||||
void QgsProject::processLayerJoins( QgsVectorLayer* layer )
|
||||
{
|
||||
if ( !layer )
|
||||
return;
|
||||
|
||||
layer->createJoinCaches();
|
||||
layer->updateFields();
|
||||
}
|
||||
|
||||
bool QgsProject::_getMapLayers( const QDomDocument& doc, QList<QDomNode>& brokenNodes )
|
||||
{
|
||||
// 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
|
||||
QList< QPair< QgsVectorLayer*, QDomElement > >::iterator vIt = vLayerList.begin();
|
||||
for ( ; vIt != vLayerList.end(); ++vIt )
|
||||
{
|
||||
vIt->first->createJoinCaches();
|
||||
vIt->first->updateFields();
|
||||
processLayerJoins( vIt->first );
|
||||
}
|
||||
|
||||
QSet<QgsVectorLayer *> notified;
|
||||
@ -975,7 +983,24 @@ bool QgsProject::read( QDomNode &layerNode )
|
||||
{
|
||||
QList<QDomNode> brokenNodes;
|
||||
QList< QPair< QgsVectorLayer*, QDomElement > > vectorLayerList;
|
||||
return addLayer( layerNode.toElement(), brokenNodes, vectorLayerList );
|
||||
if ( addLayer( layerNode.toElement(), brokenNodes, vectorLayerList ) )
|
||||
{
|
||||
// have to try to update joins for all layers now - a previously added layer may be dependant on this newly
|
||||
// added layer for joins
|
||||
QVector<QgsVectorLayer*> vectorLayers = QgsMapLayerRegistry::instance()->layers<QgsVectorLayer*>();
|
||||
Q_FOREACH ( QgsVectorLayer* layer, vectorLayers )
|
||||
{
|
||||
processLayerJoins( layer );
|
||||
}
|
||||
|
||||
if ( !vectorLayerList.isEmpty() )
|
||||
{
|
||||
emit readMapLayer( vectorLayerList.at( 0 ).first, vectorLayerList.at( 0 ).second );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsProject::write( QFileInfo const &file )
|
||||
|
@ -491,6 +491,11 @@ class CORE_EXPORT QgsProject : public QObject
|
||||
*/
|
||||
bool _getMapLayers( QDomDocument const &doc, QList<QDomNode>& brokenNodes );
|
||||
|
||||
/** Processes any joins attached to a newly added layer.
|
||||
* @param layer layer to process
|
||||
*/
|
||||
void processLayerJoins( QgsVectorLayer* layer );
|
||||
|
||||
QString mErrorMessage;
|
||||
|
||||
QgsProjectBadLayerHandler* mBadLayerHandler;
|
||||
|
Loading…
x
Reference in New Issue
Block a user