@@ -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+ }
0 commit comments