Skip to content

Commit

Permalink
Merge pull request #3054 from dgoedkoop/loadstylelabels214
Browse files Browse the repository at this point in the history
[Bugfix] Update labeling settings after loading style from file (fixes #14224)
  • Loading branch information
m-kuhn committed May 21, 2016
2 parents cf2ebb8 + 272b16a commit c260a77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/app/qgslabelingwidget.cpp
Expand Up @@ -41,6 +41,10 @@ void QgsLabelingWidget::adaptToLayer()
{
mLabelModeComboBox->setCurrentIndex( -1 );

// Delete the widget, so that labelModeChanged() recreates it with
// settings loaded from the layer
deleteWidget();

// pick the right mode of the layer
if ( mLayer->labeling() && mLayer->labeling()->type() == "rule-based" )
{
Expand Down Expand Up @@ -107,11 +111,7 @@ void QgsLabelingWidget::labelModeChanged( int index )

// in general case we need to recreate the widget

if ( mWidget )
mStackedWidget->removeWidget( mWidget );

delete mWidget;
mWidget = nullptr;
deleteWidget();

if ( index == 2 )
{
Expand Down Expand Up @@ -139,3 +139,12 @@ void QgsLabelingWidget::showEngineConfigDialog()
QgsLabelEngineConfigDialog dlg( this );
dlg.exec();
}

void QgsLabelingWidget::deleteWidget()
{
if ( mWidget )
mStackedWidget->removeWidget( mWidget );

delete mWidget;
mWidget = nullptr;
}
3 changes: 3 additions & 0 deletions src/app/qgslabelingwidget.h
Expand Up @@ -38,6 +38,9 @@ class QgsLabelingWidget : public QWidget, private Ui::QgsLabelingWidget
QgsMapCanvas* mCanvas;

QWidget* mWidget;

//! Delete the child widget
void deleteWidget();
};

#endif // QGSLABELINGWIDGET_H

0 comments on commit c260a77

Please sign in to comment.