@@ -1338,7 +1338,8 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
1338
1338
1339
1339
if ( auto widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack ->mainPanel () ) )
1340
1340
{
1341
- if ( widget->layoutObject () == item )
1341
+ const QgsLayoutObject *currentItem = widget->layoutObject ();
1342
+ if ( currentItem == item )
1342
1343
{
1343
1344
// already showing properties for this item - we don't want to create a new panel
1344
1345
if ( bringPanelToFront )
@@ -1354,6 +1355,9 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
1354
1355
if ( bringPanelToFront )
1355
1356
mItemDock ->setUserVisible ( true );
1356
1357
1358
+ disconnect ( currentItem, &QgsLayoutItem::destroyed, this , &QgsLayoutDesignerDialog::onItemDestroyed );
1359
+ connect ( item, &QgsLayoutItem::destroyed, this , &QgsLayoutDesignerDialog::onItemDestroyed );
1360
+
1357
1361
return ;
1358
1362
}
1359
1363
}
@@ -1373,10 +1377,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
1373
1377
connect ( ppWidget, &QgsLayoutPagePropertiesWidget::pageOrientationChanged, this , &QgsLayoutDesignerDialog::pageOrientationChanged );
1374
1378
1375
1379
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 );
1380
1381
1381
1382
mItemPropertiesStack ->setMainPanel ( widget.release () );
1382
1383
if ( bringPanelToFront )
@@ -5075,3 +5076,12 @@ void QgsLayoutDesignerDialog::toolButtonActionTriggered( QAction *action )
5075
5076
5076
5077
bt->setDefaultAction ( action );
5077
5078
}
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
+ }
0 commit comments