summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog
diff options
context:
space:
mode:
authorMartin Duffy <martin.duffy@kitware.com>2023-03-22 17:11:21 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-29 14:41:19 (GMT)
commit19305afd8a2a46925b1a880de68f7be0ad1f3091 (patch)
treecdef4417cd852c2a5dd85886df4ff61d7fd2e653 /Source/QtDialog
parent6b08358e17f5b85ad04ab512e4b6e39e989cea35 (diff)
downloadCMake-19305afd8a2a46925b1a880de68f7be0ad1f3091.zip
CMake-19305afd8a2a46925b1a880de68f7be0ad1f3091.tar.gz
CMake-19305afd8a2a46925b1a880de68f7be0ad1f3091.tar.bz2
presets: Improve JSON parser and error messages
Diffstat (limited to 'Source/QtDialog')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx7
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h3
-rw-r--r--Source/QtDialog/QCMake.cxx9
-rw-r--r--Source/QtDialog/QCMake.h7
4 files changed, 11 insertions, 15 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 1effdd3..ab77818 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -732,13 +732,12 @@ void CMakeSetupDialog::updatePreset(const QString& name)
}
}
-void CMakeSetupDialog::showPresetLoadError(
- const QString& dir, cmCMakePresetsGraph::ReadFileResult result)
+void CMakeSetupDialog::showPresetLoadError(const QString& dir,
+ const QString& message)
{
QMessageBox::warning(
this, "Error Reading CMake Presets",
- QString("Could not read presets from %1: %2")
- .arg(dir, cmCMakePresetsGraph::ResultToString(result)));
+ QString("Could not read presets from %1: %2").arg(dir, message));
}
void CMakeSetupDialog::doBinaryBrowse()
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 8aee70d..d4c72cb 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -59,8 +59,7 @@ protected slots:
void updateBinaryDirectory(const QString& dir);
void updatePresets(const QVector<QCMakePreset>& presets);
void updatePreset(const QString& name);
- void showPresetLoadError(const QString& dir,
- cmCMakePresetsGraph::ReadFileResult result);
+ void showPresetLoadError(const QString& dir, const QString& message);
void showProgress(const QString& msg, float percent);
void setEnabledState(bool);
bool setupFirstConfigure();
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index ea02f98..6ed24ca 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -33,7 +33,6 @@ QCMake::QCMake(QObject* p)
qRegisterMetaType<QCMakePropertyList>();
qRegisterMetaType<QProcessEnvironment>();
qRegisterMetaType<QVector<QCMakePreset>>();
- qRegisterMetaType<cmCMakePresetsGraph::ReadFileResult>();
cmSystemTools::DisableRunCommandOutput();
cmSystemTools::SetRunCommandHideConsole(true);
@@ -530,9 +529,11 @@ void QCMake::loadPresets()
{
auto result = this->CMakePresetsGraph.ReadProjectPresets(
this->SourceDirectory.toStdString(), true);
- if (result != this->LastLoadPresetsResult &&
- result != cmCMakePresetsGraph::ReadFileResult::READ_OK) {
- emit this->presetLoadError(this->SourceDirectory, result);
+ if (result != this->LastLoadPresetsResult && !result) {
+ emit this->presetLoadError(
+ this->SourceDirectory,
+ QString::fromStdString(
+ this->CMakePresetsGraph.parseState.GetErrorMessage(false)));
}
this->LastLoadPresetsResult = result;
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 8a7e4cb..0890558 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -60,7 +60,6 @@ using QCMakePropertyList = QList<QCMakeProperty>;
Q_DECLARE_METATYPE(QCMakeProperty)
Q_DECLARE_METATYPE(QCMakePropertyList)
Q_DECLARE_METATYPE(QProcessEnvironment)
-Q_DECLARE_METATYPE(cmCMakePresetsGraph::ReadFileResult)
/// Qt API for CMake library.
/// Wrapper like class allows for easier integration with
@@ -158,8 +157,7 @@ signals:
/// signal when the selected preset changes
void presetChanged(const QString& name);
/// signal when there's an error reading the presets files
- void presetLoadError(const QString& dir,
- cmCMakePresetsGraph::ReadFileResult error);
+ void presetLoadError(const QString& dir, const QString& error);
/// signal when uninitialized warning changes
void warnUninitializedModeChanged(bool value);
/// signal for progress events
@@ -203,8 +201,7 @@ protected:
QString Toolset;
std::vector<cmake::GeneratorInfo> AvailableGenerators;
cmCMakePresetsGraph CMakePresetsGraph;
- cmCMakePresetsGraph::ReadFileResult LastLoadPresetsResult =
- cmCMakePresetsGraph::ReadFileResult::READ_OK;
+ bool LastLoadPresetsResult = true;
QString PresetName;
QString CMakeExecutable;
QAtomicInt InterruptFlag;