aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/androidbuildapkstep.cpp2
-rw-r--r--src/plugins/android/androidmanifesteditor.cpp4
-rw-r--r--src/plugins/android/androidpackageinstallationstep.cpp2
-rw-r--r--src/plugins/android/androidsdkdownloader.cpp2
-rw-r--r--src/plugins/android/androidsignaloperation.cpp14
-rw-r--r--src/plugins/baremetal/baremetaldebugsupport.cpp2
-rw-r--r--src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp8
-rw-r--r--src/plugins/baremetal/debugservers/gdb/gdbserverprovider.h2
-rw-r--r--src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp12
-rw-r--r--src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h2
-rw-r--r--src/plugins/baremetal/idebugserverprovider.h5
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp34
-rw-r--r--src/plugins/clangcodemodel/test/clangdtests.cpp6
-rw-r--r--src/plugins/clangtools/clangfixitsrefactoringchanges.cpp2
-rw-r--r--src/plugins/clangtools/virtualfilesystemoverlay.cpp4
-rw-r--r--src/plugins/cmakeprojectmanager/fileapireader.cpp2
-rw-r--r--src/plugins/compilerexplorer/compilerexplorereditor.cpp8
-rw-r--r--src/plugins/coreplugin/basefilewizard.cpp2
-rw-r--r--src/plugins/coreplugin/basefilewizardfactory.cpp6
-rw-r--r--src/plugins/coreplugin/basefilewizardfactory.h2
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp4
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp4
-rw-r--r--src/plugins/coreplugin/foldernavigationwidget.cpp2
-rw-r--r--src/plugins/coreplugin/generatedfile.cpp22
-rw-r--r--src/plugins/coreplugin/generatedfile.h8
-rw-r--r--src/plugins/coreplugin/idocument.cpp18
-rw-r--r--src/plugins/coreplugin/idocument.h8
-rw-r--r--src/plugins/coreplugin/outputwindow.cpp2
-rw-r--r--src/plugins/coreplugin/plugininstallwizard.cpp16
-rw-r--r--src/plugins/coreplugin/session.cpp6
-rw-r--r--src/plugins/coreplugin/textdocument.cpp4
-rw-r--r--src/plugins/coreplugin/textdocument.h4
-rw-r--r--src/plugins/cppeditor/cppeditordocument.cpp2
-rw-r--r--src/plugins/cppeditor/cppeditordocument.h2
-rw-r--r--src/plugins/debugger/cdb/cdbengine.cpp2
-rw-r--r--src/plugins/debugger/debuggerengine.cpp10
-rw-r--r--src/plugins/debugger/debuggerengine.h4
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp10
-rw-r--r--src/plugins/debugger/debuggerprotocol.cpp2
-rw-r--r--src/plugins/debugger/debuggerprotocol.h2
-rw-r--r--src/plugins/debugger/debuggerruncontrol.cpp22
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp26
-rw-r--r--src/plugins/debugger/lldb/lldbengine.cpp2
-rw-r--r--src/plugins/debugger/loadcoredialog.cpp2
-rw-r--r--src/plugins/designer/formwindowfile.cpp20
-rw-r--r--src/plugins/designer/formwindowfile.h6
-rw-r--r--src/plugins/diffeditor/diffeditordocument.cpp14
-rw-r--r--src/plugins/diffeditor/diffeditordocument.h4
-rw-r--r--src/plugins/docker/dockercontainerthread.cpp16
-rw-r--r--src/plugins/docker/dockercontainerthread.h2
-rw-r--r--src/plugins/docker/dockerdevice.cpp6
-rw-r--r--src/plugins/docker/dockerdevice.h2
-rw-r--r--src/plugins/docker/dockerdevicewidget.cpp2
-rw-r--r--src/plugins/effectcomposer/effectcodeeditorwidget.cpp2
-rw-r--r--src/plugins/extensionmanager/remotespec.cpp12
-rw-r--r--src/plugins/extensionmanager/remotespec.h4
-rw-r--r--src/plugins/git/gitclient.cpp2
-rw-r--r--src/plugins/imageviewer/imageviewerfile.cpp6
-rw-r--r--src/plugins/imageviewer/imageviewerfile.h2
-rw-r--r--src/plugins/languageclient/languageclientutils.cpp2
-rw-r--r--src/plugins/lua/bindings/install.cpp2
-rw-r--r--src/plugins/modeleditor/modeldocument.cpp18
-rw-r--r--src/plugins/modeleditor/modeldocument.h4
-rw-r--r--src/plugins/perfprofiler/perfprofilertool.cpp2
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizard.cpp14
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizard.h2
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp10
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.h6
-rw-r--r--src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp30
-rw-r--r--src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.h4
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.cpp10
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.h6
-rw-r--r--src/plugins/projectexplorer/devicesupport/processlist.cpp2
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp10
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp2
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp20
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp54
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h28
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp12
-rw-r--r--src/plugins/projectexplorer/project.cpp4
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp30
-rw-r--r--src/plugins/projectexplorer/projectexplorer.h2
-rw-r--r--src/plugins/projectexplorer/taskfile.cpp6
-rw-r--r--src/plugins/projectexplorer/taskfile.h2
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp4
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp4
-rw-r--r--src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp2
-rw-r--r--src/plugins/qmldesigner/documentmanager.cpp2
-rw-r--r--src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp4
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp2
-rw-r--r--src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp4
-rw-r--r--src/plugins/qtsupport/gettingstartedwelcomepage.cpp2
-rw-r--r--src/plugins/remotelinux/filesystemaccess_test.cpp2
-rw-r--r--src/plugins/remotelinux/genericdeploystep.cpp12
-rw-r--r--src/plugins/remotelinux/linuxdevice.cpp22
-rw-r--r--src/plugins/remotelinux/publickeydeploymentdialog.cpp8
-rw-r--r--src/plugins/remotelinux/publickeydeploymentdialog.h9
-rw-r--r--src/plugins/remotelinux/remotelinuxfiletransfer.cpp24
-rw-r--r--src/plugins/remotelinux/remotelinuxsignaloperation.cpp6
-rw-r--r--src/plugins/remotelinux/sshkeycreationdialog.cpp6
-rw-r--r--src/plugins/resourceeditor/qrceditor/resourcefile.cpp4
-rw-r--r--src/plugins/resourceeditor/resourceeditor.cpp20
-rw-r--r--src/plugins/resourceeditor/resourcenode.cpp6
-rw-r--r--src/plugins/scxmleditor/scxmleditordocument.cpp16
-rw-r--r--src/plugins/scxmleditor/scxmleditordocument.h4
-rw-r--r--src/plugins/squish/objectsmapdocument.cpp14
-rw-r--r--src/plugins/squish/objectsmapdocument.h4
-rw-r--r--src/plugins/squish/squishfilehandler.cpp2
-rw-r--r--src/plugins/squish/squishtesttreeview.cpp2
-rw-r--r--src/plugins/squish/squishwizardpages.cpp26
-rw-r--r--src/plugins/squish/suiteconf.cpp2
-rw-r--r--src/plugins/terminal/shellintegration.cpp10
-rw-r--r--src/plugins/texteditor/refactoringchanges.cpp4
-rw-r--r--src/plugins/texteditor/textdocument.cpp24
-rw-r--r--src/plugins/texteditor/textdocument.h10
-rw-r--r--src/plugins/texteditor/texteditor.cpp2
-rw-r--r--src/plugins/valgrind/callgrindtool.cpp2
-rw-r--r--src/plugins/valgrind/memchecktool.cpp6
-rw-r--r--src/plugins/valgrind/xmlprotocol/parser.cpp8
-rw-r--r--src/plugins/valgrind/xmlprotocol/parser.h8
-rw-r--r--src/plugins/vcsbase/submiteditorfile.cpp10
-rw-r--r--src/plugins/vcsbase/submiteditorfile.h2
122 files changed, 493 insertions, 493 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp
index 0a7a9d03c2e..5d0bf2b5d11 100644
--- a/src/plugins/android/androidbuildapkstep.cpp
+++ b/src/plugins/android/androidbuildapkstep.cpp
@@ -892,7 +892,7 @@ static bool copyFileIfNewer(const FilePath &sourceFilePath, const FilePath &dest
if (!destinationFilePath.parentDir().ensureWritableDir())
return false;
- Result result = sourceFilePath.copyFile(destinationFilePath);
+ Result<> result = sourceFilePath.copyFile(destinationFilePath);
QTC_ASSERT_EXPECTED(result, return false);
return true;
}
diff --git a/src/plugins/android/androidmanifesteditor.cpp b/src/plugins/android/androidmanifesteditor.cpp
index 15bc23eb47a..2f03b622e6f 100644
--- a/src/plugins/android/androidmanifesteditor.cpp
+++ b/src/plugins/android/androidmanifesteditor.cpp
@@ -1883,10 +1883,10 @@ private:
bool isSaveAsAllowed() const override { return false; }
- Result saveImpl(const FilePath &filePath, bool autoSave) override
+ Result<> saveImpl(const FilePath &filePath, bool autoSave) override
{
m_editorWidget->preSave();
- Result result = TextDocument::saveImpl(filePath, autoSave);
+ Result<> result = TextDocument::saveImpl(filePath, autoSave);
m_editorWidget->postSave();
return result;
}
diff --git a/src/plugins/android/androidpackageinstallationstep.cpp b/src/plugins/android/androidpackageinstallationstep.cpp
index a3672f4425a..9d3f2df2ec7 100644
--- a/src/plugins/android/androidpackageinstallationstep.cpp
+++ b/src/plugins/android/androidpackageinstallationstep.cpp
@@ -135,7 +135,7 @@ Tasking::GroupItem AndroidPackageInstallationStep::runRecipe()
const FilePath androidDir = FilePath::fromString(dir);
if (!dir.isEmpty() && androidDir.exists()) {
emit addOutput(Tr::tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage);
- const Result result = androidDir.removeRecursively();
+ const Result<> result = androidDir.removeRecursively();
if (!result) {
reportWarningOrError(
Tr::tr("Failed to clean \"%1\" from the previous build, "
diff --git a/src/plugins/android/androidsdkdownloader.cpp b/src/plugins/android/androidsdkdownloader.cpp
index e113381a341..c4bae112da8 100644
--- a/src/plugins/android/androidsdkdownloader.cpp
+++ b/src/plugins/android/androidsdkdownloader.cpp
@@ -178,7 +178,7 @@ GroupItem downloadSdkRecipe()
if (result == DoneWith::Cancel)
return;
- const Result unarchiveResult = task.result();
+ const Result<> unarchiveResult = task.result();
if (!unarchiveResult) {
logError(Tr::tr("Unarchiving error: %1").arg(unarchiveResult.error()));
diff --git a/src/plugins/android/androidsignaloperation.cpp b/src/plugins/android/androidsignaloperation.cpp
index 247e90d7fb9..81d2fc1d363 100644
--- a/src/plugins/android/androidsignaloperation.cpp
+++ b/src/plugins/android/androidsignaloperation.cpp
@@ -20,7 +20,7 @@ void AndroidSignalOperation::signalOperationViaADB(qint64 pid, int signal)
struct InternalStorage {
FilePath adbPath = AndroidConfig::adbToolPath();
QString runAs = {};
- Result result = Result::Ok;
+ Result<> result = ResultOk;
};
const Storage<InternalStorage> storage;
@@ -33,15 +33,15 @@ void AndroidSignalOperation::signalOperationViaADB(qint64 pid, int signal)
storage->runAs = process.stdOut();
if (!storage->runAs.isEmpty())
return true;
- storage->result = Result::Error("Cannot find User for process: " + QString::number(pid));
+ storage->result = ResultError("Cannot find User for process: " + QString::number(pid));
} else if (result == DoneWith::Error) {
QString result = " adb process exit code: " + QString::number(process.exitCode());
const QString adbError = process.errorString();
if (!adbError.isEmpty())
result += " adb process error: " + adbError;
- storage->result = Result::Error(result);
+ storage->result = ResultError(result);
} else {
- storage->result = Result::Error("adb process timed out");
+ storage->result = ResultError("adb process timed out");
}
return false;
};
@@ -52,10 +52,10 @@ void AndroidSignalOperation::signalOperationViaADB(qint64 pid, int signal)
};
const auto onKillDone = [storage, pid](const Process &process, DoneWith result) {
if (result == DoneWith::Error) {
- storage->result = Result::Error("Cannot kill process: " + QString::number(pid)
+ storage->result = ResultError("Cannot kill process: " + QString::number(pid)
+ process.stdErr());
} else if (result == DoneWith::Cancel) {
- storage->result = Result::Error("adb process timed out");
+ storage->result = ResultError("adb process timed out");
}
};
@@ -78,7 +78,7 @@ void AndroidSignalOperation::killProcess(qint64 pid)
void AndroidSignalOperation::killProcess(const QString &filePath)
{
Q_UNUSED(filePath)
- emit finished(Result::Error("The android signal operation does not support killing by filepath."));
+ emit finished(ResultError("The android signal operation does not support killing by filepath."));
}
void AndroidSignalOperation::interruptProcess(qint64 pid)
diff --git a/src/plugins/baremetal/baremetaldebugsupport.cpp b/src/plugins/baremetal/baremetaldebugsupport.cpp
index cd021db7bc5..085e068ac68 100644
--- a/src/plugins/baremetal/baremetaldebugsupport.cpp
+++ b/src/plugins/baremetal/baremetaldebugsupport.cpp
@@ -58,7 +58,7 @@ public:
if (RunWorker *runner = p->targetRunner(runControl))
debugger->addStartDependency(runner);
- if (Result res = p->setupDebuggerRunParameters(debugger->runParameters(), runControl); !res)
+ if (Result<> res = p->setupDebuggerRunParameters(debugger->runParameters(), runControl); !res)
debugger->reportFailure(res.error()); // TODO: reportFailure won't work from RunWorker's c'tor.
return debugger;
diff --git a/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp
index 1cca5f7e6eb..cb1c2d85cbe 100644
--- a/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp
+++ b/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp
@@ -127,17 +127,17 @@ bool GdbServerProvider::isValid() const
return !channelString().isEmpty();
}
-Result GdbServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp,
+Result<> GdbServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp,
RunControl *runControl) const
{
Q_UNUSED(runControl)
const CommandLine cmd = rp.inferior().command;
const FilePath bin = FilePath::fromString(cmd.executable().path());
if (bin.isEmpty()) {
- return Result::Error(Tr::tr("Cannot debug: Local executable is not set."));
+ return ResultError(Tr::tr("Cannot debug: Local executable is not set."));
}
if (!bin.exists()) {
- return Result::Error(Tr::tr("Cannot debug: Could not find executable for \"%1\".")
+ return ResultError(Tr::tr("Cannot debug: Could not find executable for \"%1\".")
.arg(bin.toUserOutput()));
}
@@ -153,7 +153,7 @@ Result GdbServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp,
rp.setUseContinueInsteadOfRun(true);
rp.setUseExtendedRemote(useExtendedRemote());
rp.setPeripheralDescriptionFile(m_peripheralDescriptionFile);
- return Result::Ok;
+ return ResultOk;
}
RunWorker *GdbServerProvider::targetRunner(RunControl *runControl) const
diff --git a/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.h b/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.h
index 110831a4c48..8ce041a6cc1 100644
--- a/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.h
+++ b/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.h
@@ -37,7 +37,7 @@ public:
virtual Utils::CommandLine command() const;
- Utils::Result setupDebuggerRunParameters(Debugger::DebuggerRunParameters &rp,
+ Utils::Result<> setupDebuggerRunParameters(Debugger::DebuggerRunParameters &rp,
ProjectExplorer::RunControl *runControl) const final;
ProjectExplorer::RunWorker *targetRunner(
ProjectExplorer::RunControl *runControl) const override;
diff --git a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp
index 41a767c8649..8bc4385c628 100644
--- a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp
+++ b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp
@@ -159,25 +159,25 @@ QString UvscServerProvider::channelString() const
return m_channel.toString();
}
-Result UvscServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp,
+Result<> UvscServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp,
RunControl *runControl) const
{
const FilePath bin = rp.inferior().command.executable();
if (bin.isEmpty()) {
- return Result::Error(Tr::tr("Cannot debug: Local executable is not set."));
+ return ResultError(Tr::tr("Cannot debug: Local executable is not set."));
} else if (!bin.exists()) {
- return Result::Error(Tr::tr("Cannot debug: Could not find executable for \"%1\".")
+ return ResultError(Tr::tr("Cannot debug: Could not find executable for \"%1\".")
.arg(bin.toUserOutput()));
}
QString errorMessage;
const FilePath projFilePath = projectFilePath(runControl, errorMessage);
if (!projFilePath.exists())
- return Result::Error(errorMessage);
+ return ResultError(errorMessage);
const FilePath optFilePath = optionsFilePath(runControl, errorMessage);
if (!optFilePath.exists())
- return Result::Error(errorMessage);
+ return ResultError(errorMessage);
const FilePath peripheralDescriptionFile = FilePath::fromString(m_deviceSelection.svd);
@@ -192,7 +192,7 @@ Result UvscServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp,
rp.setStartMode(AttachToRemoteServer);
rp.setRemoteChannel(channelString());
rp.setUseContinueInsteadOfRun(true);
- return Result::Ok;
+ return ResultOk;
}
ProjectExplorer::RunWorker *UvscServerProvider::targetRunner(RunControl *runControl) const
diff --git a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h
index bd4a04c4183..61636cd0319 100644
--- a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h
+++ b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h
@@ -47,7 +47,7 @@ public:
void toMap(Utils::Store &map) const override;
- Utils::Result setupDebuggerRunParameters(Debugger::DebuggerRunParameters &rp,
+ Utils::Result<> setupDebuggerRunParameters(Debugger::DebuggerRunParameters &rp,
ProjectExplorer::RunControl *runControl) const final;
ProjectExplorer::RunWorker *targetRunner(ProjectExplorer::RunControl *runControl) const final;
diff --git a/src/plugins/baremetal/idebugserverprovider.h b/src/plugins/baremetal/idebugserverprovider.h
index 4f21d70d275..375e2021a35 100644
--- a/src/plugins/baremetal/idebugserverprovider.h
+++ b/src/plugins/baremetal/idebugserverprovider.h
@@ -9,6 +9,7 @@
#include <utils/filepath.h>
#include <utils/store.h>
+#include <utils/result.h>
#include <QSet>
#include <QUrl>
@@ -28,8 +29,6 @@ class RunControl;
class RunWorker;
}
-namespace Utils { class Result; }
-
namespace BareMetal::Internal {
class BareMetalDevice;
@@ -69,7 +68,7 @@ public:
virtual void toMap(Utils::Store &data) const;
virtual void fromMap(const Utils::Store &data);
- virtual Utils::Result setupDebuggerRunParameters(Debugger::DebuggerRunParameters &rp,
+ virtual Utils::Result<> setupDebuggerRunParameters(Debugger::DebuggerRunParameters &rp,
ProjectExplorer::RunControl *runControl) const = 0;
virtual ProjectExplorer::RunWorker *targetRunner(
ProjectExplorer::RunControl *runControl) const = 0;
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index b952c1e3ae3..d70aa77cdf7 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -119,8 +119,8 @@ public:
bool isSaveAsAllowed() const final { return true; }
- Utils::Result reload(ReloadFlag flag, ChangeType type) final;
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) final;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) final;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) final;
void fetchData(quint64 address) const { if (m_fetchDataHandler) m_fetchDataHandler(address); }
void requestNewWindow(quint64 address) { if (m_newWindowRequestHandler) m_newWindowRequestHandler(address); }
@@ -156,7 +156,7 @@ public:
void addData(quint64 addr, const QByteArray &data);
void updateContents();
- Result save(const FilePath &oldFilePath, const FilePath &newFilePath);
+ Result<> save(const FilePath &oldFilePath, const FilePath &newFilePath);
void clear();
void undo();
@@ -614,7 +614,7 @@ void BinEditorDocument::setModified(bool modified)
emit changed();
}
-Result BinEditorDocument::save(const FilePath &oldFilePath, const FilePath &newFilePath)
+Result<> BinEditorDocument::save(const FilePath &oldFilePath, const FilePath &newFilePath)
{
if (oldFilePath != newFilePath) {
// Get a unique temporary file name
@@ -623,19 +623,19 @@ Result BinEditorDocument::save(const FilePath &oldFilePath, const FilePath &newF
const auto result = TemporaryFilePath::create(
newFilePath.stringAppended("_XXXXXX.new"));
if (!result)
- return Result::Error(result.error());
+ return ResultError(result.error());
tmpName = (*result)->filePath();
}
- if (Result res = oldFilePath.copyFile(tmpName); !res)
+ if (Result<> res = oldFilePath.copyFile(tmpName); !res)
return res;
if (newFilePath.exists()) {
- if (Result res = newFilePath.removeFile(); !res)
+ if (Result<> res = newFilePath.removeFile(); !res)
return res;
}
- if (Result res = tmpName.renameFile(newFilePath); !res)
+ if (Result<> res = tmpName.renameFile(newFilePath); !res)
return res;
}
@@ -661,10 +661,10 @@ Result BinEditorDocument::save(const FilePath &oldFilePath, const FilePath &newF
QString errorString;
if (!saver.finalize(&errorString))
- return Result::Error(errorString);
+ return ResultError(errorString);
setModified(false);
- return Result::Ok;
+ return ResultOk;
}
void BinEditorDocument::setSizes(quint64 startAddr, qint64 range, int blockSize)
@@ -2182,26 +2182,26 @@ bool BinEditorDocument::isModified() const
return m_undoStack.size() != m_unmodifiedState;
}
-Result BinEditorDocument::reload(ReloadFlag flag, ChangeType type)
+Result<> BinEditorDocument::reload(ReloadFlag flag, ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
emit aboutToReload();
clear();
QString errorString;
const bool success = (openImpl(&errorString, filePath()) == OpenResult::Success);
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
-Result BinEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> BinEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
- QTC_ASSERT(!autoSave, return Result::Ok); // bineditor does not support autosave - it would be a bit expensive
- if (Result res = save(this->filePath(), filePath); !res)
+ QTC_ASSERT(!autoSave, return ResultOk); // bineditor does not support autosave - it would be a bit expensive
+ if (Result<> res = save(this->filePath(), filePath); !res)
return res;
setFilePath(filePath);
- return Result::Ok;
+ return ResultOk;
}
class BinEditorImpl final : public IEditor, public EditorService
diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp
index 8a3072a47fd..45b4f33913e 100644
--- a/src/plugins/clangcodemodel/test/clangdtests.cpp
+++ b/src/plugins/clangcodemodel/test/clangdtests.cpp
@@ -1994,8 +1994,10 @@ void ClangdTestCompletion::testCompleteAfterProjectChange()
EditorManager::openEditor(project()->projectFilePath()));
QVERIFY(proFileEditor);
proFileEditor->insert("DEFINES += PROJECT_CONFIGURATION_1\n");
- const Result res = proFileEditor->document()->save();
- QVERIFY2(res, qPrintable(res.error()));
+ const Result<> res = proFileEditor->document()->save();
+ QVERIFY(res);
+ if (!res)
+ QVERIFY2(false, qPrintable(res.error()));
QVERIFY(waitForSignalOrTimeout(project(), &Project::anyParsingFinished, timeOutInMs()));
QVERIFY(waitForSignalOrTimeout(LanguageClientManager::instance(),
&LanguageClientManager::clientRemoved,
diff --git a/src/plugins/clangtools/clangfixitsrefactoringchanges.cpp b/src/plugins/clangtools/clangfixitsrefactoringchanges.cpp
index 7cebab6ba1a..d52f1233709 100644
--- a/src/plugins/clangtools/clangfixitsrefactoringchanges.cpp
+++ b/src/plugins/clangtools/clangfixitsrefactoringchanges.cpp
@@ -101,7 +101,7 @@ bool FixitsRefactoringFile::apply()
return false; // Error reading file
for (auto it = m_documents.begin(); it != m_documents.end(); ++it) {
- if (const Result res = m_textFileFormat.writeFile(it.key(), it.value()->toPlainText()); !res) {
+ if (const Result<> res = m_textFileFormat.writeFile(it.key(), it.value()->toPlainText()); !res) {
qCDebug(fixitsLog) << "ERROR: Could not write file" << it.key() << ":" << res.error();
return false; // Error writing file
}
diff --git a/src/plugins/clangtools/virtualfilesystemoverlay.cpp b/src/plugins/clangtools/virtualfilesystemoverlay.cpp
index f3a25f9b013..3517dfe387e 100644
--- a/src/plugins/clangtools/virtualfilesystemoverlay.cpp
+++ b/src/plugins/clangtools/virtualfilesystemoverlay.cpp
@@ -41,7 +41,7 @@ void VirtualFileSystemOverlay::update()
saved.path = m_root.filePath(doc->filePath().fileName() + ".auto");
while (saved.path.exists())
saved.path = saved.path.stringAppended(".1");
- if (Utils::Result res = doc->save(saved.path, true); !res) {
+ if (Utils::Result<> res = doc->save(saved.path, true); !res) {
qCDebug(LOG) << res.error();
continue;
}
@@ -50,7 +50,7 @@ void VirtualFileSystemOverlay::update()
}
for (const AutoSavedPath &path : std::as_const(m_saved)) {
- Utils::Result result = path.path.removeRecursively();
+ Utils::Result<> result = path.path.removeRecursively();
if (!result)
qCDebug(LOG) << result.error();
}
diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp
index 3d668e21abb..127a3be9665 100644
--- a/src/plugins/cmakeprojectmanager/fileapireader.cpp
+++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp
@@ -321,7 +321,7 @@ void FileApiReader::makeBackupConfiguration(bool store)
std::swap(cmakeCacheTxt, cmakeCacheTxtPrev);
if (cmakeCacheTxt.exists()) {
- if (Result res = FileUtils::copyIfDifferent(cmakeCacheTxt, cmakeCacheTxtPrev); !res) {
+ if (Result<> res = FileUtils::copyIfDifferent(cmakeCacheTxt, cmakeCacheTxtPrev); !res) {
Core::MessageManager::writeFlashing(addCMakePrefix(
Tr::tr("Failed to copy \"%1\" to \"%2\": %3")
.arg(cmakeCacheTxt.toUserOutput(), cmakeCacheTxtPrev.toUserOutput(), res.error())));
diff --git a/src/plugins/compilerexplorer/compilerexplorereditor.cpp b/src/plugins/compilerexplorer/compilerexplorereditor.cpp
index bf515a85b7e..97293e26c42 100644
--- a/src/plugins/compilerexplorer/compilerexplorereditor.cpp
+++ b/src/plugins/compilerexplorer/compilerexplorereditor.cpp
@@ -154,7 +154,7 @@ public:
const Utils::FilePath &filePath,
const Utils::FilePath &realFilePath) override;
- Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
bool setContents(const QByteArray &contents) override;
@@ -408,7 +408,7 @@ Core::IDocument::OpenResult JsonSettingsDocument::open(QString *errorString,
return OpenResult::Success;
}
-Result JsonSettingsDocument::saveImpl(const FilePath &newFilePath, bool autoSave)
+Result<> JsonSettingsDocument::saveImpl(const FilePath &newFilePath, bool autoSave)
{
Store store;
@@ -434,10 +434,10 @@ Result JsonSettingsDocument::saveImpl(const FilePath &newFilePath, bool autoSave
expected_str<qint64> result = path.writeFileContents(jsonFromStore(store));
if (!result)
- return Result::Error(result.error());
+ return ResultError(result.error());
emit changed();
- return Result::Ok;
+ return ResultOk;
}
bool JsonSettingsDocument::isModified() const
diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp
index f1a461338a8..282d0081f12 100644
--- a/src/plugins/coreplugin/basefilewizard.cpp
+++ b/src/plugins/coreplugin/basefilewizard.cpp
@@ -78,7 +78,7 @@ void BaseFileWizard::accept()
}
// Write
- if (const Result res = m_factory->writeFiles(m_files); !res) {
+ if (const Result<> res = m_factory->writeFiles(m_files); !res) {
QMessageBox::critical(parentWidget(), Tr::tr("File Generation Failure"), res.error());
reject();
return;
diff --git a/src/plugins/coreplugin/basefilewizardfactory.cpp b/src/plugins/coreplugin/basefilewizardfactory.cpp
index 3a0e823435d..7935ce53b69 100644
--- a/src/plugins/coreplugin/basefilewizardfactory.cpp
+++ b/src/plugins/coreplugin/basefilewizardfactory.cpp
@@ -124,16 +124,16 @@ Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, Id platform,
GeneratedFile::CustomGeneratorAttribute set.
*/
-Result BaseFileWizardFactory::writeFiles(const GeneratedFiles &files) const
+Result<> BaseFileWizardFactory::writeFiles(const GeneratedFiles &files) const
{
const GeneratedFile::Attributes noWriteAttributes
= GeneratedFile::CustomGeneratorAttribute|GeneratedFile::KeepExistingFileAttribute;
for (const GeneratedFile &generatedFile : std::as_const(files)) {
if (!(generatedFile.attributes() & noWriteAttributes ))
- if (const Result res = generatedFile.write(); !res)
+ if (const Result<> res = generatedFile.write(); !res)
return res;
}
- return Result::Ok;
+ return ResultOk;
}
/*!
diff --git a/src/plugins/coreplugin/basefilewizardfactory.h b/src/plugins/coreplugin/basefilewizardfactory.h
index 47d74bb862f..6c36ef6f065 100644
--- a/src/plugins/coreplugin/basefilewizardfactory.h
+++ b/src/plugins/coreplugin/basefilewizardfactory.h
@@ -72,7 +72,7 @@ protected:
virtual GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const = 0;
- virtual Utils::Result writeFiles(const GeneratedFiles &files) const;
+ virtual Utils::Result<> writeFiles(const GeneratedFiles &files) const;
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage) const;
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index acfbcf30b69..125d3f475ec 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -714,7 +714,7 @@ bool DocumentManager::saveDocument(IDocument *document,
expectFileChange(savePath); // This only matters to other IDocuments which refer to this file
bool addWatcher = removeDocument(document); // So that our own IDocument gets no notification at all
- if (const Result res = document->save(savePath, false); !res) {
+ if (const Result<> res = document->save(savePath, false); !res) {
if (isReadOnly) {
QFile ofi(savePath.toUrlishString());
// Check whether the existing file is writable
@@ -1187,7 +1187,7 @@ void DocumentManager::checkForReload()
removeFileInfo(document);
addFileInfos({document});
- Result success = Result::Ok;
+ Result<> success = ResultOk;
// we've got some modification
document->checkPermissions();
// check if it's contents or permissions:
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 83c4fe866ed..1e701cbb4ba 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -2386,7 +2386,7 @@ void EditorManagerPrivate::autoSave()
if (document->filePath().isEmpty()
|| !savePath.isWritableDir()) // FIXME: save them to a dedicated directory
continue;
- if (Result res = document->autoSave(saveName); !res)
+ if (Result<> res = document->autoSave(saveName); !res)
errors << res.error();
}
if (!errors.isEmpty())
@@ -2614,7 +2614,7 @@ void EditorManagerPrivate::revertToSaved(IDocument *document)
}
}
- if (Result res = document->reload(IDocument::FlagReload, IDocument::TypeContents); !res)
+ if (Result<> res = document->reload(IDocument::FlagReload, IDocument::TypeContents); !res)
QMessageBox::critical(ICore::dialogParent(), ::Core::Tr::tr("File Error"), res.error());
}
diff --git a/src/plugins/coreplugin/foldernavigationwidget.cpp b/src/plugins/coreplugin/foldernavigationwidget.cpp
index 3d94c3a8ac5..2d488c74240 100644
--- a/src/plugins/coreplugin/foldernavigationwidget.cpp
+++ b/src/plugins/coreplugin/foldernavigationwidget.cpp
@@ -731,7 +731,7 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
RemoveFileDialog dialog(filePath, ICore::dialogParent());
dialog.setDeleteFileVisible(false);
if (dialog.exec() == QDialog::Accepted) {
- Utils::Result result = filePath.removeRecursively();
+ Utils::Result<> result = filePath.removeRecursively();
if (!result)
QMessageBox::critical(ICore::dialogParent(), Tr::tr("Error"), result.error());
}
diff --git a/src/plugins/coreplugin/generatedfile.cpp b/src/plugins/coreplugin/generatedfile.cpp
index fd4508a2560..9737467d5fc 100644
--- a/src/plugins/coreplugin/generatedfile.cpp
+++ b/src/plugins/coreplugin/generatedfile.cpp
@@ -37,8 +37,8 @@ public:
GeneratedFilePrivate() = default;
explicit GeneratedFilePrivate(const FilePath &path);
- Result writeContents() const;
- Result writePermissions() const;
+ Result<> writeContents() const;
+ Result<> writePermissions() const;
FilePath path;
std::optional<QFile::Permissions> permissions;
@@ -150,7 +150,7 @@ void GeneratedFile::setEditorId(Id id)
m_d->editorId = id;
}
-Result GeneratedFilePrivate::writeContents() const
+Result<> GeneratedFilePrivate::writeContents() const
{
if (binary) {
QIODevice::OpenMode flags = QIODevice::WriteOnly | QIODevice::Truncate;
@@ -158,7 +158,7 @@ Result GeneratedFilePrivate::writeContents() const
saver.write(contents);
QString errorMessage;
const bool ok = saver.finalize(&errorMessage);
- return ok ? Result::Ok : Result::Error(errorMessage);
+ return ok ? ResultOk : ResultError(errorMessage);
}
TextFileFormat format;
@@ -167,28 +167,28 @@ Result GeneratedFilePrivate::writeContents() const
return format.writeFile(path, QString::fromUtf8(contents));
}
-Result GeneratedFilePrivate::writePermissions() const
+Result<> GeneratedFilePrivate::writePermissions() const
{
if (!permissions)
- return Result::Ok;
+ return ResultOk;
if (!path.setPermissions(*permissions))
- return Result::Error(Tr::tr("Failed to set permissions."));
- return Result::Ok;
+ return ResultError(Tr::tr("Failed to set permissions."));
+ return ResultOk;
}
-Result GeneratedFile::write() const
+Result<> GeneratedFile::write() const
{
// Ensure the directory
const FilePath parentDir = m_d->path.parentDir();
if (!parentDir.isDir()) {
if (!parentDir.createDir()) {
- return Result::Error(Tr::tr("Unable to create the directory %1.")
+ return ResultError(Tr::tr("Unable to create the directory %1.")
.arg(parentDir.toUserOutput()));
}
}
// Write out
- if (const Result res = m_d->writeContents(); !res)
+ if (const Result<> res = m_d->writeContents(); !res)
return res;
return m_d->writePermissions();
}
diff --git a/src/plugins/coreplugin/generatedfile.h b/src/plugins/coreplugin/generatedfile.h
index fda30813cf2..0772924a9c2 100644
--- a/src/plugins/coreplugin/generatedfile.h
+++ b/src/plugins/coreplugin/generatedfile.h
@@ -6,15 +6,13 @@
#include "core_global.h"
#include <utils/id.h>
+#include <utils/result.h>
#include <QFile>
#include <QList>
#include <QSharedDataPointer>
-namespace Utils {
-class FilePath;
-class Result;
-} // Utils
+namespace Utils { class FilePath; }
namespace Core {
class GeneratedFilePrivate;
@@ -66,7 +64,7 @@ public:
Utils::Id editorId() const;
void setEditorId(Utils::Id id);
- Utils::Result write() const;
+ Utils::Result<> write() const;
Attributes attributes() const;
void setAttributes(Attributes a);
diff --git a/src/plugins/coreplugin/idocument.cpp b/src/plugins/coreplugin/idocument.cpp
index f57256819fd..fe1ab0d8995 100644
--- a/src/plugins/coreplugin/idocument.cpp
+++ b/src/plugins/coreplugin/idocument.cpp
@@ -340,11 +340,11 @@ IDocument::OpenResult IDocument::open(QString *errorString, const Utils::FilePat
\sa saved()
\sa filePath()
*/
-Result IDocument::save(const FilePath &filePath, bool autoSave)
+Result<> IDocument::save(const FilePath &filePath, bool autoSave)
{
const FilePath savePath = filePath.isEmpty() ? this->filePath() : filePath;
emit aboutToSave(savePath, autoSave);
- const Result res = saveImpl(savePath, autoSave);
+ const Result<> res = saveImpl(savePath, autoSave);
if (res)
emit saved(savePath, autoSave);
return res;
@@ -361,11 +361,11 @@ Result IDocument::save(const FilePath &filePath, bool autoSave)
The default implementation does nothing and returns \c false.
*/
-Result IDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> IDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
Q_UNUSED(filePath)
Q_UNUSED(autoSave)
- return Result::Error(Tr::tr("Not implemented"));
+ return ResultError(Tr::tr("Not implemented"));
}
/*!
@@ -461,11 +461,11 @@ IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger trigger, Chang
\sa reloadFinished()
\sa changed()
*/
-Result IDocument::reload(ReloadFlag flag, ChangeType type)
+Result<> IDocument::reload(ReloadFlag flag, ChangeType type)
{
Q_UNUSED(flag)
Q_UNUSED(type)
- return Result::Ok;
+ return ResultOk;
}
/*!
@@ -641,13 +641,13 @@ void IDocument::setMimeType(const QString &mimeType)
/*!
\internal
*/
-Result IDocument::autoSave(const FilePath &filePath)
+Result<> IDocument::autoSave(const FilePath &filePath)
{
- if (const Result res = save(filePath, true); !res)
+ if (const Result<> res = save(filePath, true); !res)
return res;
d->autoSavePath = filePath;
- return Result::Ok;
+ return ResultOk;
}
static const char kRestoredAutoSave[] = "RestoredAutoSave";
diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h
index cb8a095dd78..58a903464a7 100644
--- a/src/plugins/coreplugin/idocument.h
+++ b/src/plugins/coreplugin/idocument.h
@@ -68,7 +68,7 @@ public:
virtual OpenResult open(QString *errorString, const Utils::FilePath &filePath, const Utils::FilePath &realFilePath);
- Utils::Result save(const Utils::FilePath &filePath = {}, bool autoSave = false);
+ Utils::Result<> save(const Utils::FilePath &filePath = {}, bool autoSave = false);
virtual QByteArray contents() const;
virtual bool setContents(const QByteArray &contents);
@@ -100,11 +100,11 @@ public:
void setSuspendAllowed(bool value);
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- virtual Utils::Result reload(ReloadFlag flag, ChangeType type);
+ virtual Utils::Result<> reload(ReloadFlag flag, ChangeType type);
void checkPermissions();
- Utils::Result autoSave(const Utils::FilePath &filePath);
+ Utils::Result<> autoSave(const Utils::FilePath &filePath);
void setRestoredFrom(const Utils::FilePath &path);
void removeAutoSaveFile();
@@ -131,7 +131,7 @@ signals:
void filePathChanged(const Utils::FilePath &oldName, const Utils::FilePath &newName);
protected:
- virtual Utils::Result saveImpl(const Utils::FilePath &filePath = {}, bool autoSave = false);
+ virtual Utils::Result<> saveImpl(const Utils::FilePath &filePath = {}, bool autoSave = false);
private:
Internal::IDocumentPrivate *d;
diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp
index f982b79ad4a..8ac6e0e0b43 100644
--- a/src/plugins/coreplugin/outputwindow.cpp
+++ b/src/plugins/coreplugin/outputwindow.cpp
@@ -321,7 +321,7 @@ void OutputWindow::contextMenuEvent(QContextMenuEvent *event)
Utils::TextFileFormat format;
format.setCodecName(EditorManager::defaultTextCodecName());
format.lineTerminationMode = EditorManager::defaultLineEnding();
- if (const Result res = format.writeFile(file, toPlainText()); !res)
+ if (const Result<> res = format.writeFile(file, toPlainText()); !res)
MessageManager::writeDisrupting(res.error());
}
});
diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp
index 8a2956d4002..2c6a48725d0 100644
--- a/src/plugins/coreplugin/plugininstallwizard.cpp
+++ b/src/plugins/coreplugin/plugininstallwizard.cpp
@@ -122,22 +122,22 @@ public:
using CheckResult = expected_str<PluginSpec *>;
-static Result checkPlugin(PluginSpec *spec, bool update)
+static Result<> checkPlugin(PluginSpec *spec, bool update)
{
const bool pluginAlreadyExists = PluginManager::specExists(spec->id());
if (!update && pluginAlreadyExists) {
- return Result::Error(
+ return ResultError(
Tr::tr("A plugin with ID \"%1\" is already installed.").arg(spec->id()));
} else if (update && !pluginAlreadyExists) {
- return Result::Error(Tr::tr("No plugin with ID \"%1\" is installed.").arg(spec->id()));
+ return ResultError(Tr::tr("No plugin with ID \"%1\" is installed.").arg(spec->id()));
}
if (!spec->resolveDependencies(PluginManager::plugins())) {
- return Result::Error(
+ return ResultError(
Tr::tr("Plugin failed to resolve dependencies:") + " " + spec->errorString());
}
- return Result::Ok;
+ return ResultOk;
}
static expected_str<std::unique_ptr<PluginSpec>> checkPlugin(
@@ -145,7 +145,7 @@ static expected_str<std::unique_ptr<PluginSpec>> checkPlugin(
{
if (!spec)
return spec;
- const Result ok = checkPlugin(spec->get(), update);
+ const Result<> ok = checkPlugin(spec->get(), update);
if (ok)
return spec;
return Utils::make_unexpected(ok.error());
@@ -166,7 +166,7 @@ void checkContents(QPromise<CheckResult> &promise, const FilePath &tempDir, bool
}
PluginSpec *plugin = plugins.front();
- const Result ok = checkPlugin(plugin, update);
+ const Result<> ok = checkPlugin(plugin, update);
if (!ok) {
promise.addResult(Utils::make_unexpected(ok.error()));
delete plugin;
@@ -512,7 +512,7 @@ InstallResult executePluginInstallWizard(const FilePath &archive, bool prepareFo
/ extensionId(data.pluginSpec.get());
if (prepareForUpdate) {
- const Result result = ExtensionSystem::PluginManager::removePluginOnRestart(
+ const Result<> result = ExtensionSystem::PluginManager::removePluginOnRestart(
data.pluginSpec->id());
if (!result) {
qWarning() << "Failed to remove plugin" << data.pluginSpec->id() << ":"
diff --git a/src/plugins/coreplugin/session.cpp b/src/plugins/coreplugin/session.cpp
index fd09d17f81d..c615fbc7e08 100644
--- a/src/plugins/coreplugin/session.cpp
+++ b/src/plugins/coreplugin/session.cpp
@@ -360,7 +360,7 @@ bool SessionManager::deleteSession(const QString &session)
FilePath sessionFile = sessionNameToFileName(session);
if (!sessionFile.exists())
return false;
- Result result = sessionFile.removeFile();
+ Result<> result = sessionFile.removeFile();
QTC_CHECK_EXPECTED(result);
return bool(result);
}
@@ -789,7 +789,7 @@ bool SessionManager::saveSession()
if (!d->m_writer || d->m_writer->fileName() != filePath)
d->m_writer.reset(new PersistentSettingsWriter(filePath, "QtCreatorSession"));
- const Result result = d->m_writer->save(data);
+ const Result<> result = d->m_writer->save(data);
if (result) {
if (!SessionManager::isDefaultVirgin())
d->m_sessionDateTimes.insert(SessionManager::activeSession(),
@@ -801,7 +801,7 @@ bool SessionManager::saveSession()
.arg(d->m_writer->fileName().toUserOutput()));
}
- return result;
+ return result.has_value();
}
} // namespace Core
diff --git a/src/plugins/coreplugin/textdocument.cpp b/src/plugins/coreplugin/textdocument.cpp
index e5897cc34b3..1dbf760150e 100644
--- a/src/plugins/coreplugin/textdocument.cpp
+++ b/src/plugins/coreplugin/textdocument.cpp
@@ -73,7 +73,7 @@ QByteArray BaseTextDocument::decodingErrorSample() const
Returns whether the operation was successful.
*/
-Result BaseTextDocument::write(const FilePath &filePath, const QString &data) const
+Result<> BaseTextDocument::write(const FilePath &filePath, const QString &data) const
{
return write(filePath, format(), data);
}
@@ -88,7 +88,7 @@ Result BaseTextDocument::write(const FilePath &filePath, const QString &data) co
Returns whether the operation was successful.
*/
-Result BaseTextDocument::write(const FilePath &filePath,
+Result<> BaseTextDocument::write(const FilePath &filePath,
const TextFileFormat &format,
const QString &data) const
{
diff --git a/src/plugins/coreplugin/textdocument.h b/src/plugins/coreplugin/textdocument.h
index 2e1b6f83159..406ed83f245 100644
--- a/src/plugins/coreplugin/textdocument.h
+++ b/src/plugins/coreplugin/textdocument.h
@@ -37,8 +37,8 @@ public:
bool hasDecodingError() const;
QByteArray decodingErrorSample() const;
- Utils::Result write(const Utils::FilePath &filePath, const QString &data) const;
- Utils::Result write(const Utils::FilePath &filePath, const Utils::TextFileFormat &format, const QString &data) const;
+ Utils::Result<> write(const Utils::FilePath &filePath, const QString &data) const;
+ Utils::Result<> write(const Utils::FilePath &filePath, const Utils::TextFileFormat &format, const QString &data) const;
void setSupportsUtf8Bom(bool value);
void setLineTerminationMode(Utils::TextFileFormat::LineTerminationMode mode);
diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp
index 5a1e84645df..f31004a10e4 100644
--- a/src/plugins/cppeditor/cppeditordocument.cpp
+++ b/src/plugins/cppeditor/cppeditordocument.cpp
@@ -501,7 +501,7 @@ TextEditor::TabSettings CppEditorDocument::tabSettings() const
return indenter()->tabSettings().value_or(TextEditor::TextDocument::tabSettings());
}
-Result CppEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> CppEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
if (!indenter()->formatOnSave() || autoSave)
return TextEditor::TextDocument::saveImpl(filePath, autoSave);
diff --git a/src/plugins/cppeditor/cppeditordocument.h b/src/plugins/cppeditor/cppeditordocument.h
index c259afdcc23..aba526e7872 100644
--- a/src/plugins/cppeditor/cppeditordocument.h
+++ b/src/plugins/cppeditor/cppeditordocument.h
@@ -75,7 +75,7 @@ signals:
protected:
void applyFontSettings() override;
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
void slotCodeStyleSettingsChanged() override;
private:
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp
index 045d483a74a..fbc4c71875b 100644
--- a/src/plugins/debugger/cdb/cdbengine.cpp
+++ b/src/plugins/debugger/cdb/cdbengine.cpp
@@ -2081,7 +2081,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, c
response.data.m_type = GdbMi::Tuple;
}
} else {
- response.resultClass = ResultError;
+ response.resultClass = ResultFail;
GdbMi msg;
msg.m_name = "msg";
msg.m_data = message;
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index 7b7d8faec20..538f50739bf 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -210,7 +210,7 @@ void DebuggerRunParameters::setBreakOnMainNextTime()
breakOnMainNextTime = true;
}
-Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runControl)
+Result<> DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runControl)
{
if (m_symbolFile.isEmpty())
m_symbolFile = m_inferior.command.executable();
@@ -227,7 +227,7 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
// validate debugger if C++ debugging is enabled
if (!m_validationErrors.isEmpty())
- return Result::Error(m_validationErrors.join('\n'));
+ return ResultError(m_validationErrors.join('\n'));
if (m_isQmlDebugging) {
const auto device = runControl->device();
@@ -235,7 +235,7 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
if (m_qmlServer.port() <= 0) {
m_qmlServer = Utils::urlFromLocalHostAndFreePort();
if (m_qmlServer.port() <= 0)
- return Result::Error(Tr::tr("Not enough free ports for QML debugging."));
+ return ResultError(Tr::tr("Not enough free ports for QML debugging."));
}
// Makes sure that all bindings go through the JavaScript engine, so that
// breakpoints are actually hit!
@@ -292,7 +292,7 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
if (perr != ProcessArgs::SplitOk) {
// perr == BadQuoting is never returned on Windows
// FIXME? QTCREATORBUG-2809
- return Result::Error(Tr::tr("Debugging complex command lines "
+ return ResultError(Tr::tr("Debugging complex command lines "
"is currently not supported on Windows."));
}
}
@@ -303,7 +303,7 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
if (settings().forceLoggingToConsole())
m_inferior.environment.set("QT_LOGGING_TO_CONSOLE", "1");
- return Result::Ok;
+ return ResultOk;
}
void DebuggerRunParameters::setStartMode(DebuggerStartMode startMode)
diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h
index 6bd2c46129d..ac259bbdc33 100644
--- a/src/plugins/debugger/debuggerengine.h
+++ b/src/plugins/debugger/debuggerengine.h
@@ -20,6 +20,7 @@
#include <utils/outputformat.h>
#include <utils/processhandle.h>
#include <utils/processinterface.h>
+#include <utils/result.h>
QT_BEGIN_NAMESPACE
class QDebug;
@@ -34,7 +35,6 @@ namespace Utils {
class MacroExpander;
class Perspective;
class ProcessResultData;
-class Result;
} // Utils
namespace Debugger {
@@ -77,7 +77,7 @@ public:
static void setBreakOnMainNextTime();
- Utils::Result fixupParameters(ProjectExplorer::RunControl *runControl);
+ Utils::Result<> fixupParameters(ProjectExplorer::RunControl *runControl);
void setStartMode(DebuggerStartMode startMode);
DebuggerStartMode startMode() const { return m_startMode; }
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 36cf835ba7c..074b4f18ebc 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -1530,11 +1530,11 @@ void DebuggerPluginPrivate::updatePresetState()
if (!currentEngine) {
// No engine running -- or -- we have a running engine but it does not
// correspond to the current start up project.
- m_startAction.setEnabled(canRun);
+ m_startAction.setEnabled(canRun.has_value());
m_startAction.setIcon(startIcon(true));
m_startAction.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_startAction.setVisible(true);
- m_debugWithoutDeployAction.setEnabled(canRun);
+ m_debugWithoutDeployAction.setEnabled(canRun.has_value());
m_visibleStartAction.setAction(&m_startAction);
m_hiddenStopAction.setAction(&m_undisturbableAction);
return;
@@ -1548,7 +1548,7 @@ void DebuggerPluginPrivate::updatePresetState()
m_startAction.setEnabled(false);
m_startAction.setVisible(false);
- m_debugWithoutDeployAction.setEnabled(canRun);
+ m_debugWithoutDeployAction.setEnabled(canRun.has_value());
const DebuggerState state = currentEngine->state();
@@ -1566,8 +1566,8 @@ void DebuggerPluginPrivate::updatePresetState()
m_hiddenStopAction.setAction(ActionManager::command(Constants::INTERRUPT)->action());
} else if (state == DebuggerFinished) {
// We don't want to do anything anymore.
- m_startAction.setEnabled(canRun);
- m_debugWithoutDeployAction.setEnabled(canRun);
+ m_startAction.setEnabled(canRun.has_value());
+ m_debugWithoutDeployAction.setEnabled(canRun.has_value());
m_visibleStartAction.setAction(ActionManager::command(DEBUGGER_START)->action());
m_hiddenStopAction.setAction(&m_undisturbableAction);
} else if (state == InferiorUnrunnable) {
diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp
index 23d836f018c..4ee6590662b 100644
--- a/src/plugins/debugger/debuggerprotocol.cpp
+++ b/src/plugins/debugger/debuggerprotocol.cpp
@@ -428,7 +428,7 @@ QString DebuggerResponse::stringFromResultClass(ResultClass resultClass)
case ResultDone: return QLatin1String("done");
case ResultRunning: return QLatin1String("running");
case ResultConnected: return QLatin1String("connected");
- case ResultError: return QLatin1String("error");
+ case ResultFail: return QLatin1String("error");
case ResultExit: return QLatin1String("exit");
default: return QLatin1String("unknown");
}
diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h
index 12b60867acb..5663b2eb1f1 100644
--- a/src/plugins/debugger/debuggerprotocol.h
+++ b/src/plugins/debugger/debuggerprotocol.h
@@ -194,7 +194,7 @@ enum ResultClass
ResultDone,
ResultRunning,
ResultConnected,
- ResultError,
+ ResultFail,
ResultExit
};
diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp
index 4f02aa0e34a..048ffb52242 100644
--- a/src/plugins/debugger/debuggerruncontrol.cpp
+++ b/src/plugins/debugger/debuggerruncontrol.cpp
@@ -88,8 +88,8 @@ class EnginesDriver : public QObject
public:
~EnginesDriver() { clearEngines(); }
- Result setupEngines(RunControl *runControl, const DebuggerRunParameters &rp);
- Result checkBreakpoints() const;
+ Result<> setupEngines(RunControl *runControl, const DebuggerRunParameters &rp);
+ Result<> checkBreakpoints() const;
QString debuggerName() const
{
return Utils::transform<QStringList>(m_engines, &DebuggerEngine::objectName).join(" ");
@@ -293,7 +293,7 @@ ExecutableItem DebuggerRunToolPrivate::fixupParamsRecipe()
// return;
// }
- if (Result res = m_runParameters.fixupParameters(q->runControl()); !res) {
+ if (Result<> res = m_runParameters.fixupParameters(q->runControl()); !res) {
q->reportFailure(res.error());
return false;
}
@@ -478,11 +478,11 @@ ExecutableItem DebuggerRunToolPrivate::startEnginesRecipe(const Storage<EnginesD
const auto setupEngines = [this, driverStorage] {
EnginesDriver *driver = driverStorage.activeStorage();
RunControl *rc = q->runControl();
- if (Result res = driver->setupEngines(rc, m_runParameters); !res) {
+ if (Result<> res = driver->setupEngines(rc, m_runParameters); !res) {
q->reportFailure(res.error());
return false;
}
- if (Result res = driver->checkBreakpoints(); !res) {
+ if (Result<> res = driver->checkBreakpoints(); !res) {
driver->showMessage(res.error(), LogWarning);
if (settings().showUnsupportedBreakpointWarning()) {
bool doNotAskAgain = false;
@@ -584,13 +584,13 @@ static int newRunId()
return ++toolRunCount;
}
-Result EnginesDriver::setupEngines(RunControl *runControl, const DebuggerRunParameters &rp)
+Result<> EnginesDriver::setupEngines(RunControl *runControl, const DebuggerRunParameters &rp)
{
m_runControl = runControl;
clearEngines();
const auto engines = createEngines(runControl, rp);
if (!engines)
- return Result::Error(engines.error());
+ return ResultError(engines.error());
m_engines = *engines;
const QString runId = QString::number(newRunId());
@@ -606,10 +606,10 @@ Result EnginesDriver::setupEngines(RunControl *runControl, const DebuggerRunPara
engine->setDevice(m_runControl->device());
}
- return Result::Ok;
+ return ResultOk;
}
-Result EnginesDriver::checkBreakpoints() const
+Result<> EnginesDriver::checkBreakpoints() const
{
QStringList unhandledIds;
bool hasQmlBreakpoints = false;
@@ -626,7 +626,7 @@ Result EnginesDriver::checkBreakpoints() const
}
if (unhandledIds.isEmpty())
- return Result::Ok;
+ return ResultOk;
QString warningMessage = Tr::tr("Some breakpoints cannot be handled by the debugger "
"languages currently active, and will be ignored.<p>"
@@ -635,7 +635,7 @@ Result EnginesDriver::checkBreakpoints() const
warningMessage += "<p>" + Tr::tr("QML debugging needs to be enabled both in the Build "
"and the Run settings.");
}
- return Result::Error(warningMessage);
+ return ResultError(warningMessage);
}
void EnginesDriver::start()
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 320dd504703..5268caabefe 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -385,7 +385,7 @@ void GdbEngine::handleResponse(const QString &buff)
else if (resultClass == u"connected")
response.resultClass = ResultConnected;
else if (resultClass == u"error")
- response.resultClass = ResultError;
+ response.resultClass = ResultFail;
else if (resultClass == u"exit")
response.resultClass = ResultExit;
else
@@ -686,7 +686,7 @@ void GdbEngine::interruptInferior()
DeviceProcessSignalOperation::Ptr signalOperation = dev->signalOperation();
QTC_ASSERT(signalOperation, notifyInferiorStopFailed(); return);
connect(signalOperation.get(), &DeviceProcessSignalOperation::finished,
- this, [this, signalOperation](const Result &result) {
+ this, [this, signalOperation](const Result<> &result) {
if (result) {
showMessage("Interrupted " + QString::number(inferiorPid()));
notifyInferiorStopOk();
@@ -720,7 +720,7 @@ void GdbEngine::runCommand(const DebuggerCommand &command)
.arg(cmd.function).arg(state()));
if (cmd.callback) {
DebuggerResponse response;
- response.resultClass = ResultError;
+ response.resultClass = ResultFail;
cmd.callback(response);
}
return;
@@ -864,7 +864,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
showMessage(QString("COOKIE FOR TOKEN %1 ALREADY EATEN (%2). "
"TWO RESPONSES FOR ONE COMMAND?").arg(token).
arg(stateName(state())));
- if (response->resultClass == ResultError) {
+ if (response->resultClass == ResultFail) {
QString msg = response->data["msg"].data();
if (msg == "Cannot find new threads: generic error") {
// Handle a case known to occur on Linux/gdb 6.8 when debugging moc
@@ -955,7 +955,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
}
bool isExpectedResult =
- (response->resultClass == ResultError) // Can always happen.
+ (response->resultClass == ResultFail) // Can always happen.
|| (response->resultClass == ResultRunning && (flags & RunRequest))
|| (response->resultClass == ResultExit && (flags & ExitRequest))
|| (response->resultClass == ResultDone);
@@ -1059,7 +1059,7 @@ void GdbEngine::handleExecuteJumpToLine(const DebuggerResponse &response)
// All is fine. Waiting for a *running
// and the temporary breakpoint to be hit.
notifyInferiorRunOk(); // Only needed for gdb < 7.0.
- } else if (response.resultClass == ResultError) {
+ } else if (response.resultClass == ResultFail) {
// Could be "Unreasonable jump request" or similar.
QString out = Tr::tr("Cannot jump. Stopped.");
QString msg = response.data["msg"].data();
@@ -1509,7 +1509,7 @@ void GdbEngine::handleShowVersion(const DebuggerResponse &response)
void GdbEngine::handleDumperSetup(const DebuggerResponse &response)
{
CHECK_STATE(EngineSetupRequested);
- if (response.resultClass == ResultError) {
+ if (response.resultClass == ResultFail) {
const QString msg = response.data["msg"].data();
if (property("lru_fail").toBool() && msg.contains("Error while executing Python code.")) {
AsynchronousMessageBox::critical(
@@ -4709,7 +4709,7 @@ void GdbEngine::handleLocalAttach(const DebuggerResponse &response)
}
break;
}
- case ResultError:
+ case ResultFail:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
const QString msg = msgPtraceError(runParameters().startMode());
showStatusMessage(Tr::tr("Failed to attach to application: %1").arg(msg));
@@ -4740,7 +4740,7 @@ void GdbEngine::handleRemoteAttach(const DebuggerResponse &response)
handleInferiorPrepared();
break;
}
- case ResultError:
+ case ResultFail:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
notifyInferiorSetupFailedHelper(msgPtraceError(runParameters().startMode()));
break;
@@ -4881,7 +4881,7 @@ void GdbEngine::handleExecRun(const DebuggerResponse &response)
void GdbEngine::handleSetTargetAsync(const DebuggerResponse &response)
{
CHECK_STATE(EngineSetupRequested);
- if (response.resultClass == ResultError)
+ if (response.resultClass == ResultFail)
qDebug() << "Adapter too old: does not support asynchronous mode.";
}
@@ -5001,7 +5001,7 @@ void GdbEngine::handleSetNtoExecutable(const DebuggerResponse &response)
handleInferiorPrepared();
break;
}
- case ResultError:
+ case ResultFail:
default:
notifyInferiorSetupFailedHelper(response.data["msg"].data());
}
@@ -5050,7 +5050,7 @@ void GdbEngine::handleStubAttached(const DebuggerResponse &response, qint64 main
// Wait for the upcoming *stopped and handle it there.
}
break;
- case ResultError:
+ case ResultFail:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
notifyInferiorSetupFailedHelper(msgPtraceError(runParameters().startMode()));
break;
@@ -5138,7 +5138,7 @@ void GdbEngine::handleTargetCore(const DebuggerResponse &response)
CHECK_STATE(EngineRunRequested);
notifyEngineRunOkAndInferiorUnrunnable();
showMessage(Tr::tr("Attached to core."), StatusBar);
- if (response.resultClass == ResultError) {
+ if (response.resultClass == ResultFail) {
// We'll accept any kind of error e.g. &"Cannot access memory at address 0x2abc2a24\n"
// Even without the stack, the user can find interesting stuff by exploring
// the memory, globals etc.
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp
index 2ab984dda15..7daa4c12f39 100644
--- a/src/plugins/debugger/lldb/lldbengine.cpp
+++ b/src/plugins/debugger/lldb/lldbengine.cpp
@@ -391,7 +391,7 @@ void LldbEngine::continueInferior()
notifyInferiorRunRequested();
DebuggerCommand cmd("continueInferior");
cmd.callback = [this](const DebuggerResponse &response) {
- if (response.resultClass == ResultError)
+ if (response.resultClass == ResultFail)
notifyEngineIll();
};
runCommand(cmd);
diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp
index 7ee9a098001..c1ef64090f6 100644
--- a/src/plugins/debugger/loadcoredialog.cpp
+++ b/src/plugins/debugger/loadcoredialog.cpp
@@ -245,7 +245,7 @@ void AttachCoreDialog::accepted()
const expected_str<FilePath> resultPath = pattern.createTempFile();
if (!resultPath)
return make_unexpected(resultPath.error());
- const Result result = srcPath.copyFile(resultPath.value());
+ const Result<> result = srcPath.copyFile(resultPath.value());
if (!result)
return make_unexpected(result.error());
diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp
index 7156443f331..d238a4002a4 100644
--- a/src/plugins/designer/formwindowfile.cpp
+++ b/src/plugins/designer/formwindowfile.cpp
@@ -82,18 +82,18 @@ Core::IDocument::OpenResult FormWindowFile::open(QString *errorString,
return OpenResult::Success;
}
-Result FormWindowFile::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> FormWindowFile::saveImpl(const FilePath &filePath, bool autoSave)
{
if (!m_formWindow)
- return Result::Error("ASSERT: FormWindoFile: !m_formWindow");
+ return ResultError("ASSERT: FormWindoFile: !m_formWindow");
if (filePath.isEmpty())
- return Result::Error("ASSERT: FormWindowFile: filePath.isEmpty()");
+ return ResultError("ASSERT: FormWindowFile: filePath.isEmpty()");
const QString oldFormName = m_formWindow->fileName();
if (!autoSave)
m_formWindow->setFileName(filePath.toUrlishString());
- const Result res = writeFile(filePath);
+ const Result<> res = writeFile(filePath);
m_shouldAutoSave = false;
if (autoSave)
return res;
@@ -107,7 +107,7 @@ Result FormWindowFile::saveImpl(const FilePath &filePath, bool autoSave)
setFilePath(filePath);
updateIsModified();
- return Result::Ok;
+ return ResultOk;
}
QByteArray FormWindowFile::contents() const
@@ -184,11 +184,11 @@ bool FormWindowFile::isSaveAsAllowed() const
return true;
}
-Result FormWindowFile::reload(ReloadFlag flag, ChangeType type)
+Result<> FormWindowFile::reload(ReloadFlag flag, ChangeType type)
{
if (flag == FlagIgnore) {
if (!m_formWindow || type != TypeContents)
- return Result::Ok;
+ return ResultOk;
const bool wasModified = m_formWindow->isDirty();
{
Utils::GuardLocker locker(m_modificationChangedGuard);
@@ -198,14 +198,14 @@ Result FormWindowFile::reload(ReloadFlag flag, ChangeType type)
}
if (!wasModified)
updateIsModified();
- return Result::Ok;
+ return ResultOk;
} else {
emit aboutToReload();
QString errorString;
const bool success
= (open(&errorString, filePath(), filePath()) == OpenResult::Success);
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
}
@@ -227,7 +227,7 @@ bool FormWindowFile::supportsCodec(const QByteArray &codec) const
return TextEditor::TextDocument::isUtf8Codec(codec);
}
-Result FormWindowFile::writeFile(const Utils::FilePath &filePath) const
+Result<> FormWindowFile::writeFile(const Utils::FilePath &filePath) const
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << this->filePath() << filePath;
diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h
index 9ec5fea5c0f..289b338cec6 100644
--- a/src/plugins/designer/formwindowfile.h
+++ b/src/plugins/designer/formwindowfile.h
@@ -33,14 +33,14 @@ public:
bool shouldAutoSave() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
QString fallbackSaveAsFileName() const override;
bool supportsCodec(const QByteArray &codec) const override;
// Internal
void setFallbackSaveAsFileName(const QString &fileName);
- Utils::Result writeFile(const Utils::FilePath &filePath) const;
+ Utils::Result<> writeFile(const Utils::FilePath &filePath) const;
QDesignerFormWindowInterface *formWindow() const;
void syncXmlFromFormWindow();
@@ -52,7 +52,7 @@ public:
void updateIsModified();
protected:
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
private:
void slotFormWindowRemoved(QDesignerFormWindowInterface *w);
diff --git a/src/plugins/diffeditor/diffeditordocument.cpp b/src/plugins/diffeditor/diffeditordocument.cpp
index a41f4cf9235..62176d3618b 100644
--- a/src/plugins/diffeditor/diffeditordocument.cpp
+++ b/src/plugins/diffeditor/diffeditordocument.cpp
@@ -226,14 +226,14 @@ bool DiffEditorDocument::isSaveAsAllowed() const
return state() == LoadOK;
}
-Result DiffEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> DiffEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
Q_UNUSED(autoSave)
if (state() != LoadOK)
- return Result::Error(QString());
+ return ResultError(QString());
- const Result res = write(filePath, format(), plainText());
+ const Result<> res = write(filePath, format(), plainText());
if (!res)
return res;
@@ -246,7 +246,7 @@ Result DiffEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
setPreferredDisplayName({});
emit temporaryStateChanged();
- return Result::Ok;
+ return ResultOk;
}
void DiffEditorDocument::reload()
@@ -257,14 +257,14 @@ void DiffEditorDocument::reload()
reload(Core::IDocument::FlagReload, Core::IDocument::TypeContents);
}
-Result DiffEditorDocument::reload(ReloadFlag flag, ChangeType type)
+Result<> DiffEditorDocument::reload(ReloadFlag flag, ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
QString errorString;
bool success = open(&errorString, filePath(), filePath()) == OpenResult::Success;
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
Core::IDocument::OpenResult DiffEditorDocument::open(QString *errorString, const FilePath &filePath,
diff --git a/src/plugins/diffeditor/diffeditordocument.h b/src/plugins/diffeditor/diffeditordocument.h
index 295286cfc87..7a736ff929b 100644
--- a/src/plugins/diffeditor/diffeditordocument.h
+++ b/src/plugins/diffeditor/diffeditordocument.h
@@ -61,7 +61,7 @@ public:
bool isSaveAsAllowed() const override;
void reload();
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
OpenResult open(QString *errorString, const Utils::FilePath &filePath,
const Utils::FilePath &realFilePath) override;
bool selectEncoding();
@@ -75,7 +75,7 @@ signals:
void descriptionChanged();
protected:
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
private:
void beginReload();
diff --git a/src/plugins/docker/dockercontainerthread.cpp b/src/plugins/docker/dockercontainerthread.cpp
index 298d700b019..38e3cd44570 100644
--- a/src/plugins/docker/dockercontainerthread.cpp
+++ b/src/plugins/docker/dockercontainerthread.cpp
@@ -41,7 +41,7 @@ public:
else
containerId = *create;
- if (Result start = startContainer(); !start)
+ if (Result<> start = startContainer(); !start)
return make_unexpected(start.error());
return containerId;
@@ -70,7 +70,7 @@ private:
return m_containerId;
}
- Result startContainer()
+ Result<> startContainer()
{
using namespace std::chrono_literals;
@@ -82,7 +82,7 @@ private:
m_startProcess->start();
if (!m_startProcess->waitForStarted(5s)) {
if (m_startProcess->state() == QProcess::NotRunning) {
- return Result::Error(
+ return ResultError(
Tr::tr("Failed starting Docker container. Exit code: %1, output: %2")
.arg(m_startProcess->exitCode())
.arg(m_startProcess->allOutput()));
@@ -94,7 +94,7 @@ private:
qCDebug(dockerThreadLog) << "Started container: " << m_startProcess->commandLine();
- return Result::Ok;
+ return ResultOk;
}
private:
@@ -112,15 +112,15 @@ DockerContainerThread::DockerContainerThread(Init init)
m_thread.start();
}
-Result DockerContainerThread::start()
+Result<> DockerContainerThread::start()
{
expected_str<QString> result;
QMetaObject::invokeMethod(m_internal, &Internal::start, Qt::BlockingQueuedConnection, &result);
if (result) {
m_containerId = *result;
- return Result::Ok;
+ return ResultOk;
}
- return Result::Error(result.error());
+ return ResultError(result.error());
}
DockerContainerThread::~DockerContainerThread()
@@ -138,7 +138,7 @@ expected_str<std::unique_ptr<DockerContainerThread>> DockerContainerThread::crea
{
std::unique_ptr<DockerContainerThread> thread(new DockerContainerThread(init));
- if (Result result = thread->start(); !result)
+ if (Result<> result = thread->start(); !result)
return make_unexpected(result.error());
return thread;
diff --git a/src/plugins/docker/dockercontainerthread.h b/src/plugins/docker/dockercontainerthread.h
index 215dd58c790..72c0f7d394e 100644
--- a/src/plugins/docker/dockercontainerthread.h
+++ b/src/plugins/docker/dockercontainerthread.h
@@ -29,7 +29,7 @@ public:
private:
DockerContainerThread(Init init);
- Utils::Result start();
+ Utils::Result<> start();
private:
QThread m_thread;
diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp
index 0f5483a0352..8f5ac1e52ab 100644
--- a/src/plugins/docker/dockerdevice.cpp
+++ b/src/plugins/docker/dockerdevice.cpp
@@ -229,7 +229,7 @@ public:
if (auto result = updateContainerAccess(); !result)
return make_unexpected(result.error());
- Result initResult = Result::Ok;
+ Result<> initResult = ResultOk;
if (cmdBridgePath->isSameDevice(Docker::Internal::settings().dockerBinaryPath())) {
initResult = fAccess->init(
q->rootPath().withNewPath("/tmp/_qtc_cmdbridge"), q->environment(), false);
@@ -756,10 +756,10 @@ void DockerDevice::shutdown()
d->shutdown();
}
-Result DockerDevice::updateContainerAccess() const
+Result<> DockerDevice::updateContainerAccess() const
{
expected_str<QString> result = d->updateContainerAccess();
- return result ? Result::Ok : Result::Error(result.error());
+ return result ? ResultOk : ResultError(result.error());
}
expected_str<CommandLine> DockerDevicePrivate::withDockerExecCmd(
diff --git a/src/plugins/docker/dockerdevice.h b/src/plugins/docker/dockerdevice.h
index 3a3cf92115c..ed849483fc8 100644
--- a/src/plugins/docker/dockerdevice.h
+++ b/src/plugins/docker/dockerdevice.h
@@ -59,7 +59,7 @@ public:
Utils::expected_str<Utils::Environment> systemEnvironmentWithError() const override;
- Utils::Result updateContainerAccess() const;
+ Utils::Result<> updateContainerAccess() const;
void setMounts(const QStringList &mounts) const;
bool prepareForBuild(const ProjectExplorer::Target *target) override;
diff --git a/src/plugins/docker/dockerdevicewidget.cpp b/src/plugins/docker/dockerdevicewidget.cpp
index a7eaf0384b2..5dd73e66e83 100644
--- a/src/plugins/docker/dockerdevicewidget.cpp
+++ b/src/plugins/docker/dockerdevicewidget.cpp
@@ -104,7 +104,7 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
this,
[this, logView, dockerDevice, searchPaths] {
logView->clear();
- Result startResult = dockerDevice->updateContainerAccess();
+ Result<> startResult = dockerDevice->updateContainerAccess();
if (!startResult) {
logView->append(Tr::tr("Failed to start container."));
diff --git a/src/plugins/effectcomposer/effectcodeeditorwidget.cpp b/src/plugins/effectcomposer/effectcodeeditorwidget.cpp
index bc14bea53cf..ca5ef0c6a4d 100644
--- a/src/plugins/effectcomposer/effectcodeeditorwidget.cpp
+++ b/src/plugins/effectcomposer/effectcodeeditorwidget.cpp
@@ -86,7 +86,7 @@ void EffectCodeEditorWidget::setEditorTextWithIndentation(const QString &text)
auto *doc = document();
doc->setPlainText(text);
- if (Utils::Result result = textDocument()->save(); !result)
+ if (Utils::Result<> result = textDocument()->save(); !result)
qWarning() << __FUNCTION__ << result.error();
// We don't need to indent an empty text but is also needed for safer text.length()-1 below
diff --git a/src/plugins/extensionmanager/remotespec.cpp b/src/plugins/extensionmanager/remotespec.cpp
index c8f2114b3e9..fe7294f1928 100644
--- a/src/plugins/extensionmanager/remotespec.cpp
+++ b/src/plugins/extensionmanager/remotespec.cpp
@@ -49,14 +49,14 @@ FilePath RemoteSpec::installLocation(bool inUserFolder) const
return {};
};
-Result RemoteSpec::fromJson(const QJsonObject &remoteJsonData)
+Result<> RemoteSpec::fromJson(const QJsonObject &remoteJsonData)
{
qCDebug(remoteSpec).noquote() << "Remote JSON data:"
<< QJsonDocument(remoteJsonData).toJson(QJsonDocument::Indented);
return fromJson(remoteJsonData, remoteJsonData.value("latest").toString());
}
-Utils::Result RemoteSpec::fromJson(const QJsonObject &remoteJsonData, const QString &version)
+Utils::Result<> RemoteSpec::fromJson(const QJsonObject &remoteJsonData, const QString &version)
{
m_remoteJsonData = remoteJsonData;
m_version = version;
@@ -66,15 +66,15 @@ Utils::Result RemoteSpec::fromJson(const QJsonObject &remoteJsonData, const QStr
if (!plugin.isEmpty()) {
auto res = ExtensionSystem::PluginSpec::readMetaData(plugin.value("metadata").toObject());
if (!res)
- return Result::Error(res.error());
+ return ResultError(res.error());
if (hasError())
- return Result::Error(errorString());
- return Result::Ok;
+ return ResultError(errorString());
+ return ResultOk;
}
m_isPack = true;
- return Result::Ok;
+ return ResultOk;
}
std::vector<std::unique_ptr<RemoteSpec>> RemoteSpec::versions() const
diff --git a/src/plugins/extensionmanager/remotespec.h b/src/plugins/extensionmanager/remotespec.h
index a6e274426eb..a787250f5b8 100644
--- a/src/plugins/extensionmanager/remotespec.h
+++ b/src/plugins/extensionmanager/remotespec.h
@@ -45,8 +45,8 @@ public:
ExtensionSystem::IPlugin *plugin() const override;
Utils::FilePath installLocation(bool inUserFolder) const override;
- Utils::Result fromJson(const QJsonObject &remoteJsonData);
- Utils::Result fromJson(const QJsonObject &remoteJsonData, const QString &version);
+ Utils::Result<> fromJson(const QJsonObject &remoteJsonData);
+ Utils::Result<> fromJson(const QJsonObject &remoteJsonData, const QString &version);
QString id() const override;
QString displayName() const override;
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 27b24165d50..c1fa1d943ae 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -1593,7 +1593,7 @@ bool GitClient::synchronousAddGitignore(const FilePath &workingDirectory)
Core::GeneratedFile gitIgnoreFile(gitIgnoreDestination);
gitIgnoreFile.setBinaryContents(gitIgnoreTemplate.fileContents().value());
- if (const Result res = gitIgnoreFile.write(); !res) {
+ if (const Result<> res = gitIgnoreFile.write(); !res) {
VcsOutputWindow::appendError(res.error());
return false;
}
diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp
index 177b6fa67d3..9eeee463951 100644
--- a/src/plugins/imageviewer/imageviewerfile.cpp
+++ b/src/plugins/imageviewer/imageviewerfile.cpp
@@ -146,17 +146,17 @@ Core::IDocument::ReloadBehavior ImageViewerFile::reloadBehavior(ChangeTrigger st
return BehaviorAsk;
}
-Result ImageViewerFile::reload(Core::IDocument::ReloadFlag flag,
+Result<> ImageViewerFile::reload(Core::IDocument::ReloadFlag flag,
Core::IDocument::ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
emit aboutToReload();
QString errorString;
bool success = (openImpl(&errorString, filePath()) == OpenResult::Success);
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
QMovie *ImageViewerFile::movie() const
diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h
index 0936302060b..e4cc432651d 100644
--- a/src/plugins/imageviewer/imageviewerfile.h
+++ b/src/plugins/imageviewer/imageviewerfile.h
@@ -39,7 +39,7 @@ public:
const Utils::FilePath &realFilePath) override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
QMovie *movie() const;
diff --git a/src/plugins/languageclient/languageclientutils.cpp b/src/plugins/languageclient/languageclientutils.cpp
index 9679d07769d..fdfa0b3d37c 100644
--- a/src/plugins/languageclient/languageclientutils.cpp
+++ b/src/plugins/languageclient/languageclientutils.cpp
@@ -389,7 +389,7 @@ bool applyDocumentChange(const Client *client, const DocumentChange &change)
if (!filePath.exists())
return options->ignoreIfNotExists().value_or(false);
if (filePath.isDir() && options->recursive().value_or(false))
- return filePath.removeRecursively();
+ return filePath.removeRecursively().has_value();
}
return bool(filePath.removeFile());
}
diff --git a/src/plugins/lua/bindings/install.cpp b/src/plugins/lua/bindings/install.cpp
index a5a055173f1..9f83181c030 100644
--- a/src/plugins/lua/bindings/install.cpp
+++ b/src/plugins/lua/bindings/install.cpp
@@ -168,7 +168,7 @@ static Group installRecipe(
if (result == DoneWith::Cancel)
return DoneResult::Error;
- Result r = unarchiver.result();
+ Result<> r = unarchiver.result();
if (!r)
return emitResult(r.error());
diff --git a/src/plugins/modeleditor/modeldocument.cpp b/src/plugins/modeleditor/modeldocument.cpp
index b6ffd0d7d5b..3497d597f5b 100644
--- a/src/plugins/modeleditor/modeldocument.cpp
+++ b/src/plugins/modeleditor/modeldocument.cpp
@@ -52,16 +52,16 @@ Core::IDocument::OpenResult ModelDocument::open(QString *errorString,
return result;
}
-Result ModelDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> ModelDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
if (!d->documentController)
- return Result::Error(Tr::tr("No model loaded. Cannot save."));
+ return ResultError(Tr::tr("No model loaded. Cannot save."));
d->documentController->projectController()->setFileName(filePath);
try {
d->documentController->projectController()->save();
} catch (const qmt::Exception &ex) {
- return Result::Error(ex.errorMessage());
+ return ResultError(ex.errorMessage());
}
if (autoSave) {
@@ -71,7 +71,7 @@ Result ModelDocument::saveImpl(const FilePath &filePath, bool autoSave)
emit changed();
}
- return Result::Ok;
+ return ResultOk;
}
bool ModelDocument::shouldAutoSave() const
@@ -89,22 +89,22 @@ bool ModelDocument::isSaveAsAllowed() const
return true;
}
-Result ModelDocument::reload(Core::IDocument::ReloadFlag flag,
+Result<> ModelDocument::reload(Core::IDocument::ReloadFlag flag,
Core::IDocument::ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
try {
d->documentController->loadProject(filePath());
} catch (const qmt::FileNotFoundException &ex) {
- return Result::Error(ex.errorMessage());
+ return ResultError(ex.errorMessage());
} catch (const qmt::Exception &ex) {
- return Result::Error(Tr::tr("Could not open \"%1\" for reading: %2.")
+ return ResultError(Tr::tr("Could not open \"%1\" for reading: %2.")
.arg(filePath().toUserOutput(), ex.errorMessage()));
}
emit contentSet();
- return Result::Ok;
+ return ResultOk;
}
ExtDocumentController *ModelDocument::documentController() const
diff --git a/src/plugins/modeleditor/modeldocument.h b/src/plugins/modeleditor/modeldocument.h
index bf70cb74f7e..f36a32db80c 100644
--- a/src/plugins/modeleditor/modeldocument.h
+++ b/src/plugins/modeleditor/modeldocument.h
@@ -33,14 +33,14 @@ public:
bool shouldAutoSave() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
ExtDocumentController *documentController() const;
OpenResult load(QString *errorString, const Utils::FilePath &fileName);
protected:
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
private:
ModelDocumentPrivate *d;
diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp
index c8e69c784ca..615ed3cb4f8 100644
--- a/src/plugins/perfprofiler/perfprofilertool.cpp
+++ b/src/plugins/perfprofiler/perfprofilertool.cpp
@@ -442,7 +442,7 @@ void PerfProfilerTool::updateRunActions()
const auto canRun = ProjectExplorerPlugin::canRunStartupProject(
ProjectExplorer::Constants::PERFPROFILER_RUN_MODE);
m_startAction->setToolTip(canRun ? Tr::tr("Start a performance analysis.") : canRun.error());
- m_startAction->setEnabled(canRun);
+ m_startAction->setEnabled(canRun.has_value());
m_loadPerfData->setEnabled(true);
m_loadTrace->setEnabled(true);
}
diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp
index 95878735530..65abdf0528c 100644
--- a/src/plugins/projectexplorer/customwizard/customwizard.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp
@@ -246,12 +246,12 @@ GeneratedFiles CustomWizard::generateFiles(const QWizard *dialog, QString *error
return generateWizardFiles(errorMessage);
}
-Result CustomWizard::writeFiles(const GeneratedFiles &files) const
+Result<> CustomWizard::writeFiles(const GeneratedFiles &files) const
{
- if (const Result res = BaseFileWizardFactory::writeFiles(files); !res)
+ if (const Result<> res = BaseFileWizardFactory::writeFiles(files); !res)
return res;
if (d->m_parameters->filesGeneratorScript.isEmpty())
- return Result::Ok;
+ return ResultOk;
// Prepare run of the custom script to generate. In the case of a
// project wizard that is entirely created by a script,
// the target project directory might not exist.
@@ -264,10 +264,10 @@ Result CustomWizard::writeFiles(const GeneratedFiles &files) const
if (CustomWizardPrivate::verbose)
qDebug("Creating directory %s", qPrintable(scriptWorkingDir));
if (!scriptWorkingDirDir.mkpath(scriptWorkingDir))
- return Result::Error(QString("Unable to create the target directory \"%1\"").arg(scriptWorkingDir));
+ return ResultError(QString("Unable to create the target directory \"%1\"").arg(scriptWorkingDir));
}
// Run the custom script to actually generate the files.
- const Result res = runCustomWizardGeneratorScript(scriptWorkingDir,
+ const Result<> res = runCustomWizardGeneratorScript(scriptWorkingDir,
d->m_parameters->filesGeneratorScript,
d->m_parameters->filesGeneratorScriptArguments,
ctx->replacements);
@@ -277,13 +277,13 @@ Result CustomWizard::writeFiles(const GeneratedFiles &files) const
for (const GeneratedFile &generatedFile : files) {
if (generatedFile.attributes() & GeneratedFile::CustomGeneratorAttribute) {
if (!generatedFile.filePath().isFile()) {
- return Result::Error(QString::fromLatin1("%1 failed to generate %2").
+ return ResultError(QString::fromLatin1("%1 failed to generate %2").
arg(d->m_parameters->filesGeneratorScript.back()).
arg(generatedFile.filePath().toUrlishString()));
}
}
}
- return Result::Ok;
+ return ResultOk;
}
GeneratedFiles CustomWizard::generateWizardFiles(QString *errorMessage) const
diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h
index 50557ad9ce9..21a07f6cad3 100644
--- a/src/plugins/projectexplorer/customwizard/customwizard.h
+++ b/src/plugins/projectexplorer/customwizard/customwizard.h
@@ -83,7 +83,7 @@ protected:
Core::GeneratedFiles generateWizardFiles(QString *errorMessage) const;
// Create replacement map as static base fields + QWizard fields
FieldReplacementMap replacementMap(const QWizard *w) const;
- Utils::Result writeFiles(const Core::GeneratedFiles &files) const override;
+ Utils::Result<> writeFiles(const Core::GeneratedFiles &files) const override;
CustomWizardParametersPtr parameters() const;
CustomWizardContextPtr context() const;
diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
index b6597a99092..7c78fc17b17 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
@@ -55,7 +55,7 @@ QStringList fixGeneratorScript(const QString &configFile, QString binary)
}
// Helper for running the optional generation script.
-static Result
+static Result<>
runGenerationScriptHelper(const FilePath &workingDirectory,
const QStringList &script,
const QList<GeneratorScriptArgument> &argumentsIn,
@@ -101,14 +101,14 @@ static Result
errorMessage.append(QLatin1Char('\n'));
errorMessage.append(stdErr);
}
- return Result::Error(errorMessage);
+ return ResultError(errorMessage);
}
if (stdOut) {
*stdOut = process.cleanedStdOut();
if (CustomWizard::verbose())
qDebug("Output: '%s'\n", qPrintable(*stdOut));
}
- return Result::Ok;
+ return ResultOk;
}
/*!
@@ -127,7 +127,7 @@ Core::GeneratedFiles
{
// Run in temporary directory as the target path may not exist yet.
QString stdOut;
- const Result res = runGenerationScriptHelper(Utils::TemporaryDirectory::masterDirectoryFilePath(),
+ const Result<> res = runGenerationScriptHelper(Utils::TemporaryDirectory::masterDirectoryFilePath(),
script, arguments, true, fieldMap, &stdOut);
if (!res) {
*errorMessage = res.error();
@@ -207,7 +207,7 @@ Core::GeneratedFiles
\sa dryRunCustomWizardGeneratorScript, ProjectExplorer::CustomWizard
*/
-Result runCustomWizardGeneratorScript(const QString &targetPath,
+Result<> runCustomWizardGeneratorScript(const QString &targetPath,
const QStringList &script,
const QList<GeneratorScriptArgument> &arguments,
const QMap<QString, QString> &fieldMap)
diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.h b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.h
index c4cf2f65bbb..57854883909 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.h
+++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.h
@@ -3,13 +3,13 @@
#pragma once
+#include <utils/result.h>
+
#include <QMap>
#include <QStringList>
namespace Core { class GeneratedFile; }
-namespace Utils { class Result; }
-
namespace ProjectExplorer::Internal {
class GeneratorScriptArgument;
@@ -26,7 +26,7 @@ QList<Core::GeneratedFile>
QString *errorMessage);
// Step 2) Generate files
-Utils::Result runCustomWizardGeneratorScript(const QString &targetPath,
+Utils::Result<> runCustomWizardGeneratorScript(const QString &targetPath,
const QStringList &script,
const QList<GeneratorScriptArgument> &arguments,
const QMap<QString, QString> &fieldMap);
diff --git a/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp b/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp
index cb34028179b..8d1ebe7e5dd 100644
--- a/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp
+++ b/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp
@@ -34,7 +34,7 @@ void DesktopProcessSignalOperation::killProcess(qint64 pid)
void DesktopProcessSignalOperation::killProcess(const QString &filePath)
{
- Result result = Result::Ok;
+ Result<> result = ResultOk;
const QList<ProcessInfo> processInfoList = ProcessInfo::processInfoList().value_or(
QList<ProcessInfo>());
for (const ProcessInfo &processInfo : processInfoList) {
@@ -49,27 +49,29 @@ void DesktopProcessSignalOperation::interruptProcess(qint64 pid)
emit finished(interruptProcessSilently(pid));
}
-static Result cannotKillError(qint64 pid, const QString &why)
+static Result<> cannotKillError(qint64 pid, const QString &why)
{
- return Result::Error(Tr::tr("Cannot kill process with pid %1: %2").arg(pid).arg(why));
+ return ResultError(Tr::tr("Cannot kill process with pid %1: %2").arg(pid).arg(why));
}
-static Result appendCannotInterruptError(qint64 pid, const QString &why,
- const Result &previousResult = Result::Ok)
+static Result<> appendCannotInterruptError(qint64 pid, const QString &why,
+ const Result<> &previousResult = ResultOk)
{
- const QString error = Tr::tr("Cannot interrupt process with pid %1: %2").arg(pid).arg(why);
- return Result::Error(previousResult ? QStringList{previousResult, error}.join('\n') : error);
+ QString error = Tr::tr("Cannot interrupt process with pid %1: %2").arg(pid).arg(why);
+ if (previousResult.has_value())
+ error.append('\n' + previousResult.error());
+ return ResultError(error);
}
-Result DesktopProcessSignalOperation::killProcessSilently(qint64 pid)
+Result<> DesktopProcessSignalOperation::killProcessSilently(qint64 pid)
{
#ifdef Q_OS_WIN
const DWORD rights = PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION
|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ
|PROCESS_DUP_HANDLE|PROCESS_TERMINATE|PROCESS_CREATE_THREAD|PROCESS_SUSPEND_RESUME;
if (const HANDLE handle = OpenProcess(rights, FALSE, DWORD(pid))) {
- const Result result = TerminateProcess(handle, UINT(-1))
- ? Result::Ok : cannotKillError(pid, winErrorMessage(GetLastError()));
+ const Result<> result = TerminateProcess(handle, UINT(-1))
+ ? ResultOk : cannotKillError(pid, winErrorMessage(GetLastError()));
CloseHandle(handle);
return result;
} else {
@@ -80,13 +82,13 @@ Result DesktopProcessSignalOperation::killProcessSilently(qint64 pid)
return cannotKillError(pid, Tr::tr("Invalid process id."));
else if (kill(pid, SIGKILL))
return cannotKillError(pid, QString::fromLocal8Bit(strerror(errno)));
- return Result::Ok;
+ return ResultOk;
#endif // Q_OS_WIN
}
-Result DesktopProcessSignalOperation::interruptProcessSilently(qint64 pid)
+Result<> DesktopProcessSignalOperation::interruptProcessSilently(qint64 pid)
{
- Result result = Result::Ok;
+ Result<> result = ResultOk;
#ifdef Q_OS_WIN
enum SpecialInterrupt { NoSpecialInterrupt, Win32Interrupt, Win64Interrupt };
@@ -178,7 +180,7 @@ GDB 32bit | Api | Api | N/A | Win32
return appendCannotInterruptError(pid, Tr::tr("Invalid process id."));
else if (kill(pid, SIGINT))
return appendCannotInterruptError(pid, QString::fromLocal8Bit(strerror(errno)));
- return Result::Ok;
+ return ResultOk;
#endif // Q_OS_WIN
}
diff --git a/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.h b/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.h
index 2a5722796ef..aa1797547e7 100644
--- a/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.h
+++ b/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.h
@@ -18,8 +18,8 @@ public:
void interruptProcess(qint64 pid) override;
private:
- Utils::Result killProcessSilently(qint64 pid);
- Utils::Result interruptProcessSilently(qint64 pid);
+ Utils::Result<> killProcessSilently(qint64 pid);
+ Utils::Result<> interruptProcessSilently(qint64 pid);
void appendMsgCannotKill(qint64 pid, const QString &why);
void appendMsgCannotInterrupt(qint64 pid, const QString &why);
diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp
index f017693ef1e..ad8e75d4a06 100644
--- a/src/plugins/projectexplorer/devicesupport/idevice.cpp
+++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp
@@ -748,11 +748,11 @@ DeviceProcessSignalOperation::DeviceProcessSignalOperation() = default;
void DeviceProcessKiller::start()
{
m_signalOperation.reset();
- m_result = Result::Ok;
+ m_result = ResultOk;
const IDevice::ConstPtr device = DeviceManager::deviceForPath(m_processPath);
if (!device) {
- m_result = Result::Error(Tr::tr("No device for given path: \"%1\".")
+ m_result = ResultError(Tr::tr("No device for given path: \"%1\".")
.arg(m_processPath.toUserOutput()));
emit done(DoneResult::Error);
return;
@@ -760,16 +760,16 @@ void DeviceProcessKiller::start()
m_signalOperation = device->signalOperation();
if (!m_signalOperation) {
- m_result = Result::Error(Tr::tr("Device for path \"%1\" does not support killing processes.")
+ m_result = ResultError(Tr::tr("Device for path \"%1\" does not support killing processes.")
.arg(m_processPath.toUserOutput()));
emit done(DoneResult::Error);
return;
}
connect(m_signalOperation.get(), &DeviceProcessSignalOperation::finished,
- this, [this](const Result &result) {
+ this, [this](const Result<> &result) {
m_result = result;
- emit done(toDoneResult(result));
+ emit done(toDoneResult(result.has_value()));
});
m_signalOperation->killProcess(m_processPath.path());
diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h
index 104b795aecb..56b528ac0e3 100644
--- a/src/plugins/projectexplorer/devicesupport/idevice.h
+++ b/src/plugins/projectexplorer/devicesupport/idevice.h
@@ -68,7 +68,7 @@ public:
signals:
// If the error message is empty the operation was successful
- void finished(const Utils::Result &result);
+ void finished(const Utils::Result<> &result);
protected:
explicit DeviceProcessSignalOperation();
@@ -308,7 +308,7 @@ class PROJECTEXPLORER_EXPORT DeviceProcessKiller : public QObject
public:
void setProcessPath(const Utils::FilePath &path) { m_processPath = path; }
void start();
- Utils::Result result() const { return m_result; }
+ Utils::Result<> result() const { return m_result; }
signals:
void done(Tasking::DoneResult result);
@@ -316,7 +316,7 @@ signals:
private:
Utils::FilePath m_processPath;
DeviceProcessSignalOperation::Ptr m_signalOperation;
- Utils::Result m_result = Utils::Result::Ok;
+ Utils::Result<> m_result = Utils::ResultOk;
};
using DeviceProcessKillerTask = Tasking::SimpleCustomTask<DeviceProcessKiller>;
diff --git a/src/plugins/projectexplorer/devicesupport/processlist.cpp b/src/plugins/projectexplorer/devicesupport/processlist.cpp
index 970890f0637..5282bdbf88d 100644
--- a/src/plugins/projectexplorer/devicesupport/processlist.cpp
+++ b/src/plugins/projectexplorer/devicesupport/processlist.cpp
@@ -136,7 +136,7 @@ void ProcessList::killProcess(int row)
const ProcessInfo processInfo = at(row);
d->signalOperation = d->device->signalOperation();
connect(d->signalOperation.get(), &DeviceProcessSignalOperation::finished,
- this, [this](const Result &result) {
+ this, [this](const Result<> &result) {
if (result) {
QTC_CHECK(d->state == Killing);
setFinished();
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
index 51de0d19a3d..4416378154c 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
@@ -351,7 +351,7 @@ void JsonWizard::accept()
}
emit preFormatFiles(m_files);
- if (const Result res = JsonWizardGenerator::formatFiles(this, &m_files); !res) {
+ if (const Result<> res = JsonWizardGenerator::formatFiles(this, &m_files); !res) {
QMessageBox::warning(this, Tr::tr("Failed to Format Files"), res.error());
return;
}
@@ -365,23 +365,23 @@ void JsonWizard::accept()
Core::EditorManager::closeDocuments(documentsToClose, /*askAboutModifiedEditors=*/false);
emit preWriteFiles(m_files);
- if (const Result res = JsonWizardGenerator::writeFiles(this, &m_files); !res) {
+ if (const Result<> res = JsonWizardGenerator::writeFiles(this, &m_files); !res) {
QMessageBox::warning(this, Tr::tr("Failed to Write Files"), res.error());
return;
}
emit postProcessFiles(m_files);
- if (const Result res = JsonWizardGenerator::postWrite(this, &m_files); !res) {
+ if (const Result<> res = JsonWizardGenerator::postWrite(this, &m_files); !res) {
QMessageBox::warning(this, Tr::tr("Failed to Post-Process Files"), res.error());
return;
}
emit filesReady(m_files);
- if (const Result res = JsonWizardGenerator::polish(this, &m_files); !res) {
+ if (const Result<> res = JsonWizardGenerator::polish(this, &m_files); !res) {
QMessageBox::warning(this, Tr::tr("Failed to Polish Files"), res.error());
return;
}
emit filesPolished(m_files);
- if (const Result res = JsonWizardGenerator::allDone(this, &m_files); !res) {
+ if (const Result<> res = JsonWizardGenerator::allDone(this, &m_files); !res) {
QMessageBox::warning(this, Tr::tr("Failed to Open Files"), res.error());
return;
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp
index e8eccd3430f..cbc481e5952 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp
@@ -177,7 +177,7 @@ static JsonWizardFactory::Generator parseGenerator(const QVariant &value, QStrin
}
QVariant varVal = data.value(QLatin1String(DATA_KEY));
- if (const Result res = factory->validateData(typeId, varVal); !res) {
+ if (const Result<> res = factory->validateData(typeId, varVal); !res) {
*errorMessage = res.error();
return gen;
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp
index 14cdfbeee49..d23d903456e 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp
@@ -28,14 +28,14 @@ namespace ProjectExplorer::Internal {
class JsonWizardFileGenerator final : public JsonWizardGenerator
{
public:
- Utils::Result setup(const QVariant &data);
+ Utils::Result<> setup(const QVariant &data);
Core::GeneratedFiles fileList(MacroExpander *expander,
const FilePath &wizardDir,
const FilePath &projectDir,
QString *errorMessage) final;
- Utils::Result writeFile(const JsonWizard *wizard, Core::GeneratedFile *file) final;
+ Utils::Result<> writeFile(const JsonWizard *wizard, Core::GeneratedFile *file) final;
private:
class File {
@@ -70,16 +70,16 @@ private:
}
};
-Result JsonWizardFileGenerator::setup(const QVariant &data)
+Result<> JsonWizardFileGenerator::setup(const QVariant &data)
{
QString errorMessage;
const QVariantList list = JsonWizardFactory::objectOrList(data, &errorMessage);
if (list.isEmpty())
- return Result::Error(errorMessage);
+ return ResultError(errorMessage);
for (const QVariant &d : list) {
if (d.typeId() != QMetaType::QVariantMap)
- return Result::Error(Tr::tr("Files data list entry is not an object."));
+ return ResultError(Tr::tr("Files data list entry is not an object."));
File f;
@@ -95,10 +95,10 @@ Result JsonWizardFileGenerator::setup(const QVariant &data)
f.options = JsonWizard::parseOptions(tmp.value(QLatin1String("options")), &errorMessage);
if (!errorMessage.isEmpty())
- return Result::Error(errorMessage);
+ return ResultError(errorMessage);
if (f.source.isEmpty() && f.target.isEmpty())
- return Result::Error(Tr::tr("Source and target are both empty."));
+ return ResultError(Tr::tr("Source and target are both empty."));
if (f.target.isEmpty())
f.target = f.source;
@@ -106,7 +106,7 @@ Result JsonWizardFileGenerator::setup(const QVariant &data)
m_fileList << f;
}
- return Result::Ok;
+ return ResultOk;
}
Core::GeneratedFile JsonWizardFileGenerator::generateFile(const File &file,
@@ -248,11 +248,11 @@ Core::GeneratedFiles JsonWizardFileGenerator::fileList(MacroExpander *expander,
return result;
}
-Result JsonWizardFileGenerator::writeFile(const JsonWizard *wizard, Core::GeneratedFile *file)
+Result<> JsonWizardFileGenerator::writeFile(const JsonWizard *wizard, Core::GeneratedFile *file)
{
Q_UNUSED(wizard)
if (file->attributes() & Core::GeneratedFile::KeepExistingFileAttribute)
- return Result::Ok;
+ return ResultOk;
return file->write();
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp
index 552eb370e42..02e307ce405 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp
@@ -57,15 +57,15 @@ static ICodeStylePreferences *codeStylePreferences(Project *project, Id language
// JsonWizardGenerator:
// --------------------------------------------------------------------
-Result JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *file)
+Result<> JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *file)
{
if (file->isBinary() || file->contents().isEmpty())
- return Result::Ok; // nothing to do
+ return ResultOk; // nothing to do
Id languageId = TextEditorSettings::languageId(Utils::mimeTypeForFile(file->filePath()).name());
if (!languageId.isValid())
- return Result::Ok; // don't modify files like *.ui, *.pro
+ return ResultOk; // don't modify files like *.ui, *.pro
auto baseProject = qobject_cast<Project *>(wizard->property("SelectedProject").value<QObject *>());
ICodeStylePreferencesFactory *factory = TextEditorSettings::codeStyleFactory(languageId);
@@ -96,35 +96,35 @@ Result JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *
}
file->setContents(doc.toPlainText());
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::writeFile(const JsonWizard *wizard, GeneratedFile *file)
+Result<> JsonWizardGenerator::writeFile(const JsonWizard *wizard, GeneratedFile *file)
{
Q_UNUSED(wizard)
Q_UNUSED(file)
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::postWrite(const JsonWizard *wizard, GeneratedFile *file)
+Result<> JsonWizardGenerator::postWrite(const JsonWizard *wizard, GeneratedFile *file)
{
Q_UNUSED(wizard)
Q_UNUSED(file)
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::polish(const JsonWizard *wizard, GeneratedFile *file)
+Result<> JsonWizardGenerator::polish(const JsonWizard *wizard, GeneratedFile *file)
{
Q_UNUSED(wizard)
Q_UNUSED(file)
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::allDone(const JsonWizard *wizard, GeneratedFile *file)
+Result<> JsonWizardGenerator::allDone(const JsonWizard *wizard, GeneratedFile *file)
{
Q_UNUSED(wizard)
Q_UNUSED(file)
- return Result::Ok;
+ return ResultOk;
}
JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(JsonWizard::GeneratorFiles *files,
@@ -197,49 +197,49 @@ JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(Jso
return OverwriteOk;
}
-Result JsonWizardGenerator::formatFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
+Result<> JsonWizardGenerator::formatFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
{
for (auto i = files->begin(); i != files->end(); ++i) {
- if (const Result res = i->generator->formatFile(wizard, &(i->file)); !res)
+ if (const Result<> res = i->generator->formatFile(wizard, &(i->file)); !res)
return res;
}
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
+Result<> JsonWizardGenerator::writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
{
for (auto i = files->begin(); i != files->end(); ++i) {
- if (const Result res = i->generator->writeFile(wizard, &(i->file)); !res)
+ if (const Result<> res = i->generator->writeFile(wizard, &(i->file)); !res)
return res;
}
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
+Result<> JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
{
for (auto i = files->begin(); i != files->end(); ++i) {
- if (const Result res = i->generator->postWrite(wizard, &(i->file)); !res)
+ if (const Result<> res = i->generator->postWrite(wizard, &(i->file)); !res)
return res;
}
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::polish(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
+Result<> JsonWizardGenerator::polish(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
{
for (auto i = files->begin(); i != files->end(); ++i) {
- if (const Result res = i->generator->polish(wizard, &(i->file)); !res)
+ if (const Result<> res = i->generator->polish(wizard, &(i->file)); !res)
return res;
}
- return Result::Ok;
+ return ResultOk;
}
-Result JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
+Result<> JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files)
{
for (auto i = files->begin(); i != files->end(); ++i) {
- if (const Result res = i->generator->allDone(wizard, &(i->file)); !res)
+ if (const Result<> res = i->generator->allDone(wizard, &(i->file)); !res)
return res;
}
- return Result::Ok;
+ return ResultOk;
}
// --------------------------------------------------------------------
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h
index 8b66aef450d..0dd510002f6 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h
@@ -24,22 +24,22 @@ public:
virtual Core::GeneratedFiles fileList(Utils::MacroExpander *expander,
const Utils::FilePath &wizardDir, const Utils::FilePath &projectDir,
QString *errorMessage) = 0;
- virtual Utils::Result formatFile(const JsonWizard *wizard, Core::GeneratedFile *file);
- virtual Utils::Result writeFile(const JsonWizard *wizard, Core::GeneratedFile *file);
- virtual Utils::Result postWrite(const JsonWizard *wizard, Core::GeneratedFile *file);
- virtual Utils::Result polish(const JsonWizard *wizard, Core::GeneratedFile *file);
- virtual Utils::Result allDone(const JsonWizard *wizard, Core::GeneratedFile *file);
+ virtual Utils::Result<> formatFile(const JsonWizard *wizard, Core::GeneratedFile *file);
+ virtual Utils::Result<> writeFile(const JsonWizard *wizard, Core::GeneratedFile *file);
+ virtual Utils::Result<> postWrite(const JsonWizard *wizard, Core::GeneratedFile *file);
+ virtual Utils::Result<> polish(const JsonWizard *wizard, Core::GeneratedFile *file);
+ virtual Utils::Result<> allDone(const JsonWizard *wizard, Core::GeneratedFile *file);
virtual bool canKeepExistingFiles() const { return true; }
enum OverwriteResult { OverwriteOk, OverwriteError, OverwriteCanceled };
static OverwriteResult promptForOverwrite(JsonWizard::GeneratorFiles *files, QString *errorMessage);
- static Utils::Result formatFiles(const JsonWizard *wizard, QList<JsonWizard::GeneratorFile> *files);
- static Utils::Result writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
- static Utils::Result postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
- static Utils::Result polish(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
- static Utils::Result allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
+ static Utils::Result<> formatFiles(const JsonWizard *wizard, QList<JsonWizard::GeneratorFile> *files);
+ static Utils::Result<> writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
+ static Utils::Result<> postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
+ static Utils::Result<> polish(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
+ static Utils::Result<> allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files);
};
class PROJECTEXPLORER_EXPORT JsonWizardGeneratorFactory : public QObject
@@ -58,7 +58,7 @@ public:
const QVariantMap &variables) = 0;
// Basic syntax check for the data taken from the wizard.json file:
- virtual Utils::Result validateData(Utils::Id typeId, const QVariant &data) = 0;
+ virtual Utils::Result<> validateData(Utils::Id typeId, const QVariant &data) = 0;
protected:
// This will add "PE.Wizard.Generator." in front of the suffixes and set those as supported typeIds
@@ -85,7 +85,7 @@ public:
QTC_ASSERT(canCreate(typeId), return nullptr);
auto gen = new Generator;
- const Utils::Result res = gen->setup(data);
+ const Utils::Result<> res = gen->setup(data);
if (!res) {
qWarning() << "JsonWizardGeneratorTypedFactory for " << typeId << "setup error:"
@@ -96,9 +96,9 @@ public:
return gen;
}
- Utils::Result validateData(Utils::Id typeId, const QVariant &data) final
+ Utils::Result<> validateData(Utils::Id typeId, const QVariant &data) final
{
- QTC_ASSERT(canCreate(typeId), return Utils::Result::Error("Cannot create type"));
+ QTC_ASSERT(canCreate(typeId), return Utils::ResultError("Cannot create type"));
QScopedPointer<Generator> gen(new Generator);
return gen->setup(data);
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp
index e12ca8115f1..7c6e5aef5c1 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp
@@ -25,7 +25,7 @@ namespace ProjectExplorer::Internal {
class JsonWizardScannerGenerator final : public JsonWizardGenerator
{
public:
- Result setup(const QVariant &data);
+ Result<> setup(const QVariant &data);
Core::GeneratedFiles fileList(MacroExpander *expander,
const FilePath &wizardDir,
@@ -39,13 +39,13 @@ private:
QList<QRegularExpression> m_subDirectoryExpressions;
};
-Result JsonWizardScannerGenerator::setup(const QVariant &data)
+Result<> JsonWizardScannerGenerator::setup(const QVariant &data)
{
if (data.isNull())
- return Result::Ok;
+ return ResultOk;
if (data.typeId() != QMetaType::QVariantMap)
- return Result::Error(Tr::tr("Key is not an object."));
+ return ResultError(Tr::tr("Key is not an object."));
QVariantMap gen = data.toMap();
@@ -54,11 +54,11 @@ Result JsonWizardScannerGenerator::setup(const QVariant &data)
for (const QString &pattern : patterns) {
QRegularExpression regexp(pattern);
if (!regexp.isValid())
- return Result::Error(Tr::tr("Pattern \"%1\" is no valid regular expression."));
+ return ResultError(Tr::tr("Pattern \"%1\" is no valid regular expression."));
m_subDirectoryExpressions << regexp;
}
- return Result::Ok;
+ return ResultOk;
}
Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *expander,
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp
index c56279414c1..6ca51c2cedf 100644
--- a/src/plugins/projectexplorer/project.cpp
+++ b/src/plugins/projectexplorer/project.cpp
@@ -144,13 +144,13 @@ public:
return BehaviorSilent;
}
- Result reload(ReloadFlag flag, ChangeType type) final
+ Result<> reload(ReloadFlag flag, ChangeType type) final
{
Q_UNUSED(flag)
Q_UNUSED(type)
emit m_project->projectFileIsDirty(filePath());
- return Result::Ok;
+ return ResultOk;
}
private:
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index a827c665658..1c369addda9 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -3142,32 +3142,32 @@ void ProjectExplorerPluginPrivate::updateDeployActions()
doUpdateRunActions();
}
-Result ProjectExplorerPlugin::canRunStartupProject(Utils::Id runMode)
+Result<> ProjectExplorerPlugin::canRunStartupProject(Utils::Id runMode)
{
Project *project = ProjectManager::startupProject();
if (!project)
- return Result::Error(Tr::tr("No active project."));
+ return ResultError(Tr::tr("No active project."));
if (project->needsConfiguration()) {
- return Result::Error(Tr::tr("The project \"%1\" is not configured.")
+ return ResultError(Tr::tr("The project \"%1\" is not configured.")
.arg(project->displayName()));
}
Kit *kit = project->activeKit();
if (!kit) {
- return Result::Error(Tr::tr("The project \"%1\" has no active kit.")
+ return ResultError(Tr::tr("The project \"%1\" has no active kit.")
.arg(project->displayName()));
}
RunConfiguration *activeRC = project->activeRunConfiguration();
if (!activeRC) {
- return Result::Error(
+ return ResultError(
Tr::tr("The kit \"%1\" for the project \"%2\" has no active run configuration.")
.arg(kit->displayName(), project->displayName()));
}
if (!activeRC->isEnabled(runMode))
- return Result::Error(activeRC->disabledReason(runMode));
+ return ResultError(activeRC->disabledReason(runMode));
if (projectExplorerSettings().buildBeforeDeploy != BuildBeforeRunMode::Off
&& projectExplorerSettings().deployBeforeRun
@@ -3175,28 +3175,28 @@ Result ProjectExplorerPlugin::canRunStartupProject(Utils::Id runMode)
&& hasBuildSettings(project)) {
QPair<bool, QString> buildState = dd->buildSettingsEnabled(project);
if (!buildState.first)
- return Result::Error(buildState.second);
+ return ResultError(buildState.second);
if (BuildManager::isBuilding())
- return Result::Error(Tr::tr("A build is still in progress."));
+ return ResultError(Tr::tr("A build is still in progress."));
}
// shouldn't actually be shown to the user...
if (!RunControl::canRun(runMode, RunDeviceTypeKitAspect::deviceTypeId(kit), activeRC->id()))
- return Result::Error(Tr::tr("Cannot run \"%1\".").arg(activeRC->displayName()));
+ return ResultError(Tr::tr("Cannot run \"%1\".").arg(activeRC->displayName()));
if (dd->m_delayedRunConfiguration && dd->m_delayedRunConfiguration->project() == project)
- return Result::Error(Tr::tr("A run action is already scheduled for the active project."));
+ return ResultError(Tr::tr("A run action is already scheduled for the active project."));
- return Result::Ok;
+ return ResultOk;
}
void ProjectExplorerPluginPrivate::doUpdateRunActions()
{
- const auto canRun = ProjectExplorerPlugin::canRunStartupProject(Constants::NORMAL_RUN_MODE);
- m_runAction->setEnabled(canRun);
- m_runAction->setToolTip(canRun.error());
- m_runWithoutDeployAction->setEnabled(canRun);
+ const Result<> canRun = ProjectExplorerPlugin::canRunStartupProject(Constants::NORMAL_RUN_MODE);
+ m_runAction->setEnabled(canRun.has_value());
+ m_runAction->setToolTip(canRun.has_value() ? QString() : canRun.error());
+ m_runWithoutDeployAction->setEnabled(canRun.has_value());
emit m_instance->runActionsUpdated();
}
diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h
index e35dd4442b4..e23bde1c232 100644
--- a/src/plugins/projectexplorer/projectexplorer.h
+++ b/src/plugins/projectexplorer/projectexplorer.h
@@ -133,7 +133,7 @@ public:
static void renameFilesForSymbol(const QString &oldSymbolName, const QString &newSymbolName,
const Utils::FilePaths &files, bool preferLowerCaseFileNames);
- static Utils::Result canRunStartupProject(Utils::Id runMode);
+ static Utils::Result<> canRunStartupProject(Utils::Id runMode);
static void runProject(Project *pro, Utils::Id, const bool forceSkipDeploy = false);
static void runStartupProject(Utils::Id runMode, bool forceSkipDeploy = false);
static void runRunConfiguration(RunConfiguration *rc, Utils::Id runMode,
diff --git a/src/plugins/projectexplorer/taskfile.cpp b/src/plugins/projectexplorer/taskfile.cpp
index bcb06611ac2..63e766c0c77 100644
--- a/src/plugins/projectexplorer/taskfile.cpp
+++ b/src/plugins/projectexplorer/taskfile.cpp
@@ -45,17 +45,17 @@ Core::IDocument::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, Ch
return BehaviorSilent;
}
-Result TaskFile::reload(ReloadFlag flag, ChangeType type)
+Result<> TaskFile::reload(ReloadFlag flag, ChangeType type)
{
Q_UNUSED(flag)
if (type == TypeRemoved) {
deleteLater();
- return Result::Ok;
+ return ResultOk;
}
QString errorString;
bool success = load(&errorString, filePath());
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
static Task::TaskType typeFrom(const QString &typeName)
diff --git a/src/plugins/projectexplorer/taskfile.h b/src/plugins/projectexplorer/taskfile.h
index abccdd29c5a..95c8a253d83 100644
--- a/src/plugins/projectexplorer/taskfile.h
+++ b/src/plugins/projectexplorer/taskfile.h
@@ -24,7 +24,7 @@ public:
TaskFile(QObject *parent);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
bool load(QString *errorString, const Utils::FilePath &fileName);
diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp
index 989dd09a987..0bd032ba12f 100644
--- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp
@@ -916,7 +916,7 @@ void QmakePriFile::save(const QStringList &lines)
{
QTC_ASSERT(m_textFormat.codec(), return);
FileChangeBlocker changeGuard(filePath());
- if (const Result res = m_textFormat.writeFile(filePath(), lines.join('\n')); !res)
+ if (const Result<> res = m_textFormat.writeFile(filePath(), lines.join('\n')); !res)
QMessageBox::critical(Core::ICore::dialogParent(), Tr::tr("File Error"), res.error());
}
@@ -928,7 +928,7 @@ void QmakePriFile::save(const QStringList &lines)
QStringList errorStrings;
Core::IDocument *document = Core::DocumentModel::documentForFilePath(filePath());
if (document) {
- Result res = document->reload(Core::IDocument::FlagReload, Core::IDocument::TypeContents);
+ Result<> res = document->reload(Core::IDocument::FlagReload, Core::IDocument::TypeContents);
if (!res)
errorStrings << res.error();
}
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index 2a843ac94f0..cd60e9da6e6 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -103,13 +103,13 @@ public:
Q_UNUSED(type)
return BehaviorSilent;
}
- Result reload(ReloadFlag flag, ChangeType type) override
+ Result<> reload(ReloadFlag flag, ChangeType type) override
{
Q_UNUSED(flag)
Q_UNUSED(type)
if (m_priFile)
m_priFile->scheduleUpdate();
- return Result::Ok;
+ return ResultOk;
}
void setPriFile(QmakePriFile *priFile) { m_priFile = priFile; }
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
index f68fd388d66..48e18d49b36 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
@@ -175,7 +175,7 @@ QString AssetsLibraryModel::addNewFolder(const QString &folderPath)
{
Utils::FilePath uniqueDirPath = Utils::FilePath::fromString(UniqueName::generatePath(folderPath));
- const Utils::Result res = uniqueDirPath.ensureWritableDir();
+ const Utils::Result<> res = uniqueDirPath.ensureWritableDir();
if (!res) {
qWarning() << __FUNCTION__ << res.error();
return {};
diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp
index 72234568f07..14053312a70 100644
--- a/src/plugins/qmldesigner/documentmanager.cpp
+++ b/src/plugins/qmldesigner/documentmanager.cpp
@@ -317,7 +317,7 @@ bool DocumentManager::createFile(const QString &filePath, const QString &content
TextFileFormat textFileFormat;
textFileFormat.setCodecName(Core::EditorManager::defaultTextCodecName());
- return textFileFormat.writeFile(FilePath::fromString(filePath), contents);
+ return textFileFormat.writeFile(FilePath::fromString(filePath), contents).has_value();
}
void DocumentManager::addFileToVersionControl(const QString &directoryPath, const QString &newFilePath)
diff --git a/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp b/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp
index 137e266a94d..ea3dcde82ec 100644
--- a/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp
+++ b/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp
@@ -243,9 +243,9 @@ void FileExtractor::extract()
qWarning() << "Compressed size for file '" << m_sourceFile << "' is zero or invalid: " << m_compressedSize;
QObject::connect(m_unarchiver.get(), &Unarchiver::done, this, [this]() {
- Result r = m_unarchiver->result();
+ Result<> r = m_unarchiver->result();
m_unarchiver.reset();
- m_finished = r;
+ m_finished = r.has_value();
m_timer.stop();
m_progress = 100;
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index c2bf5a17f9a..5b68a3ecccf 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -347,7 +347,7 @@ void QmlProfilerTool::updateRunActions()
ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
d->m_startAction->setToolTip(canRun ? Tr::tr("Start QML Profiler analysis.")
: canRun.error());
- d->m_startAction->setEnabled(canRun);
+ d->m_startAction->setEnabled(canRun.has_value());
d->m_stopAction->setEnabled(false);
}
}
diff --git a/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp b/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp
index 8ff437fea85..023b18438e5 100644
--- a/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp
+++ b/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp
@@ -354,7 +354,7 @@ bool QmlBuildSystem::setFileSettingInProjectFile(const QString &setting,
fileContent.replace(match.capturedStart(1), match.capturedLength(1), relativePath);
}
- if (const Result res = textFileFormat.writeFile(qmlProjectFilePath, fileContent); !res)
+ if (const Result<> res = textFileFormat.writeFile(qmlProjectFilePath, fileContent); !res)
qWarning() << "Failed to write file" << qmlProjectFilePath << ":" << res.error();
refresh(RefreshOptions::Project);
@@ -503,7 +503,7 @@ bool QmlBuildSystem::setMainUiFileInMainFile(const Utils::FilePath &newMainUiFil
if (fileContent.contains(currentMain))
fileContent.replace(currentMain, newMain);
- if (const Result res = textFileFormat.writeFile(mainFilePath(), fileContent); !res)
+ if (const Result<> res = textFileFormat.writeFile(mainFilePath(), fileContent); !res)
qWarning() << "Failed to write file" << mainFilePath() << ":" << res.error();
return true;
diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp
index d60b2fcaabd..9b6a017a702 100644
--- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp
+++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp
@@ -140,7 +140,7 @@ static FilePath copyToAlternativeLocation(const FilePath &proFile,
QMessageBox::NoButton);
return {};
} else {
- Result result = projectDir.copyRecursively(targetDir);
+ Result<> result = projectDir.copyRecursively(targetDir);
if (result) {
// set vars to new location
diff --git a/src/plugins/remotelinux/filesystemaccess_test.cpp b/src/plugins/remotelinux/filesystemaccess_test.cpp
index 65606155422..b231ab91d83 100644
--- a/src/plugins/remotelinux/filesystemaccess_test.cpp
+++ b/src/plugins/remotelinux/filesystemaccess_test.cpp
@@ -367,7 +367,7 @@ void FileSystemAccessTest::testFileTransfer()
// Cleanup remote
const FilePath remoteDir = m_device->filePath(QString("/tmp/foo/"));
- Result removeResult = remoteDir.removeRecursively();
+ Result<> removeResult = remoteDir.removeRecursively();
QVERIFY2(removeResult, qPrintable(removeResult.error()));
}
diff --git a/src/plugins/remotelinux/genericdeploystep.cpp b/src/plugins/remotelinux/genericdeploystep.cpp
index f5090d0e496..d7d38169e1f 100644
--- a/src/plugins/remotelinux/genericdeploystep.cpp
+++ b/src/plugins/remotelinux/genericdeploystep.cpp
@@ -72,7 +72,7 @@ private:
GroupItem GenericDeployStep::mkdirTask(const Storage<FilesToTransfer> &storage)
{
- const auto onSetup = [storage](Async<Result> &async) {
+ const auto onSetup = [storage](Async<Result<>> &async) {
FilePaths remoteDirs;
for (const FileToTransfer &file : *storage)
remoteDirs << file.m_target.parentDir();
@@ -80,9 +80,9 @@ GroupItem GenericDeployStep::mkdirTask(const Storage<FilesToTransfer> &storage)
FilePath::sort(remoteDirs);
FilePath::removeDuplicates(remoteDirs);
- async.setConcurrentCallData([remoteDirs](QPromise<Result> &promise) {
+ async.setConcurrentCallData([remoteDirs](QPromise<Result<>> &promise) {
for (const FilePath &dir : remoteDirs) {
- const Result result = dir.ensureWritableDir();
+ const Result<> result = dir.ensureWritableDir();
promise.addResult(result);
if (!result)
promise.future().cancel();
@@ -90,7 +90,7 @@ GroupItem GenericDeployStep::mkdirTask(const Storage<FilesToTransfer> &storage)
});
};
- const auto onError = [this](const Async<Result> &async) {
+ const auto onError = [this](const Async<Result<>> &async) {
const int numResults = async.future().resultCount();
if (numResults == 0) {
addErrorMessage(
@@ -99,13 +99,13 @@ GroupItem GenericDeployStep::mkdirTask(const Storage<FilesToTransfer> &storage)
}
for (int i = 0; i < numResults; ++i) {
- const Result result = async.future().resultAt(i);
+ const Result<> result = async.future().resultAt(i);
if (!result)
addErrorMessage(result.error());
}
};
- return AsyncTask<Result>(onSetup, onError, CallDoneIf::Error);
+ return AsyncTask<Result<>>(onSetup, onError, CallDoneIf::Error);
}
static FileTransferMethod effectiveTransferMethodFor(const FileToTransfer &fileToTransfer,
diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp
index f7e425ad253..396c696b19e 100644
--- a/src/plugins/remotelinux/linuxdevice.cpp
+++ b/src/plugins/remotelinux/linuxdevice.cpp
@@ -319,14 +319,14 @@ public:
void setupDisconnectedAccess();
- Result setupShell(const SshParameters &sshParameters, bool announce);
+ Result<> setupShell(const SshParameters &sshParameters, bool announce);
RunResult runInShell(const CommandLine &cmd, const QByteArray &stdInData = {});
bool tryToConnect(const SshParameters &sshParameters)
{
QMutexLocker locker(&m_scriptAccess.m_shellMutex);
- return setupShell(sshParameters, false);
+ return setupShell(sshParameters, false).has_value();
}
bool checkDisconnectedWithWarning();
@@ -903,7 +903,7 @@ public:
}
// Call me with shell mutex locked
- Result start(const SshParameters &parameters)
+ Result<> start(const SshParameters &parameters)
{
closeShell();
setSshParameters(parameters);
@@ -920,7 +920,7 @@ public:
connect(m_shell.get(), &DeviceShell::done, this, [this] {
closeShell();
});
- Result result = m_shell->start();
+ Result<> result = m_shell->start();
if (!result) {
qCDebug(linuxDeviceLog) << "Failed to start shell for:" << parameters.userAtHostAndPort()
<< ", " << result.error();
@@ -1070,7 +1070,7 @@ LinuxDevice::LinuxDevice()
});
addDeviceAction({Tr::tr("Open Remote Shell"), [](const IDevice::Ptr &device) {
- Result result = device->openTerminal(Environment(), FilePath());
+ Result<> result = device->openTerminal(Environment(), FilePath());
if (!result)
QMessageBox::warning(nullptr, Tr::tr("Error"), result.error());
@@ -1168,11 +1168,11 @@ void LinuxDevicePrivate::setupDisconnectedAccess()
}
// Call me with shell mutex locked
-Result LinuxDevicePrivate::setupShell(const SshParameters &sshParameters, bool announce)
+Result<> LinuxDevicePrivate::setupShell(const SshParameters &sshParameters, bool announce)
{
if (m_scriptAccess.m_handler->isRunning(sshParameters)) {
setupConnectedAccess();
- return Result::Ok;
+ return ResultOk;
}
invalidateEnvironmentCache();
@@ -1180,7 +1180,7 @@ Result LinuxDevicePrivate::setupShell(const SshParameters &sshParameters, bool a
if (announce)
announceConnectionAttempt();
- Result result = Result::Error("setupShell failed");
+ Result<> result = ResultError("setupShell failed");
QMetaObject::invokeMethod(m_scriptAccess.m_handler, [this, sshParameters] {
return m_scriptAccess.m_handler->start(sshParameters);
}, Qt::BlockingQueuedConnection, &result);
@@ -1198,7 +1198,7 @@ Result LinuxDevicePrivate::setupShell(const SshParameters &sshParameters, bool a
m_cmdBridgeAccess = std::make_unique<CmdBridge::FileAccess>();
// We have good shell access now, try to get bridge access, too:
- Result initResult
+ Result<> initResult
= m_cmdBridgeAccess
->deployAndInit(Core::ICore::libexecPath(), q->rootPath(), getEnvironment());
if (initResult) {
@@ -1209,7 +1209,7 @@ Result LinuxDevicePrivate::setupShell(const SshParameters &sshParameters, bool a
<< ", falling back to slow shell access";
}
- return Result::Ok; // Both are fine.
+ return ResultOk; // Both are fine.
}
RunResult LinuxDevicePrivate::runInShell(const CommandLine &cmd, const QByteArray &data)
@@ -1218,7 +1218,7 @@ RunResult LinuxDevicePrivate::runInShell(const CommandLine &cmd, const QByteArra
DEBUG(cmd.toUserOutput());
if (checkDisconnectedWithWarning())
return {};
- const bool isSetup = setupShell(q->sshParameters(), true);
+ const bool isSetup = setupShell(q->sshParameters(), true).has_value();
if (checkDisconnectedWithWarning())
return {};
QTC_ASSERT(isSetup, return {});
diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.cpp b/src/plugins/remotelinux/publickeydeploymentdialog.cpp
index 18d54ea7faf..99805afa22f 100644
--- a/src/plugins/remotelinux/publickeydeploymentdialog.cpp
+++ b/src/plugins/remotelinux/publickeydeploymentdialog.cpp
@@ -56,12 +56,12 @@ PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const DeviceConstRef &devic
[this] { d->m_done ? accept() : reject(); });
connect(&d->m_process, &Process::done, this, [this] {
const bool succeeded = d->m_process.result() == ProcessResult::FinishedWithSuccess;
- Result result = Result::Ok;
+ Result<> result = ResultOk;
if (!succeeded) {
const QString errorString = d->m_process.errorString();
const QString errorMessage = errorString.isEmpty() ? d->m_process.cleanedStdErr()
: errorString;
- result = Result::Error(Utils::joinStrings({Tr::tr("Key deployment failed."),
+ result = ResultError(Utils::joinStrings({Tr::tr("Key deployment failed."),
Utils::trimBack(errorMessage, '\n')}, '\n'));
}
handleDeploymentDone(result);
@@ -69,7 +69,7 @@ PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const DeviceConstRef &devic
FileReader reader;
if (!reader.fetch(publicKeyFileName)) {
- handleDeploymentDone(Result::Error(Tr::tr("Public key error: %1").arg(reader.errorString())));
+ handleDeploymentDone(ResultError(Tr::tr("Public key error: %1").arg(reader.errorString())));
return;
}
@@ -110,7 +110,7 @@ PublicKeyDeploymentDialog::~PublicKeyDeploymentDialog()
delete d;
}
-void PublicKeyDeploymentDialog::handleDeploymentDone(const Result &result)
+void PublicKeyDeploymentDialog::handleDeploymentDone(const Result<> &result)
{
QString buttonText = result ? Tr::tr("Deployment finished successfully.") : result.error();
const QString textColor = creatorColor(
diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.h b/src/plugins/remotelinux/publickeydeploymentdialog.h
index d8ebf594dab..81ce685c0b0 100644
--- a/src/plugins/remotelinux/publickeydeploymentdialog.h
+++ b/src/plugins/remotelinux/publickeydeploymentdialog.h
@@ -5,12 +5,11 @@
#include <projectexplorer/devicesupport/idevicefwd.h>
+#include <utils/result.h>
+
#include <QProgressDialog>
-namespace Utils {
-class FilePath;
-class Result;
-}
+namespace Utils { class FilePath; }
namespace RemoteLinux::Internal {
@@ -29,7 +28,7 @@ public:
~PublicKeyDeploymentDialog() override;
private:
- void handleDeploymentDone(const Utils::Result &result);
+ void handleDeploymentDone(const Utils::Result<> &result);
Internal::PublicKeyDeploymentDialogPrivate * const d;
};
diff --git a/src/plugins/remotelinux/remotelinuxfiletransfer.cpp b/src/plugins/remotelinux/remotelinuxfiletransfer.cpp
index 15d43306573..3b90dd6de9d 100644
--- a/src/plugins/remotelinux/remotelinuxfiletransfer.cpp
+++ b/src/plugins/remotelinux/remotelinuxfiletransfer.cpp
@@ -313,18 +313,18 @@ private:
QHash<FilePath, FilesToTransfer> m_batches;
};
-static void createDir(QPromise<Result> &promise, const FilePath &pathToCreate)
+static void createDir(QPromise<Result<>> &promise, const FilePath &pathToCreate)
{
- const Result result = pathToCreate.ensureWritableDir();
+ const Result<> result = pathToCreate.ensureWritableDir();
promise.addResult(result);
if (!result)
promise.future().cancel();
};
-static void copyFile(QPromise<Result> &promise, const FileToTransfer &file)
+static void copyFile(QPromise<Result<>> &promise, const FileToTransfer &file)
{
- const Result result = file.m_source.copyFile(file.m_target);
+ const Result<> result = file.m_source.copyFile(file.m_target);
promise.addResult(result);
if (!result)
@@ -352,13 +352,13 @@ private:
const LoopList iteratorParentDirs(QList(allParentDirs.cbegin(), allParentDirs.cend()));
- const auto onCreateDirSetup = [iteratorParentDirs](Async<Result> &async) {
+ const auto onCreateDirSetup = [iteratorParentDirs](Async<Result<>> &async) {
async.setConcurrentCallData(createDir, *iteratorParentDirs);
};
const auto onCreateDirDone = [this,
- iteratorParentDirs](const Async<Result> &async) {
- const Result result = async.result();
+ iteratorParentDirs](const Async<Result<>> &async) {
+ const Result<> result = async.result();
if (result)
emit progress(
Tr::tr("Created directory: \"%1\".\n").arg(iteratorParentDirs->toUserOutput()));
@@ -369,13 +369,13 @@ private:
const LoopList iterator(m_setup.m_files);
const Storage<int> counterStorage;
- const auto onCopySetup = [iterator](Async<Result> &async) {
+ const auto onCopySetup = [iterator](Async<Result<>> &async) {
async.setConcurrentCallData(copyFile, *iterator);
};
const auto onCopyDone = [this, iterator, counterStorage](
- const Async<Result> &async) {
- const Result result = async.result();
+ const Async<Result<>> &async) {
+ const Result<> result = async.result();
int &counter = *counterStorage;
++counter;
@@ -394,12 +394,12 @@ private:
const Group recipe {
For (iteratorParentDirs) >> Do {
parallelIdealThreadCountLimit,
- AsyncTask<Result>(onCreateDirSetup, onCreateDirDone),
+ AsyncTask<Result<>>(onCreateDirSetup, onCreateDirDone),
},
For (iterator) >> Do {
parallelLimit(2),
counterStorage,
- AsyncTask<Result>(onCopySetup, onCopyDone),
+ AsyncTask<Result<>>(onCopySetup, onCopyDone),
},
};
diff --git a/src/plugins/remotelinux/remotelinuxsignaloperation.cpp b/src/plugins/remotelinux/remotelinuxsignaloperation.cpp
index b48ea1f7504..0ba08f2d04e 100644
--- a/src/plugins/remotelinux/remotelinuxsignaloperation.cpp
+++ b/src/plugins/remotelinux/remotelinuxsignaloperation.cpp
@@ -77,11 +77,11 @@ void RemoteLinuxSignalOperation::interruptProcess(qint64 pid)
void RemoteLinuxSignalOperation::runnerDone()
{
- Result result = Result::Ok;
+ Result<> result = ResultOk;
if (m_process->exitStatus() != QProcess::NormalExit) {
- result = Result::Error(m_process->errorString());
+ result = ResultError(m_process->errorString());
} else if (m_process->exitCode() != 0) {
- result = Result::Error(Tr::tr("Exit code is %1. stderr:").arg(m_process->exitCode())
+ result = ResultError(Tr::tr("Exit code is %1. stderr:").arg(m_process->exitCode())
+ ' ' + QString::fromLatin1(m_process->rawStdErr()));
}
m_process.release()->deleteLater();
diff --git a/src/plugins/remotelinux/sshkeycreationdialog.cpp b/src/plugins/remotelinux/sshkeycreationdialog.cpp
index 0e08ef7f3e8..36d76bd2d1c 100644
--- a/src/plugins/remotelinux/sshkeycreationdialog.cpp
+++ b/src/plugins/remotelinux/sshkeycreationdialog.cpp
@@ -114,11 +114,11 @@ void SshKeyCreationDialog::generateKeys()
{"-t", keyTypeString, "-b", m_comboBox->currentText(), "-N", QString(), "-f",
privateKeyFilePath().path()}});
keygen.start();
- Result result = Result::Ok;
+ Result<> result = ResultOk;
if (!keygen.waitForFinished())
- result = Result::Error(keygen.errorString().isEmpty() ? Tr::tr("Unknown error") : keygen.errorString());
+ result = ResultError(keygen.errorString().isEmpty() ? Tr::tr("Unknown error") : keygen.errorString());
else if (keygen.exitCode() != 0)
- result = Result::Error(QString::fromLocal8Bit(keygen.rawStdErr()));
+ result = ResultError(QString::fromLocal8Bit(keygen.rawStdErr()));
if (!result) {
showError(Tr::tr("The ssh-keygen tool at \"%1\" failed: %2")
.arg(SshSettings::keygenFilePath().toUserOutput(), result.error()));
diff --git a/src/plugins/resourceeditor/qrceditor/resourcefile.cpp b/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
index 47108adf91e..dae3bd562aa 100644
--- a/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
+++ b/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
@@ -223,9 +223,9 @@ bool ResourceFile::save()
return false;
}
- const Result res = m_textFileFormat.writeFile(m_filePath, contents());
+ const Result<> res = m_textFileFormat.writeFile(m_filePath, contents());
m_error_message = res.error();
- return res;
+ return res.has_value();
}
void ResourceFile::refresh()
diff --git a/src/plugins/resourceeditor/resourceeditor.cpp b/src/plugins/resourceeditor/resourceeditor.cpp
index 5b95da532db..297cf682933 100644
--- a/src/plugins/resourceeditor/resourceeditor.cpp
+++ b/src/plugins/resourceeditor/resourceeditor.cpp
@@ -56,7 +56,7 @@ public:
bool shouldAutoSave() const final { return m_shouldAutoSave; }
bool isModified() const final { return m_model.dirty(); }
bool isSaveAsAllowed() const final { return true; }
- Result reload(ReloadFlag flag, ChangeType type) final;
+ Result<> reload(ReloadFlag flag, ChangeType type) final;
void setFilePath(const FilePath &newName) final;
void setBlockDirtyChanged(bool value) { m_blockDirtyChanged = value; }
@@ -67,7 +67,7 @@ signals:
void loaded(bool success);
private:
- Result saveImpl(const FilePath &filePath, bool autoSave) final;
+ Result<> saveImpl(const FilePath &filePath, bool autoSave) final;
void dirtyChanged(bool);
RelativeResourceModel m_model;
@@ -209,20 +209,20 @@ IDocument::OpenResult ResourceEditorDocument::open(QString *errorString,
return OpenResult::Success;
}
-Result ResourceEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> ResourceEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
if (debugResourceEditorW)
qDebug() << ">ResourceEditorW::saveImpl: " << filePath;
if (filePath.isEmpty())
- return Result::Error("ASSERT: ResourceEditorDocument: filePath.isEmpty()");
+ return ResultError("ASSERT: ResourceEditorDocument: filePath.isEmpty()");
m_blockDirtyChanged = true;
m_model.setFilePath(filePath);
if (!m_model.save()) {
m_model.setFilePath(this->filePath());
m_blockDirtyChanged = false;
- return Result::Error(m_model.errorMessage());
+ return ResultError(m_model.errorMessage());
}
m_shouldAutoSave = false;
@@ -230,14 +230,14 @@ Result ResourceEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
m_model.setFilePath(this->filePath());
m_model.setDirty(true);
m_blockDirtyChanged = false;
- return Result::Ok;
+ return ResultOk;
}
setFilePath(filePath);
m_blockDirtyChanged = false;
emit changed();
- return Result::Ok;
+ return ResultOk;
}
bool ResourceEditorDocument::setContents(const QByteArray &contents)
@@ -280,16 +280,16 @@ void ResourceEditorImpl::restoreState(const QByteArray &state)
m_resourceEditor->restoreState(splitterState);
}
-Result ResourceEditorDocument::reload(ReloadFlag flag, ChangeType type)
+Result<> ResourceEditorDocument::reload(ReloadFlag flag, ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
emit aboutToReload();
QString errorString;
const bool success = (open(&errorString, filePath(), filePath()) == OpenResult::Success);
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
void ResourceEditorDocument::dirtyChanged(bool dirty)
diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp
index ab2b7b273bf..d27a7cb992c 100644
--- a/src/plugins/resourceeditor/resourcenode.cpp
+++ b/src/plugins/resourceeditor/resourcenode.cpp
@@ -47,14 +47,14 @@ public:
return BehaviorSilent;
}
- Result reload(ReloadFlag, ChangeType) final
+ Result<> reload(ReloadFlag, ChangeType) final
{
FolderNode *parent = m_node->parentFolderNode();
if (!parent)
- return Result::Error("ASSERT: !parent");
+ return ResultError("ASSERT: !parent");
parent->replaceSubtree(m_node, std::make_unique<ResourceTopLevelNode>(
m_node->filePath(), parent->filePath(), m_node->contents()));
- return Result::Ok;
+ return ResultOk;
}
private:
diff --git a/src/plugins/scxmleditor/scxmleditordocument.cpp b/src/plugins/scxmleditor/scxmleditordocument.cpp
index 81cebd280ac..3102e8008b5 100644
--- a/src/plugins/scxmleditor/scxmleditordocument.cpp
+++ b/src/plugins/scxmleditor/scxmleditordocument.cpp
@@ -57,23 +57,23 @@ Core::IDocument::OpenResult ScxmlEditorDocument::open(QString *errorString,
return OpenResult::Success;
}
-Result ScxmlEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> ScxmlEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
if (filePath.isEmpty())
- return Result::Error("ASSERT: ScxmlEditorDocument: filePath.isEmpty()");
+ return ResultError("ASSERT: ScxmlEditorDocument: filePath.isEmpty()");
bool dirty = m_designWidget->isDirty();
m_designWidget->setFileName(filePath.toUrlishString());
if (!m_designWidget->save()) {
m_designWidget->setFileName(this->filePath().toUrlishString());
- return Result::Error(m_designWidget->errorMessage());
+ return ResultError(m_designWidget->errorMessage());
}
if (autoSave) {
m_designWidget->setFileName(this->filePath().toUrlishString());
m_designWidget->save();
- return Result::Ok;
+ return ResultOk;
}
setFilePath(filePath);
@@ -81,7 +81,7 @@ Result ScxmlEditorDocument::saveImpl(const FilePath &filePath, bool autoSave)
if (dirty != m_designWidget->isDirty())
emit changed();
- return Result::Ok;
+ return ResultOk;
}
void ScxmlEditorDocument::setFilePath(const FilePath &newName)
@@ -110,17 +110,17 @@ bool ScxmlEditorDocument::isModified() const
return m_designWidget && m_designWidget->isDirty();
}
-Result ScxmlEditorDocument::reload(ReloadFlag flag, ChangeType type)
+Result<> ScxmlEditorDocument::reload(ReloadFlag flag, ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
emit aboutToReload();
QString errorString;
emit reloadRequested(&errorString, filePath().toUrlishString());
const bool success = errorString.isEmpty();
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
bool ScxmlEditorDocument::supportsCodec(const QByteArray &codec) const
diff --git a/src/plugins/scxmleditor/scxmleditordocument.h b/src/plugins/scxmleditor/scxmleditordocument.h
index 631a3c6300f..ba4cfc42d6a 100644
--- a/src/plugins/scxmleditor/scxmleditordocument.h
+++ b/src/plugins/scxmleditor/scxmleditordocument.h
@@ -33,7 +33,7 @@ public:
bool shouldAutoSave() const override;
bool isSaveAsAllowed() const override;
bool isModified() const override;
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
bool supportsCodec(const QByteArray &codec) const override;
// Internal
@@ -46,7 +46,7 @@ signals:
void reloadRequested(QString *errorString, const QString &);
protected:
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
private:
QPointer<Common::MainWidget> m_designWidget;
diff --git a/src/plugins/squish/objectsmapdocument.cpp b/src/plugins/squish/objectsmapdocument.cpp
index 83816a1b64b..3475e3ee6f2 100644
--- a/src/plugins/squish/objectsmapdocument.cpp
+++ b/src/plugins/squish/objectsmapdocument.cpp
@@ -40,20 +40,20 @@ Core::IDocument::OpenResult ObjectsMapDocument::open(QString *errorString,
return result;
}
-Result ObjectsMapDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> ObjectsMapDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
if (filePath.isEmpty())
- return Result::Error("ASSERT: ObjectsMapDocument: filePath.isEmpty()");
+ return ResultError("ASSERT: ObjectsMapDocument: filePath.isEmpty()");
const bool writeOk = writeFile(filePath);
if (!writeOk)
- return Result::Error(Tr::tr("Failed to write \"%1\"").arg(filePath.toUserOutput()));
+ return ResultError(Tr::tr("Failed to write \"%1\"").arg(filePath.toUserOutput()));
if (!autoSave) {
setModified(false);
setFilePath(filePath);
}
- return Result::Ok;
+ return ResultOk;
}
Utils::FilePath ObjectsMapDocument::fallbackSaveAsPath() const
@@ -72,19 +72,19 @@ void ObjectsMapDocument::setModified(bool modified)
emit changed();
}
-Result ObjectsMapDocument::reload(Core::IDocument::ReloadFlag flag,
+Result<> ObjectsMapDocument::reload(Core::IDocument::ReloadFlag flag,
Core::IDocument::ChangeType type)
{
Q_UNUSED(type);
if (flag == FlagIgnore)
- return Result::Ok;
+ return ResultOk;
emit aboutToReload();
QString errorString;
const bool success = (openImpl(&errorString, filePath(), filePath()) == OpenResult::Success);
if (success)
setModified(false);
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
bool ObjectsMapDocument::buildObjectsMapTree(const QByteArray &contents)
diff --git a/src/plugins/squish/objectsmapdocument.h b/src/plugins/squish/objectsmapdocument.h
index 52ea97d499d..f24b47c4f61 100644
--- a/src/plugins/squish/objectsmapdocument.h
+++ b/src/plugins/squish/objectsmapdocument.h
@@ -26,7 +26,7 @@ public:
bool isModified() const override { return m_isModified; }
void setModified(bool modified);
bool isSaveAsAllowed() const override { return true; }
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
bool shouldAutoSave() const override { return true; }
bool setContents(const QByteArray &contents) override;
@@ -34,7 +34,7 @@ public:
ObjectsMapModel *model() const { return m_contentModel; }
protected:
- Utils::Result saveImpl(const Utils::FilePath &fileName, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &fileName, bool autoSave) override;
private:
OpenResult openImpl(QString *error,
diff --git a/src/plugins/squish/squishfilehandler.cpp b/src/plugins/squish/squishfilehandler.cpp
index a6e7cb07118..d00ed503860 100644
--- a/src/plugins/squish/squishfilehandler.cpp
+++ b/src/plugins/squish/squishfilehandler.cpp
@@ -339,7 +339,7 @@ void SquishFileHandler::deleteTestCase(const QString &suiteName, const QString &
SuiteConf suiteConf = SuiteConf::readSuiteConf(suiteConfPath);
const Utils::FilePath testCaseDirectory = suiteConfPath.parentDir().pathAppended(testCaseName);
closeOpenedEditorsFor(testCaseDirectory, false);
- Utils::Result result = testCaseDirectory.removeRecursively();
+ Utils::Result<> result = testCaseDirectory.removeRecursively();
if (!result) {
QString detail = Tr::tr("Deletion of Test Case failed.");
detail.append('\n').append(result.error());
diff --git a/src/plugins/squish/squishtesttreeview.cpp b/src/plugins/squish/squishtesttreeview.cpp
index 6421b89593b..4021bc94e18 100644
--- a/src/plugins/squish/squishtesttreeview.cpp
+++ b/src/plugins/squish/squishtesttreeview.cpp
@@ -185,7 +185,7 @@ void SquishTestTreeItemDelegate::setEditorData(QWidget *editor, const QModelInde
static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePath &destination)
{
- Utils::Result result = destination.ensureWritableDir();
+ Utils::Result<> result = destination.ensureWritableDir();
QTC_ASSERT_EXPECTED(result, return false);
const bool scripted = suiteConf.objectMapStyle() == "script";
diff --git a/src/plugins/squish/squishwizardpages.cpp b/src/plugins/squish/squishwizardpages.cpp
index 486007a0e81..ed977b31fd4 100644
--- a/src/plugins/squish/squishwizardpages.cpp
+++ b/src/plugins/squish/squishwizardpages.cpp
@@ -300,39 +300,39 @@ public:
class SquishFileGenerator final : public JsonWizardGenerator
{
public:
- Result setup(const QVariant &data);
+ Result<> setup(const QVariant &data);
Core::GeneratedFiles fileList(MacroExpander *expander,
const FilePath &wizardDir,
const FilePath &projectDir,
QString *errorMessage) final;
- Result writeFile(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file) final;
- Result allDone(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file) final;
+ Result<> writeFile(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file) final;
+ Result<> allDone(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file) final;
private:
QString m_mode;
};
-Result SquishFileGenerator::setup(const QVariant &data)
+Result<> SquishFileGenerator::setup(const QVariant &data)
{
if (data.isNull())
- return Result::Error("No data");
+ return ResultError("No data");
if (data.typeId() != QMetaType::QVariantMap)
- return Result::Error(Tr::tr("Key is not an object."));
+ return ResultError(Tr::tr("Key is not an object."));
const QVariantMap map = data.toMap();
const QVariant modeVariant = map.value("mode");
if (!modeVariant.isValid())
- return Result::Error(Tr::tr("Key 'mode' is not set."));
+ return ResultError(Tr::tr("Key 'mode' is not set."));
m_mode = modeVariant.toString();
if (m_mode != "TestSuite") {
- const Result res = Result::Error(Tr::tr("Unsupported mode:") + ' ' + m_mode);
+ const Result<> res = ResultError(Tr::tr("Unsupported mode:") + ' ' + m_mode);
m_mode.clear();
return res;
}
- return Result::Ok;
+ return ResultOk;
}
static QString generateSuiteConf(const QString &aut, const QString &language,
@@ -386,14 +386,14 @@ Core::GeneratedFiles SquishFileGenerator::fileList(MacroExpander *expander,
return result;
}
-Result SquishFileGenerator::writeFile(const JsonWizard *, Core::GeneratedFile *file)
+Result<> SquishFileGenerator::writeFile(const JsonWizard *, Core::GeneratedFile *file)
{
if (file->attributes() & Core::GeneratedFile::CustomGeneratorAttribute)
- return Result::Ok;
+ return ResultOk;
return file->write();
}
-Result SquishFileGenerator::allDone(const JsonWizard *wizard, Core::GeneratedFile *file)
+Result<> SquishFileGenerator::allDone(const JsonWizard *wizard, Core::GeneratedFile *file)
{
Q_UNUSED(wizard)
@@ -402,7 +402,7 @@ Result SquishFileGenerator::allDone(const JsonWizard *wizard, Core::GeneratedFil
SquishFileHandler::instance()->openTestSuite(filePath);
}, Qt::QueuedConnection);
}
- return Result::Ok;
+ return ResultOk;
}
void setupSquishWizardPages()
diff --git a/src/plugins/squish/suiteconf.cpp b/src/plugins/squish/suiteconf.cpp
index 0f63f241d0c..9d94441e865 100644
--- a/src/plugins/squish/suiteconf.cpp
+++ b/src/plugins/squish/suiteconf.cpp
@@ -323,7 +323,7 @@ bool SuiteConf::ensureObjectMapExists() const
return true;
const Utils::FilePath objectMap = scripts.pathAppended("objectmap_template" + extension);
- Utils::Result result = destinationObjectMap.parentDir().ensureWritableDir();
+ Utils::Result<> result = destinationObjectMap.parentDir().ensureWritableDir();
QTC_ASSERT_EXPECTED(result, return false);
result = objectMap.copyFile(destinationObjectMap);
QTC_ASSERT_EXPECTED(result, return false);
diff --git a/src/plugins/terminal/shellintegration.cpp b/src/plugins/terminal/shellintegration.cpp
index 556035e1266..11f9dcc2c27 100644
--- a/src/plugins/terminal/shellintegration.cpp
+++ b/src/plugins/terminal/shellintegration.cpp
@@ -172,7 +172,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath rcPath = filesToCopy.bash.rcFile;
const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.bash.rcFile.fileName()));
- const Result copyResult = rcPath.copyFile(tmpRc);
+ const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return);
if (cmd.arguments() == "-l")
@@ -181,7 +181,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
cmd = {cmd.executable(), {"--init-file", tmpRc.nativePath()}};
} else if (cmd.executable().baseName() == "zsh") {
for (const FileToCopy &file : std::as_const(filesToCopy.zsh.files)) {
- const Result copyResult = file.source.copyFile(
+ const Result<> copyResult = file.source.copyFile(
FilePath::fromUserInput(m_tempDir.filePath(file.destName)));
QTC_ASSERT_EXPECTED(copyResult, return);
}
@@ -196,7 +196,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath rcPath = filesToCopy.pwsh.script;
const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.pwsh.script.fileName()));
- const Result copyResult = rcPath.copyFile(tmpRc);
+ const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return);
cmd.addArgs(QString("-noexit -command try { . '%1' } catch {Write-Host \"Shell "
@@ -207,7 +207,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath rcPath = filesToCopy.clink.script;
const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.clink.script.fileName()));
- const Result copyResult = rcPath.copyFile(tmpRc);
+ const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return);
env.set("CLINK_HISTORY_LABEL", "QtCreator");
@@ -216,7 +216,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
FilePath xdgDir = FilePath::fromUserInput(m_tempDir.filePath("fish_xdg_data"));
FilePath subDir = xdgDir.resolvePath(QString("fish/vendor_conf.d"));
QTC_ASSERT(subDir.createDir(), return);
- const Result copyResult = filesToCopy.fish.script.copyFile(
+ const Result<> copyResult = filesToCopy.fish.script.copyFile(
subDir.resolvePath(filesToCopy.fish.script.fileName()));
QTC_ASSERT_EXPECTED(copyResult, return);
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index 8fd14db9568..88657b2a906 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -73,7 +73,7 @@ bool RefactoringFile::create(const QString &contents, bool reindent, bool openIn
// Write the file to disk:
TextFileFormat format;
format.setCodecName(EditorManager::defaultTextCodecName());
- const Result saveOk = format.writeFile(m_filePath, m_document->toPlainText());
+ const Result<> saveOk = format.writeFile(m_filePath, m_document->toPlainText());
delete m_document;
m_document = nullptr;
if (!saveOk)
@@ -267,7 +267,7 @@ bool RefactoringFile::apply()
QTC_ASSERT(!m_filePath.isEmpty(), return false);
// suppress "file has changed" warnings if the file is open in a read-only editor
Core::FileChangeBlocker block(m_filePath);
- if (const Result res = m_textFileFormat.writeFile(m_filePath, doc->toPlainText())) {
+ if (const Result<> res = m_textFileFormat.writeFile(m_filePath, doc->toPlainText())) {
Core::DocumentManager::notifyFilesChangedInternally({m_filePath});
} else {
qWarning() << "Could not apply changes to" << m_filePath
diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp
index 4af08de73ec..fc61ad6c3a3 100644
--- a/src/plugins/texteditor/textdocument.cpp
+++ b/src/plugins/texteditor/textdocument.cpp
@@ -630,7 +630,7 @@ QTextDocument *TextDocument::document() const
* If \a autoSave is true, the cursor will be restored and some signals suppressed
* and we do not clean up the text file (cleanWhitespace(), ensureFinalNewLine()).
*/
-Result TextDocument::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> TextDocument::saveImpl(const FilePath &filePath, bool autoSave)
{
QTextCursor cursor(&d->m_document);
@@ -685,7 +685,7 @@ Result TextDocument::saveImpl(const FilePath &filePath, bool autoSave)
}
}
- const Result res = write(filePath, saveFormat, plainText());
+ const Result<> res = write(filePath, saveFormat, plainText());
// restore text cursor and scroll bar positions
if (autoSave && undos < d->m_document.availableUndoSteps()) {
@@ -705,13 +705,13 @@ Result TextDocument::saveImpl(const FilePath &filePath, bool autoSave)
d->m_autoSaveRevision = d->m_document.revision();
if (autoSave)
- return Result::Ok;
+ return ResultOk;
// inform about the new filename
d->m_document.setModified(false); // also triggers update of the block revisions
setFilePath(filePath.absoluteFilePath());
emit changed();
- return Result::Ok;
+ return ResultOk;
}
QByteArray TextDocument::contents() const
@@ -833,19 +833,19 @@ Core::IDocument::OpenResult TextDocument::openImpl(QString *errorString,
return OpenResult::Success;
}
-Result TextDocument::reload(const QByteArray &codec)
+Result<> TextDocument::reload(const QByteArray &codec)
{
- QTC_ASSERT(!codec.isEmpty(), return Result::Error("No codec given"));
+ QTC_ASSERT(!codec.isEmpty(), return ResultError("No codec given"));
setCodec(codec);
return reload();
}
-Result TextDocument::reload()
+Result<> TextDocument::reload()
{
return reload(filePath());
}
-Result TextDocument::reload(const FilePath &realFilePath)
+Result<> TextDocument::reload(const FilePath &realFilePath)
{
emit aboutToReload();
auto documentLayout =
@@ -861,7 +861,7 @@ Result TextDocument::reload(const FilePath &realFilePath)
documentLayout->documentReloaded(this); // re-adds text marks
emit reloadFinished(success);
- return Result(success, errorString);
+ return makeResult(success, errorString);
}
bool TextDocument::setPlainText(const QString &text)
@@ -878,11 +878,11 @@ bool TextDocument::setPlainText(const QString &text)
return true;
}
-Result TextDocument::reload(ReloadFlag flag, ChangeType type)
+Result<> TextDocument::reload(ReloadFlag flag, ChangeType type)
{
if (flag == FlagIgnore) {
if (type != TypeContents)
- return Result::Ok;
+ return ResultOk;
const bool wasModified = document()->isModified();
{
@@ -893,7 +893,7 @@ Result TextDocument::reload(ReloadFlag flag, ChangeType type)
}
if (!wasModified)
modificationChanged(true);
- return Result::Ok;
+ return ResultOk;
}
return reload();
}
diff --git a/src/plugins/texteditor/textdocument.h b/src/plugins/texteditor/textdocument.h
index 44b1469c921..3d5b8ea9baf 100644
--- a/src/plugins/texteditor/textdocument.h
+++ b/src/plugins/texteditor/textdocument.h
@@ -107,7 +107,7 @@ public:
bool shouldAutoSave() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
- Utils::Result reload(ReloadFlag flag, ChangeType type) override;
+ Utils::Result<> reload(ReloadFlag flag, ChangeType type) override;
void setFilePath(const Utils::FilePath &newName) override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
@@ -119,8 +119,8 @@ public:
OpenResult open(QString *errorString, const Utils::FilePath &filePath,
const Utils::FilePath &realFilePath) override;
- virtual Utils::Result reload();
- Utils::Result reload(const Utils::FilePath &realFilePath);
+ virtual Utils::Result<> reload();
+ Utils::Result<> reload(const Utils::FilePath &realFilePath);
bool setPlainText(const QString &text);
QTextDocument *document() const;
@@ -129,7 +129,7 @@ public:
void resetSyntaxHighlighter(const SyntaxHighLighterCreator &creator);
SyntaxHighlighter *syntaxHighlighter() const;
- Utils::Result reload(const QByteArray &codec);
+ Utils::Result<> reload(const QByteArray &codec);
void cleanWhitespace(const QTextCursor &cursor);
virtual void triggerPendingUpdates();
@@ -166,7 +166,7 @@ signals:
protected:
virtual void applyFontSettings();
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
virtual void slotCodeStyleSettingsChanged(); // Used in CppEditorDocumet
private:
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 35e03c5ceb4..2ad6e1f8846 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -2012,7 +2012,7 @@ void TextEditorWidget::selectEncoding()
const CodecSelectorResult result = Core::askForCodec(doc);
switch (result.action) {
case Core::CodecSelectorResult::Reload: {
- if (Result res = doc->reload(result.codec); !res) {
+ if (Result<> res = doc->reload(result.codec); !res) {
QMessageBox::critical(this, Tr::tr("File Error"), res.error());
break;
}
diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp
index 4700091f47f..f44e15c4818 100644
--- a/src/plugins/valgrind/callgrindtool.cpp
+++ b/src/plugins/valgrind/callgrindtool.cpp
@@ -1012,7 +1012,7 @@ void CallgrindTool::updateRunActions()
const auto canRun = ProjectExplorerPlugin::canRunStartupProject(CALLGRIND_RUN_MODE);
m_startAction->setToolTip(canRun ? Tr::tr("Start a Valgrind Callgrind analysis.")
: canRun.error());
- m_startAction->setEnabled(canRun);
+ m_startAction->setEnabled(canRun.has_value());
m_stopAction->setEnabled(false);
}
}
diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp
index ab1148a78a3..b8117cccef5 100644
--- a/src/plugins/valgrind/memchecktool.cpp
+++ b/src/plugins/valgrind/memchecktool.cpp
@@ -732,12 +732,12 @@ void MemcheckTool::updateRunActions()
const auto canRun = ProjectExplorerPlugin::canRunStartupProject(MEMCHECK_RUN_MODE);
m_startAction->setToolTip(canRun ? Tr::tr("Start a Valgrind Memcheck analysis.")
: canRun.error());
- m_startAction->setEnabled(canRun);
+ m_startAction->setEnabled(canRun.has_value());
const auto canRunGdb = ProjectExplorerPlugin::canRunStartupProject(
MEMCHECK_WITH_GDB_RUN_MODE);
m_startWithGdbAction->setToolTip(
canRunGdb ? Tr::tr("Start a Valgrind Memcheck with GDB analysis.") : canRunGdb.error());
- m_startWithGdbAction->setEnabled(canRunGdb);
+ m_startWithGdbAction->setEnabled(canRunGdb.has_value());
m_stopAction->setEnabled(false);
}
}
@@ -895,7 +895,7 @@ void MemcheckTool::loadXmlLogFile(const QString &filePath)
m_logParser.reset(new Parser);
connect(m_logParser.get(), &Parser::error, this, &MemcheckTool::parserError);
- connect(m_logParser.get(), &Parser::done, this, [this](const Result &result) {
+ connect(m_logParser.get(), &Parser::done, this, [this](const Result<> &result) {
if (!result)
internalParserError(result.error());
loadingExternalXmlLogFileFinished();
diff --git a/src/plugins/valgrind/xmlprotocol/parser.cpp b/src/plugins/valgrind/xmlprotocol/parser.cpp
index 9c8009a0822..bea5456faee 100644
--- a/src/plugins/valgrind/xmlprotocol/parser.cpp
+++ b/src/plugins/valgrind/xmlprotocol/parser.cpp
@@ -709,7 +709,7 @@ public:
m_errorString = data.m_internalError;
});
QObject::connect(m_watcher.get(), &QFutureWatcherBase::finished, q, [this] {
- emit q->done({!m_errorString, m_errorString.value_or(QString())});
+ emit q->done(makeResult(!m_errorString, m_errorString.value_or(QString())));
m_watcher.release()->deleteLater();
m_thread.reset();
m_socket.reset();
@@ -780,12 +780,12 @@ bool Parser::isRunning() const
return d->m_watcher.get();
}
-Result Parser::runBlocking()
+Result<> Parser::runBlocking()
{
- Result ok(Result::Ok);
+ Result<> ok(ResultOk);
QEventLoop loop;
- const auto finalize = [&loop, &ok](const Result &result) {
+ const auto finalize = [&loop, &ok](const Result<> &result) {
ok = result;
// Refer to the QObject::deleteLater() docs.
QMetaObject::invokeMethod(&loop, [&loop] { loop.quit(); }, Qt::QueuedConnection);
diff --git a/src/plugins/valgrind/xmlprotocol/parser.h b/src/plugins/valgrind/xmlprotocol/parser.h
index 94218ee606a..ff55b2e0eb6 100644
--- a/src/plugins/valgrind/xmlprotocol/parser.h
+++ b/src/plugins/valgrind/xmlprotocol/parser.h
@@ -39,7 +39,7 @@ public:
void start();
bool isRunning() const;
- Utils::Result runBlocking();
+ Utils::Result<> runBlocking();
signals:
void status(const Status &status);
@@ -47,7 +47,7 @@ signals:
void errorCount(qint64 unique, qint64 count);
void suppressionCount(const QString &name, qint64 count);
void announceThread(const AnnounceThread &announceThread);
- void done(const Utils::Result &result);
+ void done(const Utils::Result<> &result);
private:
std::unique_ptr<ParserPrivate> d;
@@ -58,8 +58,8 @@ class ParserTaskAdapter final : public Tasking::TaskAdapter<Parser>
public:
ParserTaskAdapter()
{
- connect(task(), &Parser::done, this, [this](const Utils::Result &result) {
- emit done(Tasking::toDoneResult(result == Utils::Result::Ok));
+ connect(task(), &Parser::done, this, [this](const Utils::Result<> &result) {
+ emit done(Tasking::toDoneResult(result == Utils::ResultOk));
});
}
void start() final { task()->start(); }
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp
index e515d01b260..ca5601a8002 100644
--- a/src/plugins/vcsbase/submiteditorfile.cpp
+++ b/src/plugins/vcsbase/submiteditorfile.cpp
@@ -64,21 +64,21 @@ void SubmitEditorFile::setModified(bool modified)
emit changed();
}
-Result SubmitEditorFile::saveImpl(const FilePath &filePath, bool autoSave)
+Result<> SubmitEditorFile::saveImpl(const FilePath &filePath, bool autoSave)
{
FileSaver saver(filePath, QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
saver.write(m_editor->fileContents());
QString errorString;
if (!saver.finalize(&errorString))
- return Result::Error(errorString);
+ return ResultError(errorString);
if (autoSave)
- return Result::Ok;
+ return ResultOk;
setFilePath(filePath.absoluteFilePath());
setModified(false);
if (!errorString.isEmpty())
- return Result::Error(errorString);
+ return ResultError(errorString);
emit changed();
- return Result::Ok;
+ return ResultOk;
}
IDocument::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h
index e71516ab699..de9741a1fdf 100644
--- a/src/plugins/vcsbase/submiteditorfile.h
+++ b/src/plugins/vcsbase/submiteditorfile.h
@@ -28,7 +28,7 @@ public:
void setModified(bool modified = true);
protected:
- Utils::Result saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
+ Utils::Result<> saveImpl(const Utils::FilePath &filePath, bool autoSave) override;
private:
bool m_modified;