diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index a7ae2915c5..9270d35b26 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -275,6 +275,8 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->BrowseSourceDirectoryButton,
&QAbstractButton::clicked, this,
&CMakeSetupDialog::doSourceBrowse);
+ QObject::connect(this->ReloadPresetsButton, &QAbstractButton::clicked,
+ this->CMakeThread->cmakeInstance(), &QCMake::loadPresets);
QObject::connect(this->BrowseBinaryDirectoryButton,
&QAbstractButton::clicked, this,
&CMakeSetupDialog::doBinaryBrowse);
diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui
index c17c4140b6..0289b0a110 100644
--- a/Source/QtDialog/CMakeSetupDialog.ui
+++ b/Source/QtDialog/CMakeSetupDialog.ui
@@ -74,6 +74,13 @@
+ -
+
+
+ Reload &presets
+
+
+
-
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index dac4f532f9..f81f10711c 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -64,17 +64,6 @@ QCMake::QCMake(QObject* p)
for (cmake::GeneratorInfo const& gen : generators) {
this->AvailableGenerators.push_back(gen);
}
-
- connect(&this->LoadPresetsTimer, &QTimer::timeout, this, [this]() {
- this->loadPresets();
- if (!this->PresetName.isEmpty() &&
- this->CMakePresetsGraph.ConfigurePresets.find(
- std::string(this->PresetName.toStdString())) ==
- this->CMakePresetsGraph.ConfigurePresets.end()) {
- this->setPreset(QString{});
- }
- });
- this->LoadPresetsTimer.start(1000);
}
QCMake::~QCMake() = default;
@@ -572,13 +561,12 @@ void QCMake::loadPresets()
{
auto result = this->CMakePresetsGraph.ReadProjectPresets(
this->SourceDirectory.toStdString(), true);
- if (result != this->LastLoadPresetsResult && !result) {
+ if (!result) {
emit this->presetLoadError(
this->SourceDirectory,
QString::fromStdString(
this->CMakePresetsGraph.parseState.GetErrorMessage(false)));
}
- this->LastLoadPresetsResult = result;
QVector presets;
for (auto const& name : this->CMakePresetsGraph.ConfigurePresetOrder) {
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 71e86568b6..2bffd70d86 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -124,6 +124,8 @@ public slots:
void setWarnUninitializedMode(bool value);
/// check if project IDE open is possible and emit openPossible signal
void checkOpenPossible();
+ /// Reload the preset files and tree
+ void loadPresets();
public:
/// get the list of cache properties
@@ -193,8 +195,6 @@ protected:
void stderrCallback(std::string const& msg);
void setUpEnvironment() const;
- void loadPresets();
-
bool WarnUninitializedMode;
QString SourceDirectory;
QString BinaryDirectory;
@@ -204,11 +204,9 @@ protected:
QString Toolset;
std::vector AvailableGenerators;
cmCMakePresetsGraph CMakePresetsGraph;
- bool LastLoadPresetsResult = true;
QString PresetName;
QString CMakeExecutable;
QAtomicInt InterruptFlag;
QProcessEnvironment StartEnvironment;
QProcessEnvironment Environment;
- QTimer LoadPresetsTimer;
};
diff --git a/Tests/CMakeGUI/CMakeGUITest.cxx b/Tests/CMakeGUI/CMakeGUITest.cxx
index a3414fd744..d4fdfc81f0 100644
--- a/Tests/CMakeGUI/CMakeGUITest.cxx
+++ b/Tests/CMakeGUI/CMakeGUITest.cxx
@@ -359,13 +359,15 @@ void CMakeGUITest::changingPresets()
QCOMPARE(this->m_window->Preset->isEnabled(), false);
writePresets("build1", { "preset" });
- loopSleep(1500);
+ this->m_window->ReloadPresetsButton->click();
+ loopSleep();
QCOMPARE(this->m_window->Preset->presetName(), QString{});
QCOMPARE(this->m_window->Preset->presets().size(), 1);
QCOMPARE(this->m_window->BinaryDirectory->currentText(), "");
QCOMPARE(this->m_window->Preset->isEnabled(), true);
this->m_window->Preset->setPresetName("preset");
+ this->m_window->ReloadPresetsButton->click();
loopSleep();
QCOMPARE(this->m_window->Preset->presetName(), "preset");
QCOMPARE(this->m_window->Preset->presets().size(), 1);
@@ -374,7 +376,8 @@ void CMakeGUITest::changingPresets()
QCOMPARE(this->m_window->Preset->isEnabled(), true);
writePresets("build2", { "preset2", "preset" });
- loopSleep(1500);
+ this->m_window->ReloadPresetsButton->click();
+ loopSleep();
QCOMPARE(this->m_window->Preset->presetName(), "preset");
QCOMPARE(this->m_window->Preset->presets().size(), 2);
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
@@ -382,7 +385,8 @@ void CMakeGUITest::changingPresets()
QCOMPARE(this->m_window->Preset->isEnabled(), true);
writePresets("build3", { "preset2" });
- loopSleep(1500);
+ this->m_window->ReloadPresetsButton->click();
+ loopSleep();
QCOMPARE(this->m_window->Preset->presetName(), QString{});
QCOMPARE(this->m_window->Preset->presets().size(), 1);
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
@@ -420,7 +424,8 @@ void CMakeGUITest::changingPresets()
QFile(CMakeGUITest_BINARY_DIR "/changingPresets/src2/CMakePresets.json")
.remove();
- loopSleep(1500);
+ this->m_window->ReloadPresetsButton->click();
+ loopSleep();
QCOMPARE(this->m_window->Preset->presetName(), QString{});
QCOMPARE(this->m_window->Preset->presets().size(), 0);
QCOMPARE(this->m_window->BinaryDirectory->currentText(),