Utils: Warn if enabler is set before readSettings

Change-Id: If3dd3fc5adbcd73a87f8e57482c7497c3cd11da2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-11-07 15:15:03 +01:00
parent 55227ba829
commit 772546453a

View File

@@ -83,6 +83,7 @@ public:
bool m_enabled = true;
bool m_readOnly = false;
bool m_autoApply = true;
bool m_hasEnabler = false;
int m_spanX = 1;
int m_spanY = 1;
BaseAspect::ConfigWidgetCreator m_configWidgetCreator;
@@ -347,6 +348,8 @@ void BaseAspect::setEnabler(BoolAspect *checker)
{
QTC_ASSERT(checker, return);
d->m_hasEnabler = true;
auto update = [this, checker] {
BaseAspect::setEnabled(checker->isEnabled() && checker->volatileValue());
};
@@ -646,6 +649,10 @@ void BaseAspect::readSettings()
if (settingsKey().isEmpty())
return;
QTC_ASSERT(theSettings, return);
// The enabler needs to be set up after reading the settings, otherwise
// changes from reading the settings will not update the enabled state
// because the updates are "quiet".
QTC_CHECK(!d->m_hasEnabler);
const QVariant val = theSettings->value(settingsKey());
setVariantValue(val.isValid() ? fromSettingsValue(val) : defaultVariantValue(), BeQuiet);
}