Commit 10ff6769 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Core: Let IDocument also report failed file reload operations

Change-Id: I8fa02f2398f59306c49481316fdedf50a1c4e32f
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent a0439779
...@@ -302,9 +302,9 @@ public: ...@@ -302,9 +302,9 @@ public:
emit changed(); emit changed();
} else { } else {
emit aboutToReload(); emit aboutToReload();
if (!open(errorString, m_fileName)) const bool success = open(errorString, m_fileName);
return false; emit reloadFinished(success);
emit reloaded(); return success;
} }
return true; return true;
} }
......
...@@ -112,7 +112,8 @@ signals: ...@@ -112,7 +112,8 @@ signals:
void changed(); void changed();
void aboutToReload(); void aboutToReload();
void reloaded(); void reloadFinished(bool success);
void fileNameChanged(const QString &oldName, const QString &newName); void fileNameChanged(const QString &oldName, const QString &newName);
private: private:
......
...@@ -145,9 +145,9 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty ...@@ -145,9 +145,9 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
} else { } else {
emit aboutToReload(); emit aboutToReload();
emit reload(errorString, m_fileName); emit reload(errorString, m_fileName);
if (!errorString->isEmpty()) const bool success = errorString->isEmpty();
return false; emit reloadFinished(success);
emit reloaded(); return success;
} }
return true; return true;
} }
......
...@@ -259,9 +259,9 @@ bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, Chang ...@@ -259,9 +259,9 @@ bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, Chang
} else { } else {
emit aboutToReload(); emit aboutToReload();
QString fn = m_parent->m_resourceEditor->fileName(); QString fn = m_parent->m_resourceEditor->fileName();
if (!m_parent->open(errorString, fn, fn)) const bool success = m_parent->open(errorString, fn, fn);
return false; emit reloadFinished(success);
emit reloaded(); return success;
} }
return true; return true;
} }
......
...@@ -415,8 +415,7 @@ bool BaseTextDocument::reload(QString *errorString) ...@@ -415,8 +415,7 @@ bool BaseTextDocument::reload(QString *errorString)
if (documentLayout) if (documentLayout)
documentLayout->documentReloaded(marks); // readds text marks documentLayout->documentReloaded(marks); // readds text marks
if (success) emit reloadFinished(success);
emit reloaded();
return success; return success;
} }
......
...@@ -2204,8 +2204,11 @@ void BaseTextEditorWidget::documentAboutToBeReloaded() ...@@ -2204,8 +2204,11 @@ void BaseTextEditorWidget::documentAboutToBeReloaded()
d->m_refactorOverlay->clear(); d->m_refactorOverlay->clear();
} }
void BaseTextEditorWidget::documentReloaded() void BaseTextEditorWidget::documentReloadFinished(bool success)
{ {
if (!success)
return;
// restore cursor position // restore cursor position
restoreState(d->m_tempState); restoreState(d->m_tempState);
updateCannotDecodeInfo(); updateCannotDecodeInfo();
...@@ -2584,7 +2587,7 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals(const QSharedPointer<Base ...@@ -2584,7 +2587,7 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals(const QSharedPointer<Base
QObject::connect(document.data(), SIGNAL(changed()), q, SIGNAL(changed())); QObject::connect(document.data(), SIGNAL(changed()), q, SIGNAL(changed()));
QObject::connect(document.data(), SIGNAL(titleChanged(QString)), q, SLOT(setDisplayName(QString))); QObject::connect(document.data(), SIGNAL(titleChanged(QString)), q, SLOT(setDisplayName(QString)));
QObject::connect(document.data(), SIGNAL(aboutToReload()), q, SLOT(documentAboutToBeReloaded())); QObject::connect(document.data(), SIGNAL(aboutToReload()), q, SLOT(documentAboutToBeReloaded()));
QObject::connect(document.data(), SIGNAL(reloaded()), q, SLOT(documentReloaded())); QObject::connect(document.data(), SIGNAL(reloadFinished(bool)), q, SLOT(documentReloadFinished(bool)));
q->slotUpdateExtraAreaWidth(); q->slotUpdateExtraAreaWidth();
} }
......
...@@ -375,7 +375,7 @@ protected: ...@@ -375,7 +375,7 @@ protected:
private slots: private slots:
void editorContentsChange(int position, int charsRemoved, int charsAdded); void editorContentsChange(int position, int charsRemoved, int charsAdded);
void documentAboutToBeReloaded(); void documentAboutToBeReloaded();
void documentReloaded(); void documentReloadFinished(bool success);
void highlightSearchResults(const QString &txt, Find::FindFlags findFlags); void highlightSearchResults(const QString &txt, Find::FindFlags findFlags);
void setFindScope(const QTextCursor &start, const QTextCursor &end, int, int); void setFindScope(const QTextCursor &start, const QTextCursor &end, int, int);
bool inFindScope(const QTextCursor &cursor); bool inFindScope(const QTextCursor &cursor);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment