Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c5bf01d

Browse files
nirvngithub-actions[bot]
authored andcommittedApr 9, 2023
[vector tiles] Fix editing of label styles results in missing labels
1 parent dea5892 commit c5bf01d

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
@@ -712,3 +712,8 @@ const QgsPalLayerSettings &QgsVectorLayerLabelProvider::settings() const
712712
{
713713
return mSettings;
714714
}
715+
716+
void QgsVectorLayerLabelProvider::setFields( const QgsFields &fields )
717+
{
718+
mFields = fields;
719+
}

‎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
@@ -187,6 +187,8 @@ bool QgsVectorTileBasicLabelProvider::prepare( QgsRenderContext &context, QSet<Q
187187
QgsExpressionContextScopePopper popper( context.expressionContext(), scope );
188188

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

0 commit comments

Comments
 (0)
Please sign in to comment.