File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -147,13 +147,24 @@ QgsLayoutObject *QgsLayoutItemBaseWidget::layoutObject()
147
147
148
148
bool QgsLayoutItemBaseWidget::setItem ( QgsLayoutItem *item )
149
149
{
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 );
150
155
if ( setNewItem ( item ) )
151
156
{
152
- mObject = item ;
157
+ oldConfigObject-> deleteLater () ;
153
158
return true ;
154
159
}
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
+ }
157
168
}
158
169
159
170
void QgsLayoutItemBaseWidget::setReportTypeString ( const QString & )
You can’t perform that action at this time.
0 commit comments