diff options
author | Adriaan de Groot <groot@kde.org> | 2019-02-12 07:21:35 -0500 |
---|---|---|
committer | Adriaan de Groot <groot@kde.org> | 2019-02-12 07:21:35 -0500 |
commit | 5f20eedb6e0f11731848f4252d778cacebfd4459 (patch) | |
tree | 94ea1d03b21ac9b03232a0f0c89202d35caf0fbe | |
parent | a4e6d4cd3548217fd6a843d0b47dbbb1c12e9c15 (diff) |
[partition] Use swap-choice member, not the combobox pointer
- Store changes to the selected swap-choice when the combobox changes
- Use that member instead of dereferencing the combobox
This avoids nullptr crashes when the combobox isn't even created
(e.g. when there is only one swap choice).
-rw-r--r-- | src/modules/partition/gui/ChoicePage.cpp | 13 | ||||
-rw-r--r-- | src/modules/partition/gui/ChoicePage.h | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index f62af013f..ee7905c33 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -318,7 +318,7 @@ ChoicePage::setupChoices() this, &ChoicePage::onActionChanged ); if ( m_eraseSwapChoiceComboBox ) connect( m_eraseSwapChoiceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), - this, &ChoicePage::onActionChanged ); + this, &ChoicePage::onEraseSwapChoiceChanged ); CALAMARES_RETRANSLATE( m_somethingElseButton->setText( tr( "<strong>Manual partitioning</strong><br/>" @@ -428,6 +428,15 @@ ChoicePage::onActionChanged() } } +void +ChoicePage::onEraseSwapChoiceChanged() +{ + if ( m_eraseSwapChoiceComboBox ) + { + m_eraseSwapChoice = static_cast<PartitionActions::Choices::SwapChoice>( m_eraseSwapChoiceComboBox->currentData().toInt() ); + onActionChanged(); + } +} void ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice ) @@ -448,7 +457,7 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice ) m_encryptWidget->passphrase(), gs->value( "efiSystemPartition" ).toString(), CalamaresUtils::GiBtoBytes( gs->value( "requiredStorageGB" ).toDouble() ), - static_cast<PartitionActions::Choices::SwapChoice>( m_eraseSwapChoiceComboBox->currentData().toInt() ) + m_eraseSwapChoice }; if ( m_core->isDirty() ) diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 527a59e1a..baf575d49 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -116,8 +116,10 @@ private slots: void onEncryptWidgetStateChanged(); void onHomeCheckBoxStateChanged(); - /** @brief Calls applyActionChoice() as needed. */ + /// @brief Calls applyActionChoice() as needed. void onActionChanged(); + /// @brief Calls onActionChanged() as needed. + void onEraseSwapChoiceChanged(); private: void updateNextEnabled(); |