Skip to content

Commit 0b627b3

Browse files
committed
[layouts] Fix data defined buttons do not update when clicking
between items of same type Fixes #18637, #18639 (cherry-picked from 3c08e2)
1 parent 7f24b6f commit 0b627b3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/gui/layout/qgslayoutitemwidget.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,24 @@ QgsLayoutObject *QgsLayoutItemBaseWidget::layoutObject()
147147

148148
bool QgsLayoutItemBaseWidget::setItem( QgsLayoutItem *item )
149149
{
150+
QgsLayoutObject *oldObject = mObject;
151+
QgsLayoutConfigObject *oldConfigObject = mConfigObject;
152+
// have to set new mObject/mConfigObject here, because setNewItem methods require access to them
153+
mObject = item;
154+
mConfigObject = new QgsLayoutConfigObject( this, mObject );
150155
if ( setNewItem( item ) )
151156
{
152-
mObject = item;
157+
oldConfigObject->deleteLater();
153158
return true;
154159
}
155-
156-
return false;
160+
else
161+
{
162+
// revert object change since it was unsuccessful
163+
mObject = oldObject;
164+
mConfigObject->deleteLater();
165+
mConfigObject = oldConfigObject;
166+
return false;
167+
}
157168
}
158169

159170
void QgsLayoutItemBaseWidget::setReportTypeString( const QString & )

0 commit comments

Comments
 (0)