forked from qt-creator/qt-creator
Editor: remove duplicated path is empty checks when saving
Change-Id: I1fdaacd44918a63e55bce9f15f3f80782ddcbe55 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -721,7 +721,7 @@ bool DocumentManager::saveDocument(IDocument *document,
|
||||
bool addWatcher = removeDocument(document); // So that our own IDocument gets no notification at all
|
||||
|
||||
QString errorString;
|
||||
if (!document->save(&errorString, filePath, false)) {
|
||||
if (!document->save(&errorString, savePath, false)) {
|
||||
if (isReadOnly) {
|
||||
QFile ofi(savePath.toString());
|
||||
// Check whether the existing file is writable
|
||||
|
||||
@@ -2326,9 +2326,7 @@ bool EditorManagerPrivate::saveDocument(IDocument *document)
|
||||
|
||||
document->checkPermissions();
|
||||
|
||||
const QString fileName = document->filePath().toString();
|
||||
|
||||
if (fileName.isEmpty())
|
||||
if (document->filePath().isEmpty())
|
||||
return saveDocumentAs(document);
|
||||
|
||||
bool success = false;
|
||||
|
||||
@@ -326,6 +326,7 @@ IDocument::OpenResult IDocument::open(QString *errorString, const Utils::FilePat
|
||||
|
||||
/*!
|
||||
Saves the contents of the document to the \a filePath on disk.
|
||||
If \a filePath is empty filePath() is used.
|
||||
|
||||
If \a autoSave is \c true, the saving is done for an auto-save, so the
|
||||
document should avoid cleanups or other operations that it does for
|
||||
@@ -340,13 +341,15 @@ IDocument::OpenResult IDocument::open(QString *errorString, const Utils::FilePat
|
||||
\sa shouldAutoSave()
|
||||
\sa aboutToSave()
|
||||
\sa saved()
|
||||
\sa filePath()
|
||||
*/
|
||||
bool IDocument::save(QString *errorString, const Utils::FilePath &filePath, bool autoSave)
|
||||
{
|
||||
emit aboutToSave(filePath.isEmpty() ? this->filePath() : filePath, autoSave);
|
||||
const bool success = saveImpl(errorString, filePath, autoSave);
|
||||
const Utils::FilePath savePath = filePath.isEmpty() ? this->filePath() : filePath;
|
||||
emit aboutToSave(savePath, autoSave);
|
||||
const bool success = saveImpl(errorString, savePath, autoSave);
|
||||
if (success)
|
||||
emit saved(filePath.isEmpty() ? this->filePath() : filePath, autoSave);
|
||||
emit saved(savePath, autoSave);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user