Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layouts] Fix map item loses preset them choice if item is selected
when a map theme is renamed or changed
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Feb 23, 2021
1 parent 585f04d commit 9c96f91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gui/layout/qgslayoutmapwidget.cpp
Expand Up @@ -314,6 +314,9 @@ void QgsLayoutMapWidget::followVisibilityPresetSelected( int currentIndex )
if ( !mMapItem )
return;

if ( mBlockThemeComboChanges != 0 )
return;

if ( currentIndex == -1 )
return; // doing combo box model reset

Expand Down Expand Up @@ -361,6 +364,7 @@ void QgsLayoutMapWidget::onMapThemesChanged()
{
if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
{
mBlockThemeComboChanges++;
QStringList lst;
lst.append( tr( "(none)" ) );
lst += QgsProject::instance()->mapThemeCollection()->mapThemes();
Expand All @@ -371,6 +375,7 @@ void QgsLayoutMapWidget::onMapThemesChanged()
mFollowVisibilityPresetCombo->blockSignals( true );
mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); // 0 == none
mFollowVisibilityPresetCombo->blockSignals( false );
mBlockThemeComboChanges--;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/layout/qgslayoutmapwidget.h
Expand Up @@ -152,6 +152,7 @@ class GUI_EXPORT QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui:
QMenu *mBookmarkMenu = nullptr;
QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
QString mReportTypeString;
int mBlockThemeComboChanges = 0;

//! Sets extent of composer map from line edits
void updateComposerExtentFromGui();
Expand Down

0 comments on commit 9c96f91

Please sign in to comment.