From 824fee183c5653a4077775c072759601fa8086f8 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 3 Nov 2023 15:44:38 +0100 Subject: [PATCH] Fix setEnabler / readSettings order BaseAspect::setEnabler requires the settings to be read already. This is because readSettings() does not emit "valueChanged", and so the connections from the enabler to the target are not triggered. Change-Id: I0c95e2b516cd03c1dbad653288b44510ec7ea800 Reviewed-by: Christian Stenger --- src/plugins/autotest/autotestplugin.cpp | 1 - src/plugins/autotest/boost/boosttestframework.cpp | 5 ++++- src/plugins/autotest/catch/catchtestframework.cpp | 13 ++++++++----- src/plugins/autotest/ctest/ctesttool.cpp | 3 +++ src/plugins/autotest/gtest/gtestframework.cpp | 7 +++++-- src/plugins/autotest/qtest/qttestframework.cpp | 5 ++++- src/plugins/autotest/quick/quicktestframework.cpp | 2 ++ src/plugins/autotest/testframeworkmanager.cpp | 10 ---------- src/plugins/autotest/testframeworkmanager.h | 1 - src/plugins/autotest/testsettings.cpp | 7 +++++-- src/plugins/coreplugin/systemsettings.cpp | 8 +++++--- src/plugins/fakevim/fakevimactions.cpp | 4 ++-- src/plugins/qmlprofiler/qmlprofilersettings.cpp | 3 ++- .../screenrecorder/screenrecordersettings.cpp | 5 +++-- 14 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 0f93fb7dc75..67b264dcd00 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -136,7 +136,6 @@ AutotestPluginPrivate::AutotestPluginPrivate() TestFrameworkManager::registerTestFramework(&theCatchFramework()); TestFrameworkManager::registerTestTool(&theCTestTool()); - TestFrameworkManager::synchronizeSettings(); m_resultsPane = TestResultsPane::instance(); diff --git a/src/plugins/autotest/boost/boosttestframework.cpp b/src/plugins/autotest/boost/boosttestframework.cpp index 38f800357b4..9addde077b0 100644 --- a/src/plugins/autotest/boost/boosttestframework.cpp +++ b/src/plugins/autotest/boost/boosttestframework.cpp @@ -74,7 +74,6 @@ BoostTestFramework::BoostTestFramework() seed.setLabelText(Tr::tr("Seed:")); seed.setToolTip(Tr::tr("A seed of 0 means no randomization. A value of 1 uses the current " "time, any other value is used as random seed generator.")); - seed.setEnabler(&randomize); randomize.setSettingsKey("Randomize"); randomize.setLabelPlacement(BoolAspect::LabelPlacement::Compact); @@ -96,6 +95,10 @@ BoostTestFramework::BoostTestFramework() memLeaks.setDefaultValue(true); memLeaks.setLabelText(Tr::tr("Detect memory leaks")); memLeaks.setToolTip(Tr::tr("Enable memory leak detection.")); + + readSettings(); + + seed.setEnabler(&randomize); } QString BoostTestFramework::logLevelToOption(const LogLevel logLevel) diff --git a/src/plugins/autotest/catch/catchtestframework.cpp b/src/plugins/autotest/catch/catchtestframework.cpp index 8c312f65d15..a8ac1e9faab 100644 --- a/src/plugins/autotest/catch/catchtestframework.cpp +++ b/src/plugins/autotest/catch/catchtestframework.cpp @@ -49,29 +49,24 @@ CatchFramework::CatchFramework() abortAfter.setSettingsKey("AbortAfter"); abortAfter.setRange(1, 9999); - abortAfter.setEnabler(&abortAfterChecked); benchmarkSamples.setSettingsKey("BenchSamples"); benchmarkSamples.setRange(1, 999999); benchmarkSamples.setDefaultValue(100); - benchmarkSamples.setEnabler(&samplesChecked); benchmarkResamples.setSettingsKey("BenchResamples"); benchmarkResamples.setRange(1, 9999999); benchmarkResamples.setDefaultValue(100000); benchmarkResamples.setToolTip(Tr::tr("Number of resamples for bootstrapping.")); - benchmarkResamples.setEnabler(&resamplesChecked); confidenceInterval.setSettingsKey("BenchConfInt"); confidenceInterval.setRange(0., 1.); confidenceInterval.setSingleStep(0.05); confidenceInterval.setDefaultValue(0.95); - confidenceInterval.setEnabler(&confidenceIntervalChecked); benchmarkWarmupTime.setSettingsKey("BenchWarmup"); benchmarkWarmupTime.setSuffix(Tr::tr(" ms")); benchmarkWarmupTime.setRange(0, 10000); - benchmarkWarmupTime.setEnabler(&warmupChecked); abortAfterChecked.setSettingsKey("AbortChecked"); abortAfterChecked.setLabelText(Tr::tr("Abort after")); @@ -117,6 +112,14 @@ CatchFramework::CatchFramework() warnOnEmpty.setSettingsKey("WarnEmpty"); warnOnEmpty.setLabelText(Tr::tr("Warn on empty tests")); warnOnEmpty.setToolTip(Tr::tr("Warns if a test section does not check any assertion.")); + + readSettings(); + + benchmarkWarmupTime.setEnabler(&warmupChecked); + confidenceInterval.setEnabler(&confidenceIntervalChecked); + benchmarkResamples.setEnabler(&resamplesChecked); + benchmarkSamples.setEnabler(&samplesChecked); + abortAfter.setEnabler(&abortAfterChecked); } ITestParser *CatchFramework::createTestParser() diff --git a/src/plugins/autotest/ctest/ctesttool.cpp b/src/plugins/autotest/ctest/ctesttool.cpp index 2dee957194f..8b82953e2c4 100644 --- a/src/plugins/autotest/ctest/ctesttool.cpp +++ b/src/plugins/autotest/ctest/ctesttool.cpp @@ -108,6 +108,9 @@ CTestTool::CTestTool() threshold.setLabelText(Tr::tr("Threshold")); threshold.setDefaultValue(1); threshold.setRange(1, 128); + + readSettings(); + threshold.setEnabler(&testLoad); } diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index 191ffc82c29..f07de8ed52a 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -52,7 +52,6 @@ GTestFramework::GTestFramework() iterations.setDefaultValue(1); iterations.setEnabled(false); iterations.setLabelText(Tr::tr("Iterations:")); - iterations.setEnabler(&repeat); seed.setSettingsKey("Seed"); seed.setSpecialValueText({}); @@ -60,7 +59,6 @@ GTestFramework::GTestFramework() seed.setEnabled(false); seed.setLabelText(Tr::tr("Seed:")); seed.setToolTip(Tr::tr("A seed of 0 generates a seed based on the current timestamp.")); - seed.setEnabler(&shuffle); runDisabled.setSettingsKey("RunDisabled"); runDisabled.setLabelText(Tr::tr("Run disabled tests")); @@ -132,6 +130,11 @@ GTestFramework::GTestFramework() connect(this, &AspectContainer::applied, this, [] { TestTreeModel::instance()->rebuild({GTest::Constants::FRAMEWORK_ID}); }); + + readSettings(); + + seed.setEnabler(&shuffle); + iterations.setEnabler(&repeat); } ITestParser *GTestFramework::createTestParser() diff --git a/src/plugins/autotest/qtest/qttestframework.cpp b/src/plugins/autotest/qtest/qttestframework.cpp index a406506a675..0f854ab6f59 100644 --- a/src/plugins/autotest/qtest/qttestframework.cpp +++ b/src/plugins/autotest/qtest/qttestframework.cpp @@ -92,7 +92,6 @@ QtTestFramework::QtTestFramework() maxWarnings.setRange(0, 10000); maxWarnings.setDefaultValue(2000); maxWarnings.setSpecialValueText(Tr::tr("Unlimited")); - maxWarnings.setEnabler(&limitWarnings); quickCheckForDerivedTests.setSettingsKey("QuickCheckForDerivedTests"); quickCheckForDerivedTests.setDefaultValue(false); @@ -100,6 +99,10 @@ QtTestFramework::QtTestFramework() quickCheckForDerivedTests.setToolTip( Tr::tr("Search for Qt Quick tests that are derived from TestCase.\nWarning: Enabling this " "feature significantly increases scan time.")); + + readSettings(); + + maxWarnings.setEnabler(&limitWarnings); } QString QtTestFramework::metricsTypeToOption(const MetricsType type) diff --git a/src/plugins/autotest/quick/quicktestframework.cpp b/src/plugins/autotest/quick/quicktestframework.cpp index 875520a5e70..724e6690d01 100644 --- a/src/plugins/autotest/quick/quicktestframework.cpp +++ b/src/plugins/autotest/quick/quicktestframework.cpp @@ -21,6 +21,8 @@ QuickTestFramework::QuickTestFramework() setId(QuickTest::Constants::FRAMEWORK_ID); setDisplayName(Tr::tr("Quick Test")); setPriority(5); + + readSettings(); } ITestParser *QuickTestFramework::createTestParser() diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp index d44dc3d1e7c..7d19e746c8b 100644 --- a/src/plugins/autotest/testframeworkmanager.cpp +++ b/src/plugins/autotest/testframeworkmanager.cpp @@ -86,14 +86,4 @@ ITestTool *testToolForBuildSystemId(Id buildSystemId) }); } -void synchronizeSettings() -{ - Internal::testSettings().fromSettings(); - for (ITestFramework *framework : std::as_const(testFrameworks())) - framework->readSettings(); - - for (ITestTool *testTool : std::as_const(testTools())) - testTool->readSettings(); -} - } // Autotest::TestframeworkManager diff --git a/src/plugins/autotest/testframeworkmanager.h b/src/plugins/autotest/testframeworkmanager.h index 9ced25d8fb9..48f521c863d 100644 --- a/src/plugins/autotest/testframeworkmanager.h +++ b/src/plugins/autotest/testframeworkmanager.h @@ -9,7 +9,6 @@ namespace Autotest::TestFrameworkManager { void registerTestFramework(ITestFramework *framework); void registerTestTool(ITestTool *testTool); -void synchronizeSettings(); ITestFramework *frameworkForId(Utils::Id frameworkId); ITestTool *testToolForId(Utils::Id testToolId); diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index 1d5230d711d..174773b757c 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -64,7 +64,6 @@ TestSettings::TestSettings() resultDescriptionMaxSize.setSettingsKey("ResultDescriptionMaxSize"); resultDescriptionMaxSize.setDefaultValue(10); resultDescriptionMaxSize.setRange(1, 100000); - resultDescriptionMaxSize.setEnabler(&limitResultDescription); autoScroll.setSettingsKey("AutoScrollResults"); autoScroll.setDefaultValue(true); @@ -95,7 +94,6 @@ TestSettings::TestSettings() popupOnFail.setSettingsKey("PopupOnFail"); popupOnFail.setLabelText(Tr::tr("Only for unsuccessful test runs")); - popupOnFail.setEnabler(&popupOnFinish); popupOnFail.setToolTip(Tr::tr("Displays test results only if the test run contains " "failed, fatal or unexpectedly passed tests.")); @@ -105,6 +103,11 @@ TestSettings::TestSettings() runAfterBuild.addOption(Tr::tr("None")); runAfterBuild.addOption(Tr::tr("All")); runAfterBuild.addOption(Tr::tr("Selected")); + + fromSettings(); + + resultDescriptionMaxSize.setEnabler(&limitResultDescription); + popupOnFail.setEnabler(&popupOnFinish); } void TestSettings::toSettings() const diff --git a/src/plugins/coreplugin/systemsettings.cpp b/src/plugins/coreplugin/systemsettings.cpp index 1477fcf747d..af4aef29113 100644 --- a/src/plugins/coreplugin/systemsettings.cpp +++ b/src/plugins/coreplugin/systemsettings.cpp @@ -85,7 +85,6 @@ SystemSettings::SystemSettings() autoSaveInterval.setSuffix(Tr::tr("min")); autoSaveInterval.setRange(1, 1000000); autoSaveInterval.setDefaultValue(5); - autoSaveInterval.setEnabler(&autoSaveModifiedFiles); autoSaveInterval.setLabelText(Tr::tr("Interval:")); autoSaveAfterRefactoring.setSettingsKey("EditorManager/AutoSaveAfterRefactoring"); @@ -107,7 +106,6 @@ SystemSettings::SystemSettings() autoSuspendMinDocumentCount.setSettingsKey("EditorManager/AutoSuspendMinDocuments"); autoSuspendMinDocumentCount.setRange(1, 500); autoSuspendMinDocumentCount.setDefaultValue(30); - autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled); autoSuspendMinDocumentCount.setLabelText(Tr::tr("Files to keep open:")); autoSuspendMinDocumentCount.setToolTip( Tr::tr("Minimum number of open documents that should be kept in memory. Increasing this " @@ -122,7 +120,6 @@ SystemSettings::SystemSettings() bigFileSizeLimitInMB.setSuffix(Tr::tr("MB")); bigFileSizeLimitInMB.setRange(1, 500); bigFileSizeLimitInMB.setDefaultValue(5); - bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles); maxRecentFiles.setSettingsKey("EditorManager/MaxRecentFiles"); maxRecentFiles.setRange(1, 99); @@ -151,6 +148,11 @@ SystemSettings::SystemSettings() showCrashButton.setSettingsKey("ShowCrashButton"); #endif readSettings(); + + autoSaveInterval.setEnabler(&autoSaveModifiedFiles); + autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled); + bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles); + connect(&autoSaveModifiedFiles, &BaseAspect::changed, this, &EditorManagerPrivate::updateAutoSave); connect(&autoSaveInterval, &BaseAspect::changed, this, &EditorManagerPrivate::updateAutoSave); diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp index b4d568c7f07..a7c0eee43a2 100644 --- a/src/plugins/fakevim/fakevimactions.cpp +++ b/src/plugins/fakevim/fakevimactions.cpp @@ -156,8 +156,6 @@ FakeVimSettings::FakeVimSettings() Row ints { shiftWidth, tabStop, scrollOff, st }; - vimRcPath.setEnabler(&readVimRc); - Column strings { backspace, isKeyword, @@ -239,6 +237,8 @@ FakeVimSettings::FakeVimSettings() readSettings(); + vimRcPath.setEnabler(&readVimRc); + #endif } diff --git a/src/plugins/qmlprofiler/qmlprofilersettings.cpp b/src/plugins/qmlprofiler/qmlprofilersettings.cpp index 9bbac157414..32063ec947b 100644 --- a/src/plugins/qmlprofiler/qmlprofilersettings.cpp +++ b/src/plugins/qmlprofiler/qmlprofilersettings.cpp @@ -40,7 +40,6 @@ QmlProfilerSettings::QmlProfilerSettings() flushInterval.setRange(1, 10000000); flushInterval.setDefaultValue(1000); flushInterval.setLabelText(Tr::tr("Flush interval (ms):")); - flushInterval.setEnabler(&flushEnabled); lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile"); @@ -63,6 +62,8 @@ QmlProfilerSettings::QmlProfilerSettings() }); readSettings(); + + flushInterval.setEnabler(&flushEnabled); } // QmlProfilerSettingsPage diff --git a/src/plugins/screenrecorder/screenrecordersettings.cpp b/src/plugins/screenrecorder/screenrecordersettings.cpp index cc00f6da065..0a94638f855 100644 --- a/src/plugins/screenrecorder/screenrecordersettings.cpp +++ b/src/plugins/screenrecorder/screenrecordersettings.cpp @@ -113,7 +113,6 @@ ScreenRecorderSettings::ScreenRecorderSettings() fileSizeLimit.setDefaultValue(1024); fileSizeLimit.setRange(100, 1024 * 1024 * 2); // Up to 2GB fileSizeLimit.setSuffix("MB"); - fileSizeLimit.setEnabler(&enableFileSizeLimit); enableRtBuffer.setSettingsKey("EnableRealTimeBuffer"); enableRtBuffer.setDefaultValue(true); @@ -124,7 +123,6 @@ ScreenRecorderSettings::ScreenRecorderSettings() rtBufferSize.setDefaultValue(1024); rtBufferSize.setRange(100, 1024 * 1024 * 2); // Up to 2GB rtBufferSize.setSuffix("MB"); - rtBufferSize.setEnabler(&enableRtBuffer); logFfmpegCommandline.setSettingsKey("LogFFMpegCommandLine"); logFfmpegCommandline.setDefaultValue(false); @@ -206,6 +204,9 @@ ScreenRecorderSettings::ScreenRecorderSettings() readSettings(); + rtBufferSize.setEnabler(&enableRtBuffer); + fileSizeLimit.setEnabler(&enableFileSizeLimit); + setCaptureMouseClicksVisible(); connect(&screenCaptureType, &SelectionAspect::volatileValueChanged, this, setCaptureMouseClicksVisible);