Skip to content

Commit

Permalink
Fix #38955 broken relations when loading an embedded layer
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and github-actions[bot] committed Mar 9, 2021
1 parent c9e1deb commit 8350ae9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -717,11 +717,8 @@ void QgisApp::onActiveLayerChanged( QgsMapLayer *layer )
emit activeLayerChanged( layer );
}

void QgisApp::vectorLayerStyleLoaded( QgsMapLayer::StyleCategories categories )
void QgisApp::vectorLayerStyleLoaded( QgsVectorLayer *vl, QgsMapLayer::StyleCategories categories )
{

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( sender() );

if ( vl && vl->isValid( ) )
{

Expand Down Expand Up @@ -13170,6 +13167,14 @@ void QgisApp::embedLayers()
QgsProject::instance()->createEmbeddedLayer( selId, projectFile, brokenNodes );
}
}

// fix broken relations and dependencies
for ( const QString &id : constSortedIds )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( id ) );
if ( vlayer )
vectorLayerStyleLoaded( vlayer, QgsMapLayer::AllStyleCategories );
}
}
}

Expand Down Expand Up @@ -14307,7 +14312,7 @@ void QgisApp::layersWereAdded( const QList<QgsMapLayer *> &layers )
connect( vlayer, &QgsVectorLayer::editingStopped, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::readOnlyChanged, this, &QgisApp::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::raiseError, this, &QgisApp::onLayerError );
connect( vlayer, &QgsVectorLayer::styleLoaded, this, &QgisApp::vectorLayerStyleLoaded );
connect( vlayer, &QgsVectorLayer::styleLoaded, [this, vlayer]( QgsMapLayer::StyleCategories categories ) { vectorLayerStyleLoaded( vlayer, categories ); } );

provider = vProvider;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -1953,7 +1953,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* \param categories style categories
* \since QGIS 3.12
*/
void vectorLayerStyleLoaded( const QgsMapLayer::StyleCategories categories );
void vectorLayerStyleLoaded( QgsVectorLayer *vl, const QgsMapLayer::StyleCategories categories );

//! Enable or disable event tracing (for debugging)
void toggleEventTracing();
Expand Down

0 comments on commit 8350ae9

Please sign in to comment.