mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Merge pull request #39141 from elpaso/bugfix-gh39025-fix-layer-dependency-loading
Fix broken layer dependencies for old projects
This commit is contained in:
commit
beaf4307ec
@ -2251,7 +2251,7 @@ const QList<QgsVectorLayerRef> QgisApp::findBrokenLayerDependencies( QgsVectorLa
|
|||||||
|
|
||||||
if ( found )
|
if ( found )
|
||||||
{
|
{
|
||||||
// Make sure we don't add it twice
|
// Make sure we don't add it twice if it was already added by the form widgets check
|
||||||
bool refFound = false;
|
bool refFound = false;
|
||||||
for ( const QgsVectorLayerRef &otherRef : qgis::as_const( brokenDependencies ) )
|
for ( const QgsVectorLayerRef &otherRef : qgis::as_const( brokenDependencies ) )
|
||||||
{
|
{
|
||||||
@ -2279,6 +2279,11 @@ void QgisApp::resolveVectorLayerDependencies( QgsVectorLayer *vl, QgsMapLayer::S
|
|||||||
const auto constDependencies { findBrokenLayerDependencies( vl, categories ) };
|
const auto constDependencies { findBrokenLayerDependencies( vl, categories ) };
|
||||||
for ( const QgsVectorLayerRef &dependency : constDependencies )
|
for ( const QgsVectorLayerRef &dependency : constDependencies )
|
||||||
{
|
{
|
||||||
|
// Temporary check for projects that were created before commit 7e8c7b3d0e094737336ff4834ea2af625d2921bf
|
||||||
|
if ( QgsProject::instance()->mapLayer( dependency.layerId ) )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// try to aggressively resolve the broken dependencies
|
// try to aggressively resolve the broken dependencies
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
const QString providerName { vl->dataProvider()->name() };
|
const QString providerName { vl->dataProvider()->name() };
|
||||||
|
@ -176,6 +176,13 @@ QVariant QgsRelationReferenceFieldFormatter::createCache( QgsVectorLayer *layer,
|
|||||||
|
|
||||||
QList<QgsVectorLayerRef> QgsRelationReferenceFieldFormatter::layerDependencies( const QVariantMap &config ) const
|
QList<QgsVectorLayerRef> QgsRelationReferenceFieldFormatter::layerDependencies( const QVariantMap &config ) const
|
||||||
{
|
{
|
||||||
|
// Old projects, create before the weak relations were introduced and stored with the
|
||||||
|
// widget configuration do not have the referenced layer details but only the "Relation" id,
|
||||||
|
// for these projects automatic loading of broken references is not supported.
|
||||||
|
if ( config.value( QStringLiteral( "ReferencedLayerId" ) ).toString().isEmpty() )
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
const QList<QgsVectorLayerRef> result {{
|
const QList<QgsVectorLayerRef> result {{
|
||||||
QgsVectorLayerRef(
|
QgsVectorLayerRef(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user