Skip to content

Commit 292a8a4

Browse files
committed
Fix updates of preset combo box when presets get changed
1 parent 7eb05e2 commit 292a8a4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/app/composer/qgscomposermapwidget.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ void QgsComposerMapWidget::followVisibilityPresetSelected( int currentIndex )
332332
if ( !mComposerMap )
333333
return;
334334

335+
if ( currentIndex == -1 )
336+
return; // doing combo box model reset
337+
335338
QString presetName;
336339
if ( currentIndex != 0 )
337340
{
@@ -378,6 +381,12 @@ void QgsComposerMapWidget::onPresetsChanged()
378381
lst.append( tr( "(none)" ) );
379382
lst += QgsProject::instance()->visibilityPresetCollection()->presets();
380383
model->setStringList( lst );
384+
385+
// select the previously selected item again
386+
int presetModelIndex = mFollowVisibilityPresetCombo->findText( mComposerMap->followVisibilityPresetName() );
387+
mFollowVisibilityPresetCombo->blockSignals( true );
388+
mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); // 0 == none
389+
mFollowVisibilityPresetCombo->blockSignals( false );
381390
}
382391
}
383392

@@ -840,6 +849,8 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
840849
mAtlasMarginSpinBox->blockSignals( b );
841850
mAtlasFixedScaleRadio->blockSignals( b );
842851
mAtlasMarginRadio->blockSignals( b );
852+
mFollowVisibilityPresetCheckBox->blockSignals( b );
853+
mFollowVisibilityPresetCombo->blockSignals( b );
843854
mKeepLayerListCheckBox->blockSignals( b );
844855
mKeepLayerStylesCheckBox->blockSignals( b );
845856
mSetToMapCanvasExtentButton->blockSignals( b );

0 commit comments

Comments
 (0)