Core: Return expected_str<void> from IDocumnet::autoSave()

... and adapt caller.

Change-Id: Ib139069a1a44116d661979e115e1a3daebf9b136
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-09-20 13:13:46 +02:00
parent 9e3925de87
commit bf8cfeb153
3 changed files with 8 additions and 11 deletions

View File

@@ -2382,9 +2382,8 @@ void EditorManagerPrivate::autoSave()
if (document->filePath().isEmpty()
|| !savePath.isWritableDir()) // FIXME: save them to a dedicated directory
continue;
QString errorString;
if (!document->autoSave(&errorString, saveName))
errors << errorString;
if (expected_str<void> res = document->autoSave(saveName); !res)
errors << res.error();
}
if (!errors.isEmpty())
QMessageBox::critical(ICore::dialogParent(),

View File

@@ -647,15 +647,13 @@ void IDocument::setMimeType(const QString &mimeType)
/*!
\internal
*/
bool IDocument::autoSave(QString *errorString, const FilePath &filePath)
expected_str<void> IDocument::autoSave(const FilePath &filePath)
{
const expected_str<void> res = save(filePath, true);
if (!res) {
*errorString = res.error();
return false;
}
if (const expected_str<void> res = save(filePath, true); !res)
return res;
d->autoSavePath = filePath;
return true;
return {};
}
static const char kRestoredAutoSave[] = "RestoredAutoSave";

View File

@@ -104,7 +104,7 @@ public:
void checkPermissions();
bool autoSave(QString *errorString, const Utils::FilePath &filePath);
Utils::expected_str<void> autoSave(const Utils::FilePath &filePath);
void setRestoredFrom(const Utils::FilePath &path);
void removeAutoSaveFile();