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 <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-11-03 15:44:38 +01:00
parent dce08c5b9e
commit 824fee183c
14 changed files with 43 additions and 31 deletions

View File

@@ -136,7 +136,6 @@ AutotestPluginPrivate::AutotestPluginPrivate()
TestFrameworkManager::registerTestFramework(&theCatchFramework()); TestFrameworkManager::registerTestFramework(&theCatchFramework());
TestFrameworkManager::registerTestTool(&theCTestTool()); TestFrameworkManager::registerTestTool(&theCTestTool());
TestFrameworkManager::synchronizeSettings();
m_resultsPane = TestResultsPane::instance(); m_resultsPane = TestResultsPane::instance();

View File

@@ -74,7 +74,6 @@ BoostTestFramework::BoostTestFramework()
seed.setLabelText(Tr::tr("Seed:")); seed.setLabelText(Tr::tr("Seed:"));
seed.setToolTip(Tr::tr("A seed of 0 means no randomization. A value of 1 uses the current " 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.")); "time, any other value is used as random seed generator."));
seed.setEnabler(&randomize);
randomize.setSettingsKey("Randomize"); randomize.setSettingsKey("Randomize");
randomize.setLabelPlacement(BoolAspect::LabelPlacement::Compact); randomize.setLabelPlacement(BoolAspect::LabelPlacement::Compact);
@@ -96,6 +95,10 @@ BoostTestFramework::BoostTestFramework()
memLeaks.setDefaultValue(true); memLeaks.setDefaultValue(true);
memLeaks.setLabelText(Tr::tr("Detect memory leaks")); memLeaks.setLabelText(Tr::tr("Detect memory leaks"));
memLeaks.setToolTip(Tr::tr("Enable memory leak detection.")); memLeaks.setToolTip(Tr::tr("Enable memory leak detection."));
readSettings();
seed.setEnabler(&randomize);
} }
QString BoostTestFramework::logLevelToOption(const LogLevel logLevel) QString BoostTestFramework::logLevelToOption(const LogLevel logLevel)

View File

@@ -49,29 +49,24 @@ CatchFramework::CatchFramework()
abortAfter.setSettingsKey("AbortAfter"); abortAfter.setSettingsKey("AbortAfter");
abortAfter.setRange(1, 9999); abortAfter.setRange(1, 9999);
abortAfter.setEnabler(&abortAfterChecked);
benchmarkSamples.setSettingsKey("BenchSamples"); benchmarkSamples.setSettingsKey("BenchSamples");
benchmarkSamples.setRange(1, 999999); benchmarkSamples.setRange(1, 999999);
benchmarkSamples.setDefaultValue(100); benchmarkSamples.setDefaultValue(100);
benchmarkSamples.setEnabler(&samplesChecked);
benchmarkResamples.setSettingsKey("BenchResamples"); benchmarkResamples.setSettingsKey("BenchResamples");
benchmarkResamples.setRange(1, 9999999); benchmarkResamples.setRange(1, 9999999);
benchmarkResamples.setDefaultValue(100000); benchmarkResamples.setDefaultValue(100000);
benchmarkResamples.setToolTip(Tr::tr("Number of resamples for bootstrapping.")); benchmarkResamples.setToolTip(Tr::tr("Number of resamples for bootstrapping."));
benchmarkResamples.setEnabler(&resamplesChecked);
confidenceInterval.setSettingsKey("BenchConfInt"); confidenceInterval.setSettingsKey("BenchConfInt");
confidenceInterval.setRange(0., 1.); confidenceInterval.setRange(0., 1.);
confidenceInterval.setSingleStep(0.05); confidenceInterval.setSingleStep(0.05);
confidenceInterval.setDefaultValue(0.95); confidenceInterval.setDefaultValue(0.95);
confidenceInterval.setEnabler(&confidenceIntervalChecked);
benchmarkWarmupTime.setSettingsKey("BenchWarmup"); benchmarkWarmupTime.setSettingsKey("BenchWarmup");
benchmarkWarmupTime.setSuffix(Tr::tr(" ms")); benchmarkWarmupTime.setSuffix(Tr::tr(" ms"));
benchmarkWarmupTime.setRange(0, 10000); benchmarkWarmupTime.setRange(0, 10000);
benchmarkWarmupTime.setEnabler(&warmupChecked);
abortAfterChecked.setSettingsKey("AbortChecked"); abortAfterChecked.setSettingsKey("AbortChecked");
abortAfterChecked.setLabelText(Tr::tr("Abort after")); abortAfterChecked.setLabelText(Tr::tr("Abort after"));
@@ -117,6 +112,14 @@ CatchFramework::CatchFramework()
warnOnEmpty.setSettingsKey("WarnEmpty"); warnOnEmpty.setSettingsKey("WarnEmpty");
warnOnEmpty.setLabelText(Tr::tr("Warn on empty tests")); warnOnEmpty.setLabelText(Tr::tr("Warn on empty tests"));
warnOnEmpty.setToolTip(Tr::tr("Warns if a test section does not check any assertion.")); 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() ITestParser *CatchFramework::createTestParser()

