Skip to content

Commit 2d45ba8

Browse files
committedJun 11, 2019
Move the QgsProject singleton problem one step up
1 parent 6bd5c51 commit 2d45ba8

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed
 

‎python/core/auto_generated/fieldformatter/qgsvaluerelationfieldformatter.sip.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ Check whether the ``feature`` has all values required by the ``expression``
121121
.. versionadded:: 3.2
122122
%End
123123

124-
static QgsVectorLayer *resolveLayer( const QVariantMap &config );
124+
static QgsVectorLayer *resolveLayer( const QVariantMap &config, const QgsProject *project );
125125
%Docstring
126-
Returns the (possibly NULL) layer from the widget's ``config``
126+
Returns the (possibly NULL) layer from the widget's ``config`` and ``project``
127127

128128
.. versionadded:: 3.8
129129
%End

‎src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte
118118
{
119119
ValueRelationCache cache;
120120

121-
const QgsVectorLayer *layer = resolveLayer( config );
121+
const QgsVectorLayer *layer = resolveLayer( config, QgsProject::instance() );
122122

123123
if ( !layer )
124124
return cache;
@@ -274,12 +274,12 @@ bool QgsValueRelationFieldFormatter::expressionIsUsable( const QString &expressi
274274
return true;
275275
}
276276

277-
QgsVectorLayer *QgsValueRelationFieldFormatter::resolveLayer( const QVariantMap &config )
277+
QgsVectorLayer *QgsValueRelationFieldFormatter::resolveLayer( const QVariantMap &config, const QgsProject *project )
278278
{
279279
QgsVectorLayerRef ref { config.value( QStringLiteral( "Layer" ) ).toString(),
280280
config.value( QStringLiteral( "LayerName" ) ).toString(),
281281
config.value( QStringLiteral( "LayerSource" ) ).toString(),
282282
config.value( QStringLiteral( "LayerProviderName" ) ).toString() };
283-
return ref.resolveByIdOrNameOnly( QgsProject::instance() );
283+
return ref.resolveByIdOrNameOnly( project );
284284
}
285285

‎src/core/fieldformatter/qgsvaluerelationfieldformatter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ class CORE_EXPORT QgsValueRelationFieldFormatter : public QgsFieldFormatter
120120
static bool expressionIsUsable( const QString &expression, const QgsFeature &feature );
121121

122122
/**
123-
* Returns the (possibly NULL) layer from the widget's \a config
123+
* Returns the (possibly NULL) layer from the widget's \a config and \a project
124124
* \since QGIS 3.8
125125
*/
126-
static QgsVectorLayer *resolveLayer( const QVariantMap &config );
126+
static QgsVectorLayer *resolveLayer( const QVariantMap &config, const QgsProject *project );
127127

128128

129129

‎src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ QVariantMap QgsValueRelationConfigDlg::config()
7575

7676
void QgsValueRelationConfigDlg::setConfig( const QVariantMap &config )
7777
{
78-
QgsVectorLayer *lyr = QgsValueRelationFieldFormatter::resolveLayer( config );
78+
QgsVectorLayer *lyr = QgsValueRelationFieldFormatter::resolveLayer( config, QgsProject::instance() );
7979
mLayerName->setLayer( lyr );
8080
mKeyColumn->setField( config.value( QStringLiteral( "Key" ) ).toString() );
8181
mValueColumn->setField( config.value( QStringLiteral( "Value" ) ).toString() );

‎src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ int QgsValueRelationWidgetWrapper::columnCount() const
302302

303303
QVariant::Type QgsValueRelationWidgetWrapper::fkType() const
304304
{
305-
const QgsVectorLayer *layer = QgsValueRelationFieldFormatter::resolveLayer( config() );
305+
const QgsVectorLayer *layer = QgsValueRelationFieldFormatter::resolveLayer( config(), QgsProject::instance() );
306306
if ( layer )
307307
{
308308
QgsFields fields = layer->fields();

0 commit comments

Comments
 (0)
Please sign in to comment.