forked from qt-creator/qt-creator
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:
@@ -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(),
|
||||
|
@@ -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";
|
||||
|
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user