From 329f21093b2c6bad8625fc76e4e9de92b6ca904a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Oct 2021 00:27:03 +0200 Subject: [PATCH] [libcalamaresui] More careful in unmarginLayout --- .../utils/CalamaresUtilsGui.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 ); + } } } }