Skip to content

Commit b532044

Browse files
committedOct 18, 2023
Fixes #52740 : remove properties widget when layout item is destroyed
1 parent 05e1605 commit b532044

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
@@ -1338,7 +1338,8 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
13381338

13391339
if ( auto widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack->mainPanel() ) )
13401340
{
1341-
if ( widget->layoutObject() == item )
1341+
const QgsLayoutObject *currentItem = widget->layoutObject();
1342+
if ( currentItem == item )
13421343
{
13431344
// already showing properties for this item - we don't want to create a new panel
13441345
if ( bringPanelToFront )
@@ -1354,6 +1355,9 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
13541355
if ( bringPanelToFront )
13551356
mItemDock->setUserVisible( true );
13561357

1358+
disconnect( currentItem, &QgsLayoutItem::destroyed, this, &QgsLayoutDesignerDialog::onItemDestroyed );
1359+
connect( item, &QgsLayoutItem::destroyed, this, &QgsLayoutDesignerDialog::onItemDestroyed );
1360+
13571361
return;
13581362
}
13591363
}
@@ -1373,10 +1377,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
13731377
connect( ppWidget, &QgsLayoutPagePropertiesWidget::pageOrientationChanged, this, &QgsLayoutDesignerDialog::pageOrientationChanged );
13741378

13751379
widget->setDockMode( true );
1376-
connect( item, &QgsLayoutItem::destroyed, widget.get(), [this]
1377-
{
1378-
delete mItemPropertiesStack->takeMainPanel();
1379-
} );
1380+
connect( item, &QgsLayoutItem::destroyed, this, &QgsLayoutDesignerDialog::onItemDestroyed );
13801381

13811382
mItemPropertiesStack->setMainPanel( widget.release() );
13821383
if ( bringPanelToFront )
@@ -5075,3 +5076,12 @@ void QgsLayoutDesignerDialog::toolButtonActionTriggered( QAction *action )
50755076

50765077
bt->setDefaultAction( action );
50775078
}
5079+
5080+
void QgsLayoutDesignerDialog::onItemDestroyed( QObject *item )
5081+
{
5082+
if ( QgsLayoutItemBaseWidget *widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack->mainPanel() ) )
5083+
{
5084+
if ( widget->layoutObject() == item )
5085+
delete mItemPropertiesStack->takeMainPanel();
5086+
}
5087+
}

‎src/app/layout/qgslayoutdesignerdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
424424
void backgroundTaskCountChanged( int total );
425425
void onMapPreviewRefreshed();
426426
void onItemAdded( QgsLayoutItem *item );
427+
void onItemDestroyed( QObject *item );
427428

428429
private:
429430

@@ -599,4 +600,3 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
599600
};
600601

601602
#endif // QGSLAYOUTDESIGNERDIALOG_H
602-

0 commit comments

Comments
 (0)
Please sign in to comment.