Skip to content

Commit 60f7f89

Browse files
committedApr 10, 2023
[vector tiles] Fix editing of label styles results in missing labels
1 parent 795f850 commit 60f7f89

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
 

‎src/core/labeling/qgsvectorlayerlabelprovider.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,8 @@ const QgsPalLayerSettings &QgsVectorLayerLabelProvider::settings() const
809809
{
810810
return mSettings;
811811
}
812+
813+
void QgsVectorLayerLabelProvider::setFields( const QgsFields &fields )
814+
{
815+
mFields = fields;
816+
}

‎src/core/labeling/qgsvectorlayerlabelprovider.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class CORE_EXPORT QgsVectorLayerLabelProvider : public QgsAbstractLabelProvider
116116
* a call to prepare() which uses the list of fields.
117117
* \since QGIS 3.14
118118
*/
119-
void setFields( const QgsFields &fields ) { mFields = fields; }
119+
void setFields( const QgsFields &fields );
120120

121121
protected:
122122
//! initialization method - called from constructors
@@ -147,6 +147,8 @@ class CORE_EXPORT QgsVectorLayerLabelProvider : public QgsAbstractLabelProvider
147147
private:
148148

149149
friend class TestQgsLabelingEngine;
150+
friend class QgsVectorTileBasicLabelProvider;
151+
150152
void drawCallout( QgsRenderContext &context, pal::LabelPosition *label ) const;
151153
};
152154

‎src/core/vectortile/qgsvectortilebasiclabeling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ bool QgsVectorTileBasicLabelProvider::prepare( QgsRenderContext &context, QSet<Q
186186
QgsExpressionContextScopePopper popper( context.expressionContext(), scope );
187187

188188
mSubProviders[i]->setFields( fields );
189+
// check is required as fields are not available through the GUI, which can lead to isExpression wrongly set to true
190+
mSubProviders[i]->mSettings.isExpression = !fields.names().contains( mSubProviders[i]->mSettings.fieldName );
189191
if ( !mSubProviders[i]->prepare( context, attributeNames ) )
190192
{
191193
QgsDebugMsg( QStringLiteral( "Failed to prepare labeling for style index" ) + QString::number( i ) );

0 commit comments

Comments
 (0)
Please sign in to comment.