Skip to content

Commit

Permalink
Update labeling settings in UI after loading style from file (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoedkoop committed May 2, 2016
1 parent dd136f6 commit 272b16a
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 272b16a

Please sign in to comment.