Skip to content

Commit 272b16a

Browse files
committed
Update labeling settings in UI after loading style from file (fixes #14224)
1 parent dd136f6 commit 272b16a

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/app/qgslabelingwidget.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ void QgsLabelingWidget::adaptToLayer()
4141
{
4242
mLabelModeComboBox->setCurrentIndex( -1 );
4343

44+
// Delete the widget, so that labelModeChanged() recreates it with
45+
// settings loaded from the layer
46+
deleteWidget();
47+
4448
// pick the right mode of the layer
4549
if ( mLayer->labeling() && mLayer->labeling()->type() == "rule-based" )
4650
{
@@ -107,11 +111,7 @@ void QgsLabelingWidget::labelModeChanged( int index )
107111

108112
// in general case we need to recreate the widget
109113

110-
if ( mWidget )
111-
mStackedWidget->removeWidget( mWidget );
112-
113-
delete mWidget;
114-
mWidget = nullptr;
114+
deleteWidget();
115115

116116
if ( index == 2 )
117117
{
@@ -139,3 +139,12 @@ void QgsLabelingWidget::showEngineConfigDialog()
139139
QgsLabelEngineConfigDialog dlg( this );
140140
dlg.exec();
141141
}
142+
143+
void QgsLabelingWidget::deleteWidget()
144+
{
145+
if ( mWidget )
146+
mStackedWidget->removeWidget( mWidget );
147+
148+
delete mWidget;
149+
mWidget = nullptr;
150+
}

src/app/qgslabelingwidget.h

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class QgsLabelingWidget : public QWidget, private Ui::QgsLabelingWidget
3838
QgsMapCanvas* mCanvas;
3939

4040
QWidget* mWidget;
41+
42+
//! Delete the child widget
43+
void deleteWidget();
4144
};
4245

4346
#endif // QGSLABELINGWIDGET_H

0 commit comments

Comments
 (0)