summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp41
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp4
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.h2
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp9
-rw-r--r--src/plugins/coreplugin/editormanager/ieditor.h2
-rw-r--r--src/plugins/coreplugin/filemanager.cpp28
-rw-r--r--src/plugins/coreplugin/ifile.h2
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp4
-rw-r--r--src/plugins/cppeditor/cppeditor.h2
-rw-r--r--src/plugins/designer/formwindoweditor.cpp16
-rw-r--r--src/plugins/designer/formwindoweditor.h4
-rw-r--r--src/plugins/designer/formwindowfile.cpp9
-rw-r--r--src/plugins/designer/formwindowfile.h4
-rw-r--r--src/plugins/genericprojectmanager/genericproject.cpp4
-rw-r--r--src/plugins/genericprojectmanager/genericproject.h2
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp4
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.h2
-rw-r--r--src/plugins/imageviewer/imageviewer.cpp7
-rw-r--r--src/plugins/imageviewer/imageviewer.h2
-rw-r--r--src/plugins/imageviewer/imageviewerfile.cpp8
-rw-r--r--src/plugins/imageviewer/imageviewerfile.h2
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp4
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.h2
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectfile.cpp4
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectfile.h2
-rw-r--r--src/plugins/qt4projectmanager/qt4nodes.cpp15
-rw-r--r--src/plugins/qt4projectmanager/qt4nodes.h2
-rw-r--r--src/plugins/qt4projectmanager/qt4project.cpp4
-rw-r--r--src/plugins/qt4projectmanager/qt4project.h2
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.cpp19
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.h4
-rw-r--r--src/plugins/tasklist/taskfile.cpp14
-rw-r--r--src/plugins/tasklist/taskfile.h4
-rw-r--r--src/plugins/tasklist/taskfilefactory.cpp7
-rw-r--r--src/plugins/tasklist/tasklistplugin.cpp11
-rw-r--r--src/plugins/tasklist/tasklistplugin.h2
-rw-r--r--src/plugins/texteditor/basetextdocument.cpp33
-rw-r--r--src/plugins/texteditor/basetextdocument.h8
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp15
-rw-r--r--src/plugins/texteditor/basetexteditor.h4
-rw-r--r--src/plugins/vcsbase/submiteditorfile.cpp4
-rw-r--r--src/plugins/vcsbase/submiteditorfile.h2
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.cpp16
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.h2
44 files changed, 204 insertions, 134 deletions
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 1b00d8a4d5..38a3caea48 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -34,6 +34,9 @@
#include "bineditor.h"
#include "bineditorconstants.h"
+#include <coreplugin/icore.h>
+
+#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
@@ -43,6 +46,7 @@
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include <QtGui/QMainWindow>
+#include <QtGui/QMessageBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QRegExpValidator>
@@ -219,16 +223,23 @@ public:
emit changed();
}
- bool open(const QString &fileName, quint64 offset = 0) {
+ bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
QFile file(fileName);
- if (offset < static_cast<quint64>(file.size())
- && file.open(QIODevice::ReadOnly)) {
+ if (offset >= static_cast<quint64>(file.size()))
+ return false;
+ if (file.open(QIODevice::ReadOnly)) {
m_fileName = fileName;
m_editor->setSizes(offset, file.size());
m_editor->editor()->setDisplayName(QFileInfo(fileName).fileName());
file.close();
return true;
}
+ QString errStr = tr("Cannot open %1: %2").arg(
+ QDir::toNativeSeparators(fileName), file.errorString());
+ if (errorString)
+ *errorString = errStr;
+ else
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("File Error"), errStr);
return false;
}
@@ -246,19 +257,23 @@ private slots:
data += QByteArray(blockSize - dataSize, 0);
m_editor->addData(block, data);
file.close();
+ } else {
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("File Error"),
+ tr("Cannot open %1: %2").arg(
+ QDir::toNativeSeparators(m_fileName), file.errorString()));
}
}
void provideNewRange(Core::IEditor *, quint64 offset) {
- open(m_fileName, offset);
+ open(0, m_fileName, offset);
}
void handleStartOfFileRequested(Core::IEditor *) {
- open(m_fileName, 0);
+ open(0, m_fileName, 0);
}
void handleEndOfFileRequested(Core::IEditor *) {
- open(m_fileName, QFileInfo(m_fileName).size() - 1);
+ open(0, m_fileName, QFileInfo(m_fileName).size() - 1);
}
public:
@@ -295,16 +310,18 @@ public:
return BehaviorAsk;
}
- void reload(ReloadFlag flag, ChangeType type) {
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type) {
if (flag == FlagIgnore)
- return;
+ return true;
if (type == TypePermissions) {
emit changed();
} else {
emit aboutToReload();
- if (open(m_fileName))
- emit reloaded();
+ if (!open(errorString, m_fileName))
+ return false;
+ emit reloaded();
}
+ return true;
}
private:
@@ -357,8 +374,8 @@ public:
m_file->setFilename(QString());
return true;
}
- bool open(const QString &fileName = QString()) {
- return m_file->open(fileName);
+ bool open(QString *errorString, const QString &fileName = QString()) {
+ return m_file->open(errorString, fileName);
}
Core::IFile *file() { return m_file; }
QString id() const { return QLatin1String(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); }
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 3cb0ae49f7..340fbb4f52 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -794,10 +794,12 @@ Core::IFile::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, Chang
return BehaviorSilent;
}
-void CMakeFile::reload(ReloadFlag flag, ChangeType type)
+bool CMakeFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
+ Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
+ return true;
}
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeTarget *target)
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index d5a536c8ec..028dfb54ec 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -211,7 +211,7 @@ public:
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
void rename(const QString &newName);
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 26ee9bab80..c73262dc60 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1217,9 +1217,10 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
// back to the default editor:
if (!editor)
editor = createEditor(QString(), fn);
- if (!editor || !editor->open(fn)) {
+ QString errorString;
+ if (!editor || !editor->open(&errorString, fn)) {
QApplication::restoreOverrideCursor();
- QMessageBox::critical(m_d->m_core->mainWindow(), tr("Opening File"), tr("Cannot open file %1!").arg(QDir::toNativeSeparators(fn)));
+ QMessageBox::critical(m_d->m_core->mainWindow(), tr("File Error"), errorString);
delete editor;
editor = 0;
return 0;
@@ -1843,7 +1844,9 @@ void EditorManager::revertToSaved()
return;
}
- currEditor->file()->reload(IFile::FlagReload, IFile::TypeContents);
+ QString errorString;
+ if (!currEditor->file()->reload(&errorString, IFile::FlagReload, IFile::TypeContents))
+ QMessageBox::critical(m_d->m_core->mainWindow(), tr("File Error"), errorString);
}
void EditorManager::showEditorInfoBar(const QString &id,
diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h
index d64b82396c..09a2ad320a 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.h
+++ b/src/plugins/coreplugin/editormanager/ieditor.h
@@ -50,7 +50,7 @@ public:
virtual ~IEditor() {}
virtual bool createNew(const QString &contents = QString()) = 0;
- virtual bool open(const QString &fileName = QString()) = 0;
+ virtual bool open(QString *errorString, const QString &fileName = QString()) = 0;
virtual IFile *file() = 0;
virtual QString id() const = 0;
virtual QString displayName() const = 0;
diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp
index 54aa931989..5ddb4687c0 100644
--- a/src/plugins/coreplugin/filemanager.cpp
+++ b/src/plugins/coreplugin/filemanager.cpp
@@ -912,6 +912,7 @@ void FileManager::checkForReload()
}
// handle the IFiles
+ QStringList errorStrings;
foreach (IFile *file, changedIFiles) {
IFile::ChangeTrigger behavior = IFile::TriggerInternal;
IFile::ChangeType type = IFile::TypePermissions;
@@ -958,21 +959,23 @@ void FileManager::checkForReload()
// handle it!
d->m_blockedIFile = file;
+ bool success = true;
+ QString errorString;
// we've got some modification
// check if it's contents or permissions:
if (type == IFile::TypePermissions) {
// Only permission change
- file->reload(IFile::FlagReload, IFile::TypePermissions);
+ success = file->reload(&errorString, IFile::FlagReload, IFile::TypePermissions);
// now we know it's a content change or file was removed
} else if (defaultBehavior == IFile::ReloadUnmodified
&& type == IFile::TypeContents && !file->isModified()) {
// content change, but unmodified (and settings say to reload in this case)
- file->reload(IFile::FlagReload, type);
+ success = file->reload(&errorString, IFile::FlagReload, type);
// file was removed or it's a content change and the default behavior for
// unmodified files didn't kick in
} else if (defaultBehavior == IFile::IgnoreAll) {
// content change or removed, but settings say ignore
- file->reload(IFile::FlagIgnore, type);
+ success = file->reload(&errorString, IFile::FlagIgnore, type);
// either the default behavior is to always ask,
// or the ReloadUnmodified default behavior didn't kick in,
// so do whatever the IFile wants us to do
@@ -980,27 +983,27 @@ void FileManager::checkForReload()
// check if IFile wants us to ask
if (file->reloadBehavior(behavior, type) == IFile::BehaviorSilent) {
// content change or removed, IFile wants silent handling
- file->reload(IFile::FlagReload, type);
+ success = file->reload(&errorString, IFile::FlagReload, type);
// IFile wants us to ask
} else if (type == IFile::TypeContents) {
// content change, IFile wants to ask user
if (previousAnswer == Utils::ReloadNone) {
// answer already given, ignore
- file->reload(IFile::FlagIgnore, IFile::TypeContents);
+ success = file->reload(&errorString, IFile::FlagIgnore, IFile::TypeContents);
} else if (previousAnswer == Utils::ReloadAll) {
// answer already given, reload
- file->reload(IFile::FlagReload, IFile::TypeContents);
+ success = file->reload(&errorString, IFile::FlagReload, IFile::TypeContents);
} else {
// Ask about content change
previousAnswer = Utils::reloadPrompt(file->fileName(), file->isModified(), QApplication::activeWindow());
switch (previousAnswer) {
case Utils::ReloadAll:
case Utils::ReloadCurrent:
- file->reload(IFile::FlagReload, IFile::TypeContents);
+ success = file->reload(&errorString, IFile::FlagReload, IFile::TypeContents);
break;
case Utils::ReloadSkipCurrent:
case Utils::ReloadNone:
- file->reload(IFile::FlagIgnore, IFile::TypeContents);
+ success = file->reload(&errorString, IFile::FlagIgnore, IFile::TypeContents);
break;
}
}
@@ -1031,12 +1034,21 @@ void FileManager::checkForReload()
}
}
}
+ if (!success) {
+ if (errorString.isEmpty())
+ errorStrings << tr("Cannot reload %1").arg(QDir::toNativeSeparators(file->fileName()));
+ else
+ errorStrings << errorString;
+ }
// update file info, also handling if e.g. link target has changed
removeFileInfo(file);
addFileInfo(file);
d->m_blockedIFile = 0;
}
+ if (!errorStrings.isEmpty())
+ QMessageBox::critical(d->m_mainWindow, tr("File Error"),
+ errorStrings.join(QLatin1String("\n")));
// handle deleted files
EditorManager::instance()->closeEditors(editorsToClose, false);
diff --git a/src/plugins/coreplugin/ifile.h b/src/plugins/coreplugin/ifile.h
index 9983736b55..b7b91ff300 100644
--- a/src/plugins/coreplugin/ifile.h
+++ b/src/plugins/coreplugin/ifile.h
@@ -95,7 +95,7 @@ public:
virtual bool isSaveAsAllowed() const = 0;
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const = 0;
- virtual void reload(ReloadFlag flag, ChangeType type) = 0;
+ virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0;
virtual void rename(const QString &newName) = 0;
virtual void checkPermissions() {}
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 30542972ba..6af736195d 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1787,9 +1787,9 @@ QString CPPEditor::id() const
return QLatin1String(CppEditor::Constants::CPPEDITOR_ID);
}
-bool CPPEditor::open(const QString & fileName)
+bool CPPEditor::open(QString *errorString, const QString & fileName)
{
- bool b = TextEditor::BaseTextEditor::open(fileName);
+ bool b = TextEditor::BaseTextEditor::open(errorString, fileName);
editorWidget()->setMimeType(Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName)).type());
return b;
}
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 53f86f0f8d..24888b47e1 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -152,7 +152,7 @@ public:
QString id() const;
bool isTemporary() const { return false; }
- virtual bool open(const QString & fileName);
+ virtual bool open(QString *errorString, const QString & fileName);
};
class CPPEditorWidget : public TextEditor::BaseTextEditorWidget
diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp
index 17f2d59bac..263ac2bec9 100644
--- a/src/plugins/designer/formwindoweditor.cpp
+++ b/src/plugins/designer/formwindoweditor.cpp
@@ -46,6 +46,7 @@
#include <texteditor/plaintexteditor.h>
#include <utils/qtcassert.h>
+#include <utils/fileutils.h>
#include <QtDesigner/QDesignerFormWindowInterface>
@@ -79,7 +80,7 @@ FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditor *editor,
connect(form, SIGNAL(changed()), this, SIGNAL(changed()));
// Revert to saved/load externally modified files.
- connect(&d->m_file, SIGNAL(reload(QString)), this, SLOT(slotOpen(QString)));
+ connect(&d->m_file, SIGNAL(reload(QString*,QString)), this, SLOT(slotOpen(QString*,QString)));
// Force update of open editors model.
connect(&d->m_file, SIGNAL(saved()), this, SIGNAL(changed()));
connect(&d->m_file, SIGNAL(changed()), this, SIGNAL(changed()));
@@ -126,12 +127,12 @@ bool FormWindowEditor::createNew(const QString &contents)
return true;
}
-void FormWindowEditor::slotOpen(const QString &fileName)
+void FormWindowEditor::slotOpen(QString *errorString, const QString &fileName)
{
- open(fileName);
+ open(errorString, fileName);
}
-bool FormWindowEditor::open(const QString &fileName)
+bool FormWindowEditor::open(QString *errorString, const QString &fileName)
{
if (Designer::Constants::Internal::debug)
qDebug() << "FormWindowEditor::open" << fileName;
@@ -147,15 +148,14 @@ bool FormWindowEditor::open(const QString &fileName)
const QFileInfo fi(fileName);
const QString absfileName = fi.absoluteFilePath();
- QFile file(absfileName);
- if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
+ Utils::FileReader reader;
+ if (!reader.fetch(absfileName, QIODevice::Text, errorString))
return false;
form->setFileName(absfileName);
- const QString contents = QString::fromUtf8(file.readAll());
+ const QString contents = QString::fromUtf8(reader.data());
form->setContents(contents);
- file.close();
if (!form->mainContainer())
return false;
form->setDirty(false);
diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h
index f7304af204..dec05b9095 100644
--- a/src/plugins/designer/formwindoweditor.h
+++ b/src/plugins/designer/formwindoweditor.h
@@ -71,7 +71,7 @@ public:
// IEditor
virtual bool createNew(const QString &contents = QString());
- virtual bool open(const QString &fileName = QString());
+ virtual bool open(QString *errorString, const QString &fileName = QString());
virtual Core::IFile *file();
virtual QString id() const;
virtual QString displayName() const;
@@ -100,7 +100,7 @@ public slots:
void configureXmlEditor() const;
private slots:
- void slotOpen(const QString &fileName);
+ void slotOpen(QString *errorString, const QString &fileName);
private:
void syncXmlEditor(const QString &contents);
diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp
index 8955eee9a5..714d479efe 100644
--- a/src/plugins/designer/formwindowfile.cpp
+++ b/src/plugins/designer/formwindowfile.cpp
@@ -141,17 +141,20 @@ Core::IFile::ReloadBehavior FormWindowFile::reloadBehavior(ChangeTrigger state,
return BehaviorAsk;
}
-void FormWindowFile::reload(ReloadFlag flag, ChangeType type)
+bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
if (flag == FlagIgnore)
- return;
+ return true;
if (type == TypePermissions) {
emit changed();
} else {
emit aboutToReload();
- emit reload(m_fileName);
+ emit reload(errorString, m_fileName);
+ if (!errorString->isEmpty())
+ return false;
emit reloaded();
}
+ return true;
}
QString FormWindowFile::defaultPath() const
diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h
index b120701631..4bc1075927 100644
--- a/src/plugins/designer/formwindowfile.h
+++ b/src/plugins/designer/formwindowfile.h
@@ -59,7 +59,7 @@ public:
virtual bool isReadOnly() const;
virtual bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
@@ -75,7 +75,7 @@ public:
signals:
// Internal
void saved();
- void reload(const QString &);
+ void reload(QString *errorString, const QString &);
void setDisplayName(const QString &);
public slots:
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index c1bab06f6f..ebec74a6e9 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -619,8 +619,10 @@ Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger sta
return BehaviorSilent;
}
-void GenericProjectFile::reload(ReloadFlag flag, ChangeType type)
+bool GenericProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
+ Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
+ return true;
}
diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h
index ce2746dcd0..4ec07fa091 100644
--- a/src/plugins/genericprojectmanager/genericproject.h
+++ b/src/plugins/genericprojectmanager/genericproject.h
@@ -172,7 +172,7 @@ public:
virtual void rename(const QString &newName);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
GenericProject *m_project;
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index d77ad8b64a..1a456712d1 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -205,10 +205,10 @@ QString GLSLEditorEditable::id() const
return QLatin1String(GLSLEditor::Constants::C_GLSLEDITOR_ID);
}
-bool GLSLEditorEditable::open(const QString &fileName)
+bool GLSLEditorEditable::open(QString *errorString, const QString &fileName)
{
editorWidget()->setMimeType(Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName)).type());
- bool b = TextEditor::BaseTextEditor::open(fileName);
+ bool b = TextEditor::BaseTextEditor::open(errorString, fileName);
return b;
}
diff --git a/src/plugins/glsleditor/glsleditoreditable.h b/src/plugins/glsleditor/glsleditoreditable.h
index 59823c8340..192567bbdb 100644
--- a/src/plugins/glsleditor/glsleditoreditable.h
+++ b/src/plugins/glsleditor/glsleditoreditable.h
@@ -51,7 +51,7 @@ public:
Core::IEditor *duplicate(QWidget *parent);
QString id() const;
bool isTemporary() const { return false; }
- virtual bool open(const QString &fileName);
+ virtual bool open(QString *errorString, const QString &fileName);
virtual QString preferredModeType() const;
};
diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp
index c6f760a164..830f075856 100644
--- a/src/plugins/imageviewer/imageviewer.cpp
+++ b/src/plugins/imageviewer/imageviewer.cpp
@@ -45,6 +45,7 @@
#include <QtCore/QMap>
#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
#include <QtGui/QWidget>
#include <QtCore/QtDebug>
@@ -116,10 +117,12 @@ bool ImageViewer::createNew(const QString &contents)
return false;
}
-bool ImageViewer::open(const QString &fileName)
+bool ImageViewer::open(QString *errorString, const QString &fileName)
{
- if (!d_ptr->imageView->openFile(fileName))
+ if (!d_ptr->imageView->openFile(fileName)) {
+ *errorString = tr("Cannot open image file %1").arg(QDir::toNativeSeparators(fileName));
return false;
+ }
setDisplayName(QFileInfo(fileName).fileName());
d_ptr->file->setFileName(fileName);
// d_ptr->file->setMimeType
diff --git a/src/plugins/imageviewer/imageviewer.h b/src/plugins/imageviewer/imageviewer.h
index b1656e58a2..e2770e6b68 100644
--- a/src/plugins/imageviewer/imageviewer.h
+++ b/src/plugins/imageviewer/imageviewer.h
@@ -56,7 +56,7 @@ public:
~ImageViewer();
bool createNew(const QString &contents = QString());
- bool open(const QString &fileName = QString());
+ bool open(QString *errorString, const QString &fileName = QString());
Core::IFile *file();
QString id() const;
QString displayName() const;
diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp
index a993d00fa1..4d1fa46455 100644
--- a/src/plugins/imageviewer/imageviewerfile.cpp
+++ b/src/plugins/imageviewer/imageviewerfile.cpp
@@ -74,15 +74,17 @@ Core::IFile::ReloadBehavior ImageViewerFile::reloadBehavior(Core::IFile::ChangeT
return BehaviorAsk;
}
-void ImageViewerFile::reload(Core::IFile::ReloadFlag flag,
+bool ImageViewerFile::reload(QString *errorString,
+ Core::IFile::ReloadFlag flag,
Core::IFile::ChangeType type)
{
if (flag == FlagIgnore)
- return;
+ return true;
if (type == TypePermissions) {
emit changed();
+ return true;
} else {
- d_ptr->editor->open(d_ptr->fileName);
+ return d_ptr->editor->open(errorString, d_ptr->fileName);
}
}
diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h
index b4ee14baa9..b449bb16c0 100644
--- a/src/plugins/imageviewer/imageviewerfile.h
+++ b/src/plugins/imageviewer/imageviewerfile.h
@@ -62,7 +62,7 @@ public:
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
void setMimetype(const QString &mimetype);
void setFileName(const QString &filename);
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 4fac404e69..0e6861c365 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -740,9 +740,9 @@ QString QmlJSEditorEditable::id() const
return QLatin1String(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
}
-bool QmlJSEditorEditable::open(const QString &fileName)
+bool QmlJSEditorEditable::open(QString *errorString, const QString &fileName)
{
- bool b = TextEditor::BaseTextEditor::open(fileName);
+ bool b = TextEditor::BaseTextEditor::open(errorString, fileName);
editorWidget()->setMimeType(Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName)).type());
return b;
}
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h
index a94772597c..adfcd4c449 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.h
+++ b/src/plugins/qmljseditor/qmljseditoreditable.h
@@ -50,7 +50,7 @@ public:
Core::IEditor *duplicate(QWidget *parent);
QString id() const;
bool isTemporary() const { return false; }
- virtual bool open(const QString & fileName);
+ virtual bool open(QString *errorString, const QString & fileName);
virtual QString preferredModeType() const;
void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason);
};
diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
index bcaf5323c5..64a4c723c7 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
@@ -100,10 +100,12 @@ Core::IFile::ReloadBehavior QmlProjectFile::reloadBehavior(ChangeTrigger state,
return BehaviorSilent;
}
-void QmlProjectFile::reload(ReloadFlag flag, ChangeType type)
+bool QmlProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
+ Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
+ return true;
}
} // namespace Internal
diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.h b/src/plugins/qmlprojectmanager/qmlprojectfile.h
index 9f30d092ce..e9992fee0a 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectfile.h
+++ b/src/plugins/qmlprojectmanager/qmlprojectfile.h
@@ -62,7 +62,7 @@ public:
virtual bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
QmlProject *m_project;
diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp
index 8406644147..bd4332411d 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.cpp
+++ b/src/plugins/qt4projectmanager/qt4nodes.cpp
@@ -231,13 +231,14 @@ Core::IFile::ReloadBehavior Qt4PriFile::reloadBehavior(ChangeTrigger state, Chan
return BehaviorSilent;
}
-void Qt4PriFile::reload(ReloadFlag flag, ChangeType type)
+bool Qt4PriFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
+ Q_UNUSED(errorString)
Q_UNUSED(flag)
- Q_UNUSED(type)
if (type == TypePermissions)
- return;
+ return true;
m_priFile->scheduleUpdate();
+ return true;
}
/*!
@@ -1130,11 +1131,17 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
// So the modification time might not change between those two saves.
// We manually tell each editor to reload it's file.
// (The .pro files are notified by the file system watcher.)
+ QStringList errorStrings;
foreach (Core::IEditor *editor, Core::ICore::instance()->editorManager()->editorsForFileName(m_projectFilePath)) {
if (Core::IFile *editorFile = editor->file()) {
- editorFile->reload(Core::IFile::FlagReload, Core::IFile::TypeContents);
+ QString errorString;
+ if (!editorFile->reload(&errorString, Core::IFile::FlagReload, Core::IFile::TypeContents))
+ errorStrings << errorString;
}
}
+ if (!errorStrings.isEmpty())
+ QMessageBox::warning(Core::ICore::instance()->mainWindow(), tr("File Error"),
+ errorStrings.join(QLatin1String("\n")));
includeFile->deref();
}
diff --git a/src/plugins/qt4projectmanager/qt4nodes.h b/src/plugins/qt4projectmanager/qt4nodes.h
index 7edf9abfc8..ad97338bf0 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.h
+++ b/src/plugins/qt4projectmanager/qt4nodes.h
@@ -128,7 +128,7 @@ public:
virtual bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
Qt4PriFileNode *m_priFile;
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 173bebacfe..9af9a7082d 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -238,10 +238,12 @@ Core::IFile::ReloadBehavior Qt4ProjectFile::reloadBehavior(ChangeTrigger state,
return BehaviorSilent;
}
-void Qt4ProjectFile::reload(ReloadFlag flag, ChangeType type)
+bool Qt4ProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
+ Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
+ return true;
}
/*!
diff --git a/src/plugins/qt4projectmanager/qt4project.h b/src/plugins/qt4projectmanager/qt4project.h
index 5c9b487eb0..454572f6f5 100644
--- a/src/plugins/qt4projectmanager/qt4project.h
+++ b/src/plugins/qt4projectmanager/qt4project.h
@@ -92,7 +92,7 @@ public:
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
const QString m_mimeType;
diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp
index 65f1f12121..d80fda36f8 100644
--- a/src/plugins/resourceeditor/resourceeditorw.cpp
+++ b/src/plugins/resourceeditor/resourceeditorw.cpp
@@ -112,7 +112,7 @@ bool ResourceEditorW::createNew(const QString &contents)
return rc;
}
-bool ResourceEditorW::open(const QString &fileName /* = QString() */)
+bool ResourceEditorW::open(QString *errorString, const QString &fileName /* = QString() */)
{
if (debugResourceEditorW)
qDebug() << "ResourceEditorW::open: " << fileName;
@@ -126,11 +126,10 @@ bool ResourceEditorW::open(const QString &fileName /* = QString() */)
const QString absFileName = fi.absoluteFilePath();
- if (!fi.isReadable())
- return false;
-
- if (!m_resourceEditor->load(absFileName))
+ if (!m_resourceEditor->load(absFileName)) {
+ *errorString = m_resourceEditor->errorMessage();
return false;
+ }
setDisplayName(fi.fileName());
@@ -208,17 +207,19 @@ Core::IFile::ReloadBehavior ResourceEditorFile::reloadBehavior(ChangeTrigger sta
return BehaviorAsk;
}
-void ResourceEditorFile::reload(ReloadFlag flag, ChangeType type)
+bool ResourceEditorFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
if (flag == FlagIgnore)
- return;
+ return true;
if (type == TypePermissions) {
emit changed();
} else {
emit aboutToReload();
- if (m_parent->open(m_parent->m_resourceEditor->fileName()))
- emit reloaded();
+ if (!m_parent->open(errorString, m_parent->m_resourceEditor->fileName()))
+ return false;
+ emit reloaded();
}
+ return true;
}
QString ResourceEditorFile::defaultPath() const
diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h
index 075dece673..031079c2ff 100644
--- a/src/plugins/resourceeditor/resourceeditorw.h
+++ b/src/plugins/resourceeditor/resourceeditorw.h
@@ -63,7 +63,7 @@ public:
bool isReadOnly() const;
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
QString defaultPath() const;
QString suggestedFileName() const;
virtual QString mimeType() const;
@@ -86,7 +86,7 @@ public:
// IEditor
bool createNew(const QString &contents);
- bool open(const QString &fileName = QString());
+ bool open(QString *errorString, const QString &fileName = QString());
bool duplicateSupported() const { return false; }
Core::IEditor *duplicate(QWidget *) { return 0; }
Core::IFile *file() { return m_resourceFile; }
diff --git a/src/plugins/tasklist/taskfile.cpp b/src/plugins/tasklist/taskfile.cpp
index 7c0b5429ac..e26a4b6c6c 100644
--- a/src/plugins/tasklist/taskfile.cpp
+++ b/src/plugins/tasklist/taskfile.cpp
@@ -97,15 +97,17 @@ Core::IFile::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, Change
return BehaviorSilent;
}
-void TaskFile::reload(ReloadFlag flag, ChangeType type)
+bool TaskFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
Q_UNUSED(flag);
if (type == TypePermissions)
- return;
- open(m_fileName);
- if (type == TypeRemoved)
+ return true;
+ if (type == TypeRemoved) {
deleteLater();
+ return true;
+ }
+ return open(errorString, m_fileName);
}
void TaskFile::rename(const QString &newName)
@@ -113,10 +115,10 @@ void TaskFile::rename(const QString &newName)
Q_UNUSED(newName);
}
-bool TaskFile::open(const QString &fileName)
+bool TaskFile::open(QString *errorString, const QString &fileName)
{
m_fileName = fileName;
- return TaskList::TaskListPlugin::instance()->loadFile(m_context, m_fileName);
+ return TaskList::TaskListPlugin::instance()->loadFile(errorString, m_context, m_fileName);
}
ProjectExplorer::Project *TaskFile::context() const
diff --git a/src/plugins/tasklist/taskfile.h b/src/plugins/tasklist/taskfile.h
index 0626fd6498..10638b1cdf 100644
--- a/src/plugins/tasklist/taskfile.h
+++ b/src/plugins/tasklist/taskfile.h
@@ -60,10 +60,10 @@ public:
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
void rename(const QString &newName);
- bool open(const QString &fileName);
+ bool open(QString *errorString, const QString &fileName);
ProjectExplorer::Project *context() const;
void setContext(ProjectExplorer::Project *context);
diff --git a/src/plugins/tasklist/taskfilefactory.cpp b/src/plugins/tasklist/taskfilefactory.cpp
index 1a207169bd..c66557084f 100644
--- a/src/plugins/tasklist/taskfilefactory.cpp
+++ b/src/plugins/tasklist/taskfilefactory.cpp
@@ -38,6 +38,9 @@
#include <coreplugin/icore.h>
#include <coreplugin/filemanager.h>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMessageBox>
+
using namespace TaskList::Internal;
// --------------------------------------------------------------------------
@@ -79,7 +82,9 @@ Core::IFile *TaskFileFactory::open(ProjectExplorer::Project *context, const QStr
TaskFile *file = new TaskFile(this);
file->setContext(context);
- if (!file->open(fileName)) {
+ QString errorString;
+ if (!file->open(&errorString, fileName)) {
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("File Error"), errorString);
delete file;
return 0;
}
diff --git a/src/plugins/tasklist/tasklistplugin.cpp b/src/plugins/tasklist/tasklistplugin.cpp
index e050a21711..7e0e9a1c98 100644
--- a/src/plugins/tasklist/tasklistplugin.cpp
+++ b/src/plugins/tasklist/tasklistplugin.cpp
@@ -73,11 +73,14 @@ TaskListPlugin *TaskListPlugin::m_instance = 0;
class Internal::TaskListPluginPrivate {
public:
- bool parseTaskFile(ProjectExplorer::Project *context, const QString &name)
+ bool parseTaskFile(QString *errorString, ProjectExplorer::Project *context, const QString &name)
{
QFile tf(name);
- if (!tf.open(QIODevice::ReadOnly))
+ if (!tf.open(QIODevice::ReadOnly)) {
+ *errorString = TaskListPlugin::tr("Cannot open task file %1: %2").arg(
+ QDir::toNativeSeparators(name), tf.errorString());
return false;
+ }
while (!tf.atEnd())
{
@@ -211,10 +214,10 @@ bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMess
void TaskListPlugin::extensionsInitialized()
{ }
-bool TaskListPlugin::loadFile(ProjectExplorer::Project *context, const QString &fileName)
+bool TaskListPlugin::loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName)
{
clearTasks();
- return d->parseTaskFile(context, fileName);
+ return d->parseTaskFile(errorString, context, fileName);
}
bool TaskListPlugin::monitorFile(ProjectExplorer::Project *context, const QString &fileName)
diff --git a/src/plugins/tasklist/tasklistplugin.h b/src/plugins/tasklist/tasklistplugin.h
index fe52908588..141e73d2c1 100644
--- a/src/plugins/tasklist/tasklistplugin.h
+++ b/src/plugins/tasklist/tasklistplugin.h
@@ -58,7 +58,7 @@ public:
void extensionsInitialized();
- bool loadFile(ProjectExplorer::Project *context, const QString &fileName);
+ bool loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName);
bool monitorFile(ProjectExplorer::Project *context, const QString &fileName);
void stopMonitoring();
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index f555cd549a..e8ee9faeaf 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -454,7 +454,7 @@ void BaseTextDocument::checkPermissions()
emit changed();
}
-bool BaseTextDocument::open(const QString &fileName)
+bool BaseTextDocument::open(QString *errorString, const QString &fileName)
{
QString title = tr("untitled");
if (!fileName.isEmpty()) {
@@ -462,16 +462,16 @@ bool BaseTextDocument::open(const QString &fileName)
d->m_fileIsReadOnly = !fi.isWritable();
d->m_fileName = QDir::cleanPath(fi.absoluteFilePath());
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly))
- return false;
-
title = fi.fileName();
QByteArray buf;
try {
- buf = file.readAll();
+ Utils::FileReader reader;
+ if (!reader.fetch(fileName, errorString))
+ return false;
+ buf = reader.data();
} catch (std::bad_alloc) {
+ *errorString = tr("Out of memory");
return false;
}
int bytesRead = buf.size();
@@ -591,20 +591,22 @@ bool BaseTextDocument::open(const QString &fileName)
return true;
}
-void BaseTextDocument::reload(QTextCodec *codec)
+bool BaseTextDocument::reload(QString *errorString, QTextCodec *codec)
{
- QTC_ASSERT(codec, return);
+ QTC_ASSERT(codec, return false);
d->m_codec = codec;
- reload();
+ return reload(errorString);
}
-void BaseTextDocument::reload()
+bool BaseTextDocument::reload(QString *errorString)
{
emit aboutToReload();
documentClosing(); // removes text marks non-permanently
- if (open(d->m_fileName))
- emit reloaded();
+ if (!open(errorString, d->m_fileName))
+ return false;
+ emit reloaded();
+ return true;
}
Core::IFile::ReloadBehavior BaseTextDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const
@@ -619,14 +621,15 @@ Core::IFile::ReloadBehavior BaseTextDocument::reloadBehavior(ChangeTrigger state
return BehaviorAsk;
}
-void BaseTextDocument::reload(ReloadFlag flag, ChangeType type)
+bool BaseTextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
if (flag == FlagIgnore)
- return;
+ return true;
if (type == TypePermissions) {
checkPermissions();
+ return true;
} else {
- reload();
+ return reload(errorString);
}
}
diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h
index f08c1dd09d..bc59daae7b 100644
--- a/src/plugins/texteditor/basetextdocument.h
+++ b/src/plugins/texteditor/basetextdocument.h
@@ -77,7 +77,7 @@ public:
virtual bool isSaveAsAllowed() const;
virtual void checkPermissions();
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
virtual QString mimeType() const;
void setMimeType(const QString &mt);
virtual void rename(const QString &newName);
@@ -88,8 +88,8 @@ public:
void setDefaultPath(const QString &defaultPath);
void setSuggestedFileName(const QString &suggestedFileName);
- virtual bool open(const QString &fileName = QString());
- virtual void reload();
+ virtual bool open(QString *errorString, const QString &fileName = QString());
+ virtual bool reload(QString *errorString);
QTextDocument *document() const;
void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
@@ -100,7 +100,7 @@ public:
void setCodec(QTextCodec *c);
QByteArray decodingErrorSample() const;
- void reload(QTextCodec *codec);
+ bool reload(QString *errorString, QTextCodec *codec);
void cleanWhitespace(const QTextCursor &cursor);
signals:
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index ffb656716a..b6117a8919 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -90,6 +90,7 @@
#include <QtGui/QToolBar>
#include <QtGui/QInputDialog>
#include <QtGui/QMenu>
+#include <QtGui/QMessageBox>
//#define DO_FOO
@@ -520,14 +521,18 @@ void BaseTextEditorWidget::selectEncoding()
CodecSelector codecSelector(this, doc);
switch (codecSelector.exec()) {
- case CodecSelector::Reload:
- doc->reload(codecSelector.selectedCodec());
+ case CodecSelector::Reload: {
+ QString errorString;
+ if (!doc->reload(&errorString, codecSelector.selectedCodec())) {
+ QMessageBox::critical(this, tr("File Error"), errorString);
+ break;
+ }
setReadOnly(d->m_document->hasDecodingError());
if (doc->hasDecodingError())
currentEditorChanged(Core::EditorManager::instance()->currentEditor());
else
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String(Constants::SELECT_ENCODING));
- break;
+ break; }
case CodecSelector::Save:
doc->setCodec(codecSelector.selectedCodec());
Core::EditorManager::instance()->saveEditor(editor());
@@ -555,9 +560,9 @@ bool BaseTextEditorWidget::createNew(const QString &contents)
return true;
}
-bool BaseTextEditorWidget::open(const QString &fileName)
+bool BaseTextEditorWidget::open(QString *errorString, const QString &fileName)
{
- if (d->m_document->open(fileName)) {
+ if (d->m_document->open(errorString, fileName)) {
moveCursor(QTextCursor::Start);
setReadOnly(d->m_document->hasDecodingError());
return true;
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 61727fd46c..a83072bcc5 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -138,7 +138,7 @@ public:
// EditorInterface
Core::IFile * file();
bool createNew(const QString &contents);
- virtual bool open(const QString &fileName = QString());
+ virtual bool open(QString *errorString, const QString &fileName = QString());
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
QString displayName() const;
@@ -560,7 +560,7 @@ public:
//QWidget *widget() { return e; }
Core::IFile * file() { return e->file(); }
bool createNew(const QString &contents) { return e->createNew(contents); }
- bool open(const QString &fileName = QString()) { return e->open(fileName); }
+ bool open(QString *errorString, const QString &fileName = QString()) { return e->open(errorString, fileName); }
QString displayName() const { return e->displayName(); }
void setDisplayName(const QString &title) { e->setDisplayName(title); emit changed(); }
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp
index 6555131b8b..1c95dfdf77 100644
--- a/src/plugins/vcsbase/submiteditorfile.cpp
+++ b/src/plugins/vcsbase/submiteditorfile.cpp
@@ -88,8 +88,10 @@ Core::IFile::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state
return BehaviorSilent;
}
-void SubmitEditorFile::reload(ReloadFlag flag, ChangeType type)
+bool SubmitEditorFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
+ Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
+ return true;
}
diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h
index 9987c71006..554d46f7b7 100644
--- a/src/plugins/vcsbase/submiteditorfile.h
+++ b/src/plugins/vcsbase/submiteditorfile.h
@@ -55,7 +55,7 @@ public:
bool isSaveAsAllowed() const { return false; }
bool save(QString *errorString, const QString &fileName);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
+ bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
void rename(const QString &newName);
void setFileName(const QString name);
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
index 66eb7e9fd5..645131ceeb 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
@@ -330,26 +330,20 @@ bool VCSBaseSubmitEditor::createNew(const QString &contents)
return true;
}
-bool VCSBaseSubmitEditor::open(const QString &fileName)
+bool VCSBaseSubmitEditor::open(QString *errorString, const QString &fileName)
{
if (fileName.isEmpty())
return false;
- const QFileInfo fi(fileName);
- if (!fi.isFile() || !fi.isReadable())
+ Utils::FileReader reader;
+ if (!reader.fetch(fileName, QIODevice::Text, errorString))
return false;
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
- qWarning("Unable to open %s: %s", qPrintable(fileName), qPrintable(file.errorString()));
- return false;
- }
-
- const QString text = QString::fromLocal8Bit(file.readAll());
+ const QString text = QString::fromLocal8Bit(reader.data());
if (!createNew(text))
return false;
- m_d->m_file->setFileName(fi.absoluteFilePath());
+ m_d->m_file->setFileName(QFileInfo(fileName).absoluteFilePath());
return true;
}
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h
index 1273a00918..3e4f7eae55 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.h
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h
@@ -119,7 +119,7 @@ public:
// Core::IEditor
virtual bool createNew(const QString &contents);
- virtual bool open(const QString &fileName);
+ virtual bool open(QString *errorString, const QString &fileName);
virtual Core::IFile *file();
virtual QString displayName() const;
virtual void setDisplayName(const QString &title);