Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 00eaa2d

Browse files
troopa81github-actions[bot]
authored andcommittedOct 18, 2023
Fixes #52740 : remove properties widget when layout item is destroyed
1 parent 74ae947 commit 00eaa2d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed
 

‎src/app/layout/qgslayoutdesignerdialog.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,8 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
13201320

13211321
if ( auto widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack->mainPanel() ) )
13221322
{
1323-
if ( widget->layoutObject() == item )
1323+
const QgsLayoutObject *currentItem = widget->layoutObject();
1324+
if ( currentItem == item )
13241325
{
13251326
// already showing properties for this item - we don't want to create a new panel
13261327
if ( bringPanelToFront )
@@ -1336,6 +1337,9 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
13361337
if ( bringPanelToFront )
13371338
mItemDock->setUserVisible( true );
13381339

1340+
disconnect( currentItem, &QgsLayoutItem::destroyed, this, &QgsLayoutDesignerDialog::onItemDestroyed );
1341+
connect( item, &QgsLayoutItem::destroyed, this, &QgsLayoutDesignerDialog::onItemDestroyed );
1342+
13391343
return;
13401344
}
13411345
}
@@ -1355,10 +1359,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
13551359
connect( ppWidget, &QgsLayoutPagePropertiesWidget::pageOrientationChanged, this, &QgsLayoutDesignerDialog::pageOrientationChanged );
13561360

13571361
widget->setDockMode( true );
1358-
connect( item, &QgsLayoutItem::destroyed, widget.get(), [this]
1359-
{
1360-
delete mItemPropertiesStack->takeMainPanel();
1361-
} );
1362+
connect( item, &QgsLayoutItem::destroyed, this, &QgsLayoutDesignerDialog::onItemDestroyed );
13621363

13631364
mItemPropertiesStack->setMainPanel( widget.release() );
13641365
if ( bringPanelToFront )
@@ -5035,3 +5036,12 @@ void QgsLayoutDesignerDialog::toolButtonActionTriggered( QAction *action )
50355036

50365037
bt->setDefaultAction( action );
50375038
}
5039+
5040+
void QgsLayoutDesignerDialog::onItemDestroyed( QObject *item )
5041+
{
5042+
if ( QgsLayoutItemBaseWidget *widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack->mainPanel() ) )
5043+
{
5044+
if ( widget->layoutObject() == item )
5045+
delete mItemPropertiesStack->takeMainPanel();
5046+
}
5047+
}

‎src/app/layout/qgslayoutdesignerdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
416416
void backgroundTaskCountChanged( int total );
417417
void onMapPreviewRefreshed();
418418
void onItemAdded( QgsLayoutItem *item );
419+
void onItemDestroyed( QObject *item );
419420

420421
private:
421422

@@ -587,4 +588,3 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
587588
};
588589

589590
#endif // QGSLAYOUTDESIGNERDIALOG_H
590-

0 commit comments

Comments
 (0)
Please sign in to comment.