View File

@@ -108,6 +108,9 @@ CTestTool::CTestTool()
threshold.setLabelText(Tr::tr("Threshold")); threshold.setLabelText(Tr::tr("Threshold"));
threshold.setDefaultValue(1); threshold.setDefaultValue(1);
threshold.setRange(1, 128); threshold.setRange(1, 128);
readSettings();
threshold.setEnabler(&testLoad); threshold.setEnabler(&testLoad);
} }

View File

@@ -52,7 +52,6 @@ GTestFramework::GTestFramework()
iterations.setDefaultValue(1); iterations.setDefaultValue(1);
iterations.setEnabled(false); iterations.setEnabled(false);
iterations.setLabelText(Tr::tr("Iterations:")); iterations.setLabelText(Tr::tr("Iterations:"));
iterations.setEnabler(&repeat);
seed.setSettingsKey("Seed"); seed.setSettingsKey("Seed");
seed.setSpecialValueText({}); seed.setSpecialValueText({});
@@ -60,7 +59,6 @@ GTestFramework::GTestFramework()
seed.setEnabled(false); seed.setEnabled(false);
seed.setLabelText(Tr::tr("Seed:")); seed.setLabelText(Tr::tr("Seed:"));
seed.setToolTip(Tr::tr("A seed of 0 generates a seed based on the current timestamp.")); seed.setToolTip(Tr::tr("A seed of 0 generates a seed based on the current timestamp."));
seed.setEnabler(&shuffle);
runDisabled.setSettingsKey("RunDisabled"); runDisabled.setSettingsKey("RunDisabled");
runDisabled.setLabelText(Tr::tr("Run disabled tests")); runDisabled.setLabelText(Tr::tr("Run disabled tests"));
@@ -132,6 +130,11 @@ GTestFramework::GTestFramework()
connect(this, &AspectContainer::applied, this, [] { connect(this, &AspectContainer::applied, this, [] {
TestTreeModel::instance()->rebuild({GTest::Constants::FRAMEWORK_ID}); TestTreeModel::instance()->rebuild({GTest::Constants::FRAMEWORK_ID});
}); });
readSettings();
seed.setEnabler(&shuffle);
iterations.setEnabler(&repeat);
} }
ITestParser *GTestFramework::createTestParser() ITestParser *GTestFramework::createTestParser()

View File

@@ -92,7 +92,6 @@ QtTestFramework::QtTestFramework()
maxWarnings.setRange(0, 10000); maxWarnings.setRange(0, 10000);
maxWarnings.setDefaultValue(2000); maxWarnings.setDefaultValue(2000);
maxWarnings.setSpecialValueText(Tr::tr("Unlimited")); maxWarnings.setSpecialValueText(Tr::tr("Unlimited"));
maxWarnings.setEnabler(&limitWarnings);
quickCheckForDerivedTests.setSettingsKey("QuickCheckForDerivedTests"); quickCheckForDerivedTests.setSettingsKey("QuickCheckForDerivedTests");
quickCheckForDerivedTests.setDefaultValue(false); quickCheckForDerivedTests.setDefaultValue(false);
@@ -100,6 +99,10 @@ QtTestFramework::QtTestFramework()
quickCheckForDerivedTests.setToolTip( quickCheckForDerivedTests.setToolTip(
Tr::tr("Search for Qt Quick tests that are derived from TestCase.\nWarning: Enabling this " Tr::tr("Search for Qt Quick tests that are derived from TestCase.\nWarning: Enabling this "
"feature significantly increases scan time.")); "feature significantly increases scan time."));
readSettings();
maxWarnings.setEnabler(&limitWarnings);
} }
QString QtTestFramework::metricsTypeToOption(const MetricsType type) QString QtTestFramework::metricsTypeToOption(const MetricsType type)

View File

@@ -21,6 +21,8 @@ QuickTestFramework::QuickTestFramework()
setId(QuickTest::Constants::FRAMEWORK_ID); setId(QuickTest::Constants::FRAMEWORK_ID);
setDisplayName(Tr::tr("Quick Test")); setDisplayName(Tr::tr("Quick Test"));
setPriority(5); setPriority(5);
readSettings();
} }
ITestParser *QuickTestFramework::createTestParser() ITestParser *QuickTestFramework::createTestParser()

