[welcome] Fix SEGV

- In the retranslate function, need to check if the waiting
   widget still exists.
 - Tighten up lifetime of the CheckerWidget.
This commit is contained in:
Adriaan de Groot 2019-02-26 05:05:10 -05:00
parent 33bd6c67c0
commit ba9a6981b3

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
*
* 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;