@@ -190,6 +190,9 @@ QgsLayoutAtlas *QgsLayoutItemBaseWidget::layoutAtlas() const
190
190
191
191
void QgsLayoutItemPropertiesWidget::updateVariables ()
192
192
{
193
+ if ( !mItem )
194
+ return ;
195
+
193
196
QgsExpressionContext context = mItem ->createExpressionContext ();
194
197
mVariableEditor ->setContext ( &context );
195
198
int editableIndex = context.indexOfScope ( tr ( " Layout Item" ) );
@@ -295,8 +298,11 @@ void QgsLayoutItemPropertiesWidget::setItem( QgsLayoutItem *item )
295
298
disconnect ( mItem , &QgsLayoutObject::changed, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements );
296
299
}
297
300
mItem = item;
298
- connect ( mItem , &QgsLayoutItem::sizePositionChanged, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements );
299
- connect ( mItem , &QgsLayoutObject::changed, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements );
301
+ if ( mItem )
302
+ {
303
+ connect ( mItem , &QgsLayoutItem::sizePositionChanged, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements );
304
+ connect ( mItem , &QgsLayoutObject::changed, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements );
305
+ }
300
306
301
307
setValuesForGuiElements ();
302
308
}
@@ -329,6 +335,9 @@ void QgsLayoutItemPropertiesWidget::mBackgroundColorButton_colorChanged( const Q
329
335
330
336
void QgsLayoutItemPropertiesWidget::changeItemPosition ()
331
337
{
338
+ if ( !mItem )
339
+ return ;
340
+
332
341
mItem ->layout ()->undoStack ()->beginCommand ( mItem , tr ( " Move Item" ), QgsLayoutItem::UndoIncrementalMove );
333
342
334
343
QgsLayoutPoint point ( mXPosSpin ->value (), mYPosSpin ->value (), mPosUnitsComboBox ->unit () );
@@ -339,13 +348,19 @@ void QgsLayoutItemPropertiesWidget::changeItemPosition()
339
348
340
349
void QgsLayoutItemPropertiesWidget::changeItemReference ( QgsLayoutItem::ReferencePoint point )
341
350
{
351
+ if ( !mItem )
352
+ return ;
353
+
342
354
mItem ->layout ()->undoStack ()->beginCommand ( mItem , tr ( " Change Item Reference" ) );
343
355
mItem ->setReferencePoint ( point );
344
356
mItem ->layout ()->undoStack ()->endCommand ();
345
357
}
346
358
347
359
void QgsLayoutItemPropertiesWidget::changeItemSize ()
348
360
{
361
+ if ( !mItem )
362
+ return ;
363
+
349
364
mItem ->layout ()->undoStack ()->beginCommand ( mItem , tr ( " Resize Item" ), QgsLayoutItem::UndoIncrementalResize );
350
365
351
366
QgsLayoutSize size ( mWidthSpin ->value (), mHeightSpin ->value (), mSizeUnitsComboBox ->unit () );
@@ -356,6 +371,9 @@ void QgsLayoutItemPropertiesWidget::changeItemSize()
356
371
357
372
void QgsLayoutItemPropertiesWidget::variablesChanged ()
358
373
{
374
+ if ( !mItem )
375
+ return ;
376
+
359
377
QgsExpressionContextUtils::setLayoutItemVariables ( mItem , mVariableEditor ->variablesInActiveScope () );
360
378
}
361
379
0 commit comments