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::registerTestTool(&theCTestTool());
TestFrameworkManager::synchronizeSettings();
m_resultsPane = TestResultsPane::instance();

View File

@@ -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)

View File

@@ -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()

View File

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

View File

@@ -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()

View File

@@ -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)

View File

@@ -21,6 +21,8 @@ QuickTestFramework::QuickTestFramework()
setId(QuickTest::Constants::FRAMEWORK_ID);
setDisplayName(Tr::tr("Quick Test"));
setPriority(5);
readSettings();
}
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

View File

@@ -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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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
}

View File

@@ -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

View File

@@ -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);