mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-04 14:50:23 +00:00
cmake-gui: Add 'Reload Presets' button, replacing reload timer
Previously the presets handler in the GUI was on a timer. Because of this, error messages got suppressed after the first one (even if the error message is different from the one originally suppressed). Add a "reload presets" button which forces the preset to reload, and always provides an error message if the reload failed. Fixes: #26707
This commit is contained in:
@@ -275,6 +275,8 @@ void CMakeSetupDialog::initialize()
|
|||||||
QObject::connect(this->BrowseSourceDirectoryButton,
|
QObject::connect(this->BrowseSourceDirectoryButton,
|
||||||
&QAbstractButton::clicked, this,
|
&QAbstractButton::clicked, this,
|
||||||
&CMakeSetupDialog::doSourceBrowse);
|
&CMakeSetupDialog::doSourceBrowse);
|
||||||
|
QObject::connect(this->ReloadPresetsButton, &QAbstractButton::clicked,
|
||||||
|
this->CMakeThread->cmakeInstance(), &QCMake::loadPresets);
|
||||||
QObject::connect(this->BrowseBinaryDirectoryButton,
|
QObject::connect(this->BrowseBinaryDirectoryButton,
|
||||||
&QAbstractButton::clicked, this,
|
&QAbstractButton::clicked, this,
|
||||||
&CMakeSetupDialog::doBinaryBrowse);
|
&CMakeSetupDialog::doBinaryBrowse);
|
||||||
|
|||||||
@@ -74,6 +74,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="ReloadPresetsButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reload &presets</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="BinaryLabel">
|
<widget class="QLabel" name="BinaryLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
@@ -64,17 +64,6 @@ QCMake::QCMake(QObject* p)
|
|||||||
for (cmake::GeneratorInfo const& gen : generators) {
|
for (cmake::GeneratorInfo const& gen : generators) {
|
||||||
this->AvailableGenerators.push_back(gen);
|
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;
|
QCMake::~QCMake() = default;
|
||||||
@@ -572,13 +561,12 @@ void QCMake::loadPresets()
|
|||||||
{
|
{
|
||||||
auto result = this->CMakePresetsGraph.ReadProjectPresets(
|
auto result = this->CMakePresetsGraph.ReadProjectPresets(
|
||||||
this->SourceDirectory.toStdString(), true);
|
this->SourceDirectory.toStdString(), true);
|
||||||
if (result != this->LastLoadPresetsResult && !result) {
|
if (!result) {
|
||||||
emit this->presetLoadError(
|
emit this->presetLoadError(
|
||||||
this->SourceDirectory,
|
this->SourceDirectory,
|
||||||
QString::fromStdString(
|
QString::fromStdString(
|
||||||
this->CMakePresetsGraph.parseState.GetErrorMessage(false)));
|
this->CMakePresetsGraph.parseState.GetErrorMessage(false)));
|
||||||
}
|
}
|
||||||
this->LastLoadPresetsResult = result;
|
|
||||||
|
|
||||||
QVector<QCMakePreset> presets;
|
QVector<QCMakePreset> presets;
|
||||||
for (auto const& name : this->CMakePresetsGraph.ConfigurePresetOrder) {
|
for (auto const& name : this->CMakePresetsGraph.ConfigurePresetOrder) {
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ public slots:
|
|||||||
void setWarnUninitializedMode(bool value);
|
void setWarnUninitializedMode(bool value);
|
||||||
/// check if project IDE open is possible and emit openPossible signal
|
/// check if project IDE open is possible and emit openPossible signal
|
||||||
void checkOpenPossible();
|
void checkOpenPossible();
|
||||||
|
/// Reload the preset files and tree
|
||||||
|
void loadPresets();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// get the list of cache properties
|
/// get the list of cache properties
|
||||||
@@ -193,8 +195,6 @@ protected:
|
|||||||
void stderrCallback(std::string const& msg);
|
void stderrCallback(std::string const& msg);
|
||||||
void setUpEnvironment() const;
|
void setUpEnvironment() const;
|
||||||
|
|
||||||
void loadPresets();
|
|
||||||
|
|
||||||
bool WarnUninitializedMode;
|
bool WarnUninitializedMode;
|
||||||
QString SourceDirectory;
|
QString SourceDirectory;
|
||||||
QString BinaryDirectory;
|
QString BinaryDirectory;
|
||||||
@@ -204,11 +204,9 @@ protected:
|
|||||||
QString Toolset;
|
QString Toolset;
|
||||||
std::vector<cmake::GeneratorInfo> AvailableGenerators;
|
std::vector<cmake::GeneratorInfo> AvailableGenerators;
|
||||||
cmCMakePresetsGraph CMakePresetsGraph;
|
cmCMakePresetsGraph CMakePresetsGraph;
|
||||||
bool LastLoadPresetsResult = true;
|
|
||||||
QString PresetName;
|
QString PresetName;
|
||||||
QString CMakeExecutable;
|
QString CMakeExecutable;
|
||||||
QAtomicInt InterruptFlag;
|
QAtomicInt InterruptFlag;
|
||||||
QProcessEnvironment StartEnvironment;
|
QProcessEnvironment StartEnvironment;
|
||||||
QProcessEnvironment Environment;
|
QProcessEnvironment Environment;
|
||||||
QTimer LoadPresetsTimer;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -359,13 +359,15 @@ void CMakeGUITest::changingPresets()
|
|||||||
QCOMPARE(this->m_window->Preset->isEnabled(), false);
|
QCOMPARE(this->m_window->Preset->isEnabled(), false);
|
||||||
|
|
||||||
writePresets("build1", { "preset" });
|
writePresets("build1", { "preset" });
|
||||||
loopSleep(1500);
|
this->m_window->ReloadPresetsButton->click();
|
||||||
|
loopSleep();
|
||||||
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
||||||
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
||||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(), "");
|
QCOMPARE(this->m_window->BinaryDirectory->currentText(), "");
|
||||||
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
||||||
|
|
||||||
this->m_window->Preset->setPresetName("preset");
|
this->m_window->Preset->setPresetName("preset");
|
||||||
|
this->m_window->ReloadPresetsButton->click();
|
||||||
loopSleep();
|
loopSleep();
|
||||||
QCOMPARE(this->m_window->Preset->presetName(), "preset");
|
QCOMPARE(this->m_window->Preset->presetName(), "preset");
|
||||||
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
||||||
@@ -374,7 +376,8 @@ void CMakeGUITest::changingPresets()
|
|||||||
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
||||||
|
|
||||||
writePresets("build2", { "preset2", "preset" });
|
writePresets("build2", { "preset2", "preset" });
|
||||||
loopSleep(1500);
|
this->m_window->ReloadPresetsButton->click();
|
||||||
|
loopSleep();
|
||||||
QCOMPARE(this->m_window->Preset->presetName(), "preset");
|
QCOMPARE(this->m_window->Preset->presetName(), "preset");
|
||||||
QCOMPARE(this->m_window->Preset->presets().size(), 2);
|
QCOMPARE(this->m_window->Preset->presets().size(), 2);
|
||||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
||||||
@@ -382,7 +385,8 @@ void CMakeGUITest::changingPresets()
|
|||||||
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
QCOMPARE(this->m_window->Preset->isEnabled(), true);
|
||||||
|
|
||||||
writePresets("build3", { "preset2" });
|
writePresets("build3", { "preset2" });
|
||||||
loopSleep(1500);
|
this->m_window->ReloadPresetsButton->click();
|
||||||
|
loopSleep();
|
||||||
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
||||||
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
QCOMPARE(this->m_window->Preset->presets().size(), 1);
|
||||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
||||||
@@ -420,7 +424,8 @@ void CMakeGUITest::changingPresets()
|
|||||||
|
|
||||||
QFile(CMakeGUITest_BINARY_DIR "/changingPresets/src2/CMakePresets.json")
|
QFile(CMakeGUITest_BINARY_DIR "/changingPresets/src2/CMakePresets.json")
|
||||||
.remove();
|
.remove();
|
||||||
loopSleep(1500);
|
this->m_window->ReloadPresetsButton->click();
|
||||||
|
loopSleep();
|
||||||
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
QCOMPARE(this->m_window->Preset->presetName(), QString{});
|
||||||
QCOMPARE(this->m_window->Preset->presets().size(), 0);
|
QCOMPARE(this->m_window->Preset->presets().size(), 0);
|
||||||
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
QCOMPARE(this->m_window->BinaryDirectory->currentText(),
|
||||||
|
|||||||
Reference in New Issue
Block a user