[welcome] Avoid growing more spacers

Insert spacers only once; avoid crashing when all the requirements
are satisfied immediately.
This commit is contained in:
Adriaan de Groot 2022-04-14 22:06:36 +02:00
parent e79f29dc0e
commit fcb893cd12

View File

@ -175,6 +175,8 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent )
m_explanation->setOpenExternalLinks( false ); m_explanation->setOpenExternalLinks( false );
m_explanation->setObjectName( "resultsExplanation" ); m_explanation->setObjectName( "resultsExplanation" );
m_entriesLayout->addWidget( m_explanation ); m_entriesLayout->addWidget( m_explanation );
m_entriesLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() / 2 );
m_mainLayout->addStretch();
requirementsChanged(); requirementsChanged();
@ -212,7 +214,9 @@ void
ResultsListWidget::retranslate() ResultsListWidget::retranslate()
{ {
const auto& model = *( m_config->requirementsModel() ); const auto& model = *( m_config->requirementsModel() );
for ( auto i = 0; i < model.count(); i++ ) // Retranslate the widgets that there **are**;
// these remain in-order relative to the model.
for ( auto i = 0; i < model.count() && i < m_resultWidgets.count(); i++ )
{ {
if ( m_resultWidgets[ i ] ) if ( m_resultWidgets[ i ] )
{ {
@ -247,12 +251,10 @@ ResultsListWidget::requirementsChanged()
w->deleteLater(); w->deleteLater();
} }
} ); } );
createResultWidgets( m_entriesLayout, m_resultWidgets, *( m_config->requirementsModel() ), isUnSatisfied );
if ( !requirementsSatisfied ) if ( !requirementsSatisfied )
{ {
m_entriesLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() / 2 ); createResultWidgets( m_entriesLayout, m_resultWidgets, *( m_config->requirementsModel() ), isUnSatisfied );
m_mainLayout->addStretch();
} }
else else
{ {