From ba9a6981b3fcf7fbd099adbcee9f0ce7de96f6ba Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Feb 2019 05:05:10 -0500 Subject: [PATCH] [welcome] Fix SEGV - In the retranslate function, need to check if the waiting widget still exists. - Tighten up lifetime of the CheckerWidget. --- .../welcome/checker/CheckerContainer.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/modules/welcome/checker/CheckerContainer.cpp b/src/modules/welcome/checker/CheckerContainer.cpp index 6f46cd094..569d2e9cc 100644 --- a/src/modules/welcome/checker/CheckerContainer.cpp +++ b/src/modules/welcome/checker/CheckerContainer.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2017, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017, 2019, Adriaan de Groot * Copyright 2017, Gabriel Craciunescu * * Calamares is free software: you can redistribute it and/or modify @@ -29,10 +29,10 @@ #include "utils/Retranslator.h" #include "widgets/WaitingWidget.h" -CheckerContainer::CheckerContainer(QWidget* parent) +CheckerContainer::CheckerContainer( QWidget* parent ) : QWidget( parent ) - , m_waitingWidget( new WaitingWidget( QString() ) ) - , m_checkerWidget( new CheckerWidget() ) + , m_waitingWidget( new WaitingWidget( QString(), this ) ) + , m_checkerWidget( nullptr ) , m_verdict( false ) { QBoxLayout* mainLayout = new QHBoxLayout; @@ -40,7 +40,10 @@ CheckerContainer::CheckerContainer(QWidget* parent) CalamaresUtils::unmarginLayout( mainLayout ); mainLayout->addWidget( m_waitingWidget ); - CALAMARES_RETRANSLATE( m_waitingWidget->setText( tr( "Gathering system information..." ) ); ) + CALAMARES_RETRANSLATE( + if ( m_waitingWidget ) + m_waitingWidget->setText( tr( "Gathering system information..." ) ); + ) } CheckerContainer::~CheckerContainer() @@ -51,11 +54,13 @@ CheckerContainer::~CheckerContainer() void CheckerContainer::requirementsComplete( bool ok ) { - m_checkerWidget->init( m_requirements ); + layout()->removeWidget( m_waitingWidget ); m_waitingWidget->deleteLater(); m_waitingWidget = nullptr; // Don't delete in destructor - m_checkerWidget->setParent( this ); + + m_checkerWidget = new CheckerWidget( this ); + m_checkerWidget->init( m_requirements ); layout()->addWidget( m_checkerWidget ); m_verdict = ok;