@@ -1320,7 +1320,8 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
1320
1320
1321
1321
if ( auto widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack ->mainPanel () ) )
1322
1322
{
1323
- if ( widget->layoutObject () == item )
1323
+ const QgsLayoutObject *currentItem = widget->layoutObject ();
1324
+ if ( currentItem == item )
1324
1325
{
1325
1326
// already showing properties for this item - we don't want to create a new panel
1326
1327
if ( bringPanelToFront )
@@ -1336,6 +1337,9 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
1336
1337
if ( bringPanelToFront )
1337
1338
mItemDock ->setUserVisible ( true );
1338
1339
1340
+ disconnect ( currentItem, &QgsLayoutItem::destroyed, this , &QgsLayoutDesignerDialog::onItemDestroyed );
1341
+ connect ( item, &QgsLayoutItem::destroyed, this , &QgsLayoutDesignerDialog::onItemDestroyed );
1342
+
1339
1343
return ;
1340
1344
}
1341
1345
}
@@ -1355,10 +1359,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
1355
1359
connect ( ppWidget, &QgsLayoutPagePropertiesWidget::pageOrientationChanged, this , &QgsLayoutDesignerDialog::pageOrientationChanged );
1356
1360
1357
1361
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 );
1362
1363
1363
1364
mItemPropertiesStack ->setMainPanel ( widget.release () );
1364
1365
if ( bringPanelToFront )
@@ -5035,3 +5036,12 @@ void QgsLayoutDesignerDialog::toolButtonActionTriggered( QAction *action )
5035
5036
5036
5037
bt->setDefaultAction ( action );
5037
5038
}
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