From 0a4e6804c67e1d6effcfa0c6dc0604d5dd097c14 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 20 May 2022 18:10:22 +0200 Subject: [PATCH] [partition] Move encryption state-calculation to state() Previously, state() just returned a stored state, which changed via updateState(). However, when updateState() started taking visibility-of-the-widget into account, it became possible to de-sync the *apparent* state of the encryption widget, from the stored one: - make an encryption widget, which is not visible - show it. Now the stored-state takes visibility into account that is different (hidden, so we end up with a state of Unconfirmed) from the apparent value (shown and unchecked). Move the calculation to state() instead, so whenever queried, it checks the current checks-and-visibility values. Restore the previously-reverted bit for accepting LUKS partitions. SEE #1935 SEE #1953 --- src/modules/partition/gui/EncryptWidget.cpp | 39 +++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index d5cd08aaa..7c17de7af 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -85,7 +85,26 @@ EncryptWidget::reset( bool checkVisible ) EncryptWidget::Encryption EncryptWidget::state() const { - return m_state; + Encryption newState = Encryption::Unconfirmed; + + if ( m_ui->m_encryptCheckBox->isChecked() || !m_ui->m_encryptCheckBox->isVisible() ) + { + if ( !m_ui->m_passphraseLineEdit->text().isEmpty() + && m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() ) + { + newState = Encryption::Confirmed; + } + else + { + newState = Encryption::Unconfirmed; + } + } + else + { + newState = Encryption::Disabled; + } + + return newState; } @@ -148,23 +167,7 @@ EncryptWidget::updateState() } } - Encryption newState; - if ( m_ui->m_encryptCheckBox->isChecked() ) - { - if ( !m_ui->m_passphraseLineEdit->text().isEmpty() - && m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() ) - { - newState = Encryption::Confirmed; - } - else - { - newState = Encryption::Unconfirmed; - } - } - else - { - newState = Encryption::Disabled; - } + Encryption newState = state(); if ( newState != m_state ) {