From d348633b14f26807d8009d2dc77e595cdc191722 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 7 Sep 2017 04:04:50 -0400 Subject: [PATCH] Reduce Qt runtime warnings. - deleteLater() doesn't like nullptr (produces a warning, but is harmless) - reparenting across threads doesn't work, comment on that but leave it in, since this may be relevant for memory management. --- src/modules/partition/gui/ChoicePage.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 76c65a027..d4c40550c 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -806,9 +806,12 @@ ChoicePage::updateDeviceStatePreview() cDebug() << "Updating partitioning state widgets."; qDeleteAll( m_previewBeforeFrame->children() ); - m_previewBeforeFrame->layout()->deleteLater(); - QVBoxLayout* layout = new QVBoxLayout; + auto layout = m_previewBeforeFrame->layout(); + if ( layout ) + layout->deleteLater(); // Doesn't like nullptr + + layout = new QVBoxLayout; m_previewBeforeFrame->setLayout( layout ); CalamaresUtils::unmarginLayout( layout ); layout->setSpacing( 6 ); @@ -829,7 +832,7 @@ ChoicePage::updateDeviceStatePreview() // The QObject parents tree is meaningful for memory management here, // see qDeleteAll above. - deviceBefore->setParent( model ); + deviceBefore->setParent( model ); // Can't reparent across threads model->setParent( m_beforePartitionBarsView ); m_beforePartitionBarsView->setModel( model ); @@ -838,7 +841,8 @@ ChoicePage::updateDeviceStatePreview() // Make the bars and labels view use the same selectionModel. auto sm = m_beforePartitionLabelsView->selectionModel(); m_beforePartitionLabelsView->setSelectionModel( m_beforePartitionBarsView->selectionModel() ); - sm->deleteLater(); + if ( sm ) + sm->deleteLater(); switch ( m_choice ) { @@ -874,7 +878,10 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice ) cDebug() << "Updating partitioning preview widgets."; qDeleteAll( m_previewAfterFrame->children() ); - m_previewAfterFrame->layout()->deleteLater(); + + auto oldlayout = m_previewAfterFrame->layout(); + if ( oldlayout ) + oldlayout->deleteLater(); QVBoxLayout* layout = new QVBoxLayout; m_previewAfterFrame->setLayout( layout );