diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index e16763a70..d10aada73 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -180,16 +180,20 @@ createRoundedImage( const QPixmap& pixmap, const QSize& size, float frameWidthPc void unmarginLayout( QLayout* layout ) { - layout->setContentsMargins( 0, 0, 0, 0 ); - layout->setMargin( 0 ); - layout->setSpacing( 0 ); - - for ( int i = 0; i < layout->count(); i++ ) + if ( layout ) { - QLayout* childLayout = layout->itemAt( i )->layout(); - if ( childLayout ) + layout->setContentsMargins( 0, 0, 0, 0 ); + layout->setMargin( 0 ); + layout->setSpacing( 0 ); + + for ( int i = 0; i < layout->count(); i++ ) { - unmarginLayout( childLayout ); + auto* childItem = layout->itemAt( i ); + QLayout* childLayout = childItem ? childItem->layout() : nullptr; + if ( childLayout ) + { + unmarginLayout( childLayout ); + } } } }