View File

@@ -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 } // Autotest::TestframeworkManager

View File

@@ -9,7 +9,6 @@ namespace Autotest::TestFrameworkManager {
void registerTestFramework(ITestFramework *framework); void registerTestFramework(ITestFramework *framework);
void registerTestTool(ITestTool *testTool); void registerTestTool(ITestTool *testTool);
void synchronizeSettings();
ITestFramework *frameworkForId(Utils::Id frameworkId); ITestFramework *frameworkForId(Utils::Id frameworkId);
ITestTool *testToolForId(Utils::Id testToolId); ITestTool *testToolForId(Utils::Id testToolId);

View File

@@ -64,7 +64,6 @@ TestSettings::TestSettings()
resultDescriptionMaxSize.setSettingsKey("ResultDescriptionMaxSize"); resultDescriptionMaxSize.setSettingsKey("ResultDescriptionMaxSize");
resultDescriptionMaxSize.setDefaultValue(10); resultDescriptionMaxSize.setDefaultValue(10);
resultDescriptionMaxSize.setRange(1, 100000); resultDescriptionMaxSize.setRange(1, 100000);
resultDescriptionMaxSize.setEnabler(&limitResultDescription);
autoScroll.setSettingsKey("AutoScrollResults"); autoScroll.setSettingsKey("AutoScrollResults");
autoScroll.setDefaultValue(true); autoScroll.setDefaultValue(true);
@@ -95,7 +94,6 @@ TestSettings::TestSettings()
popupOnFail.setSettingsKey("PopupOnFail"); popupOnFail.setSettingsKey("PopupOnFail");
popupOnFail.setLabelText(Tr::tr("Only for unsuccessful test runs")); 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 " popupOnFail.setToolTip(Tr::tr("Displays test results only if the test run contains "
"failed, fatal or unexpectedly passed tests.")); "failed, fatal or unexpectedly passed tests."));
@@ -105,6 +103,11 @@ TestSettings::TestSettings()
runAfterBuild.addOption(Tr::tr("None")); runAfterBuild.addOption(Tr::tr("None"));
runAfterBuild.addOption(Tr::tr("All")); runAfterBuild.addOption(Tr::tr("All"));
runAfterBuild.addOption(Tr::tr("Selected")); runAfterBuild.addOption(Tr::tr("Selected"));
fromSettings();
resultDescriptionMaxSize.setEnabler(&limitResultDescription);
popupOnFail.setEnabler(&popupOnFinish);
} }
void TestSettings::toSettings() const void TestSettings::toSettings() const

View File

@@ -85,7 +85,6 @@ SystemSettings::SystemSettings()
autoSaveInterval.setSuffix(Tr::tr("min")); autoSaveInterval.setSuffix(Tr::tr("min"));
autoSaveInterval.setRange(1, 1000000); autoSaveInterval.setRange(1, 1000000);
autoSaveInterval.setDefaultValue(5); autoSaveInterval.setDefaultValue(5);
autoSaveInterval.setEnabler(&autoSaveModifiedFiles);
autoSaveInterval.setLabelText(Tr::tr("Interval:")); autoSaveInterval.setLabelText(Tr::tr("Interval:"));
autoSaveAfterRefactoring.setSettingsKey("EditorManager/AutoSaveAfterRefactoring"); autoSaveAfterRefactoring.setSettingsKey("EditorManager/AutoSaveAfterRefactoring");
@@ -107,7 +106,6 @@ SystemSettings::SystemSettings()
autoSuspendMinDocumentCount.setSettingsKey("EditorManager/AutoSuspendMinDocuments"); autoSuspendMinDocumentCount.setSettingsKey("EditorManager/AutoSuspendMinDocuments");
autoSuspendMinDocumentCount.setRange(1, 500); autoSuspendMinDocumentCount.setRange(1, 500);
autoSuspendMinDocumentCount.setDefaultValue(30); autoSuspendMinDocumentCount.setDefaultValue(30);
autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled);
autoSuspendMinDocumentCount.setLabelText(Tr::tr("Files to keep open:")); autoSuspendMinDocumentCount.setLabelText(Tr::tr("Files to keep open:"));
autoSuspendMinDocumentCount.setToolTip( autoSuspendMinDocumentCount.setToolTip(
Tr::tr("Minimum number of open documents that should be kept in memory. Increasing this " 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.setSuffix(Tr::tr("MB"));
bigFileSizeLimitInMB.setRange(1, 500); bigFileSizeLimitInMB.setRange(1, 500);
bigFileSizeLimitInMB.setDefaultValue(5); bigFileSizeLimitInMB.setDefaultValue(5);
bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles);
maxRecentFiles.setSettingsKey("EditorManager/MaxRecentFiles"); maxRecentFiles.setSettingsKey("EditorManager/MaxRecentFiles");
maxRecentFiles.setRange(1, 99); maxRecentFiles.setRange(1, 99);
@@ -151,6 +148,11 @@ SystemSettings::SystemSettings()
showCrashButton.setSettingsKey("ShowCrashButton"); showCrashButton.setSettingsKey("ShowCrashButton");
#endif #endif
readSettings(); readSettings();
autoSaveInterval.setEnabler(&autoSaveModifiedFiles);
autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled);
bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles);
connect(&autoSaveModifiedFiles, &BaseAspect::changed, connect(&autoSaveModifiedFiles, &BaseAspect::changed,
this, &EditorManagerPrivate::updateAutoSave); this, &EditorManagerPrivate::updateAutoSave);
connect(&autoSaveInterval, &BaseAspect::changed, this, &EditorManagerPrivate::updateAutoSave); connect(&autoSaveInterval, &BaseAspect::changed, this, &EditorManagerPrivate::updateAutoSave);

View File

@@ -156,8 +156,6 @@ FakeVimSettings::FakeVimSettings()
Row ints { shiftWidth, tabStop, scrollOff, st }; Row ints { shiftWidth, tabStop, scrollOff, st };
vimRcPath.setEnabler(&readVimRc);
Column strings { Column strings {
backspace, backspace,
isKeyword, isKeyword,
@@ -239,6 +237,8 @@ FakeVimSettings::FakeVimSettings()
readSettings(); readSettings();
vimRcPath.setEnabler(&readVimRc);
#endif #endif
} }

View File

@@ -40,7 +40,6 @@ QmlProfilerSettings::QmlProfilerSettings()
flushInterval.setRange(1, 10000000); flushInterval.setRange(1, 10000000);
flushInterval.setDefaultValue(1000); flushInterval.setDefaultValue(1000);
flushInterval.setLabelText(Tr::tr("Flush interval (ms):")); flushInterval.setLabelText(Tr::tr("Flush interval (ms):"));
flushInterval.setEnabler(&flushEnabled);
lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile"); lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");
@@ -63,6 +62,8 @@ QmlProfilerSettings::QmlProfilerSettings()
}); });
readSettings(); readSettings();
flushInterval.setEnabler(&flushEnabled);
} }
// QmlProfilerSettingsPage // QmlProfilerSettingsPage

View File

@@ -113,7 +113,6 @@ ScreenRecorderSettings::ScreenRecorderSettings()
fileSizeLimit.setDefaultValue(1024); fileSizeLimit.setDefaultValue(1024);
fileSizeLimit.setRange(100, 1024 * 1024 * 2); // Up to 2GB fileSizeLimit.setRange(100, 1024 * 1024 * 2); // Up to 2GB
fileSizeLimit.setSuffix("MB"); fileSizeLimit.setSuffix("MB");
fileSizeLimit.setEnabler(&enableFileSizeLimit);
enableRtBuffer.setSettingsKey("EnableRealTimeBuffer"); enableRtBuffer.setSettingsKey("EnableRealTimeBuffer");
enableRtBuffer.setDefaultValue(true); enableRtBuffer.setDefaultValue(true);
@@ -124,7 +123,6 @@ ScreenRecorderSettings::ScreenRecorderSettings()
rtBufferSize.setDefaultValue(1024); rtBufferSize.setDefaultValue(1024);
rtBufferSize.setRange(100, 1024 * 1024 * 2); // Up to 2GB rtBufferSize.setRange(100, 1024 * 1024 * 2); // Up to 2GB
rtBufferSize.setSuffix("MB"); rtBufferSize.setSuffix("MB");
rtBufferSize.setEnabler(&enableRtBuffer);
logFfmpegCommandline.setSettingsKey("LogFFMpegCommandLine"); logFfmpegCommandline.setSettingsKey("LogFFMpegCommandLine");
logFfmpegCommandline.setDefaultValue(false); logFfmpegCommandline.setDefaultValue(false);
@@ -206,6 +204,9 @@ ScreenRecorderSettings::ScreenRecorderSettings()
readSettings(); readSettings();
rtBufferSize.setEnabler(&enableRtBuffer);
fileSizeLimit.setEnabler(&enableFileSizeLimit);
setCaptureMouseClicksVisible(); setCaptureMouseClicksVisible();
connect(&screenCaptureType, &SelectionAspect::volatileValueChanged, this, connect(&screenCaptureType, &SelectionAspect::volatileValueChanged, this,
setCaptureMouseClicksVisible); setCaptureMouseClicksVisible);