forked from qt-creator/qt-creator
Editor manager: Abort with a single message if file is not readable.
We show a dialog that offers opening a file in a different editor type if opening a file fails, but we should not do that if opening the file fails because it is not readable. With this change, documents now specify if they failed to open a file because reading failed, or because they could not handle the file contents. Task-number: QTCREATORBUG-14495 Change-Id: I5d4b7cfa74b87ef21b9b55bc30b3ebe2f8238dfa Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
This commit is contained in:
@@ -57,22 +57,23 @@ SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *paramete
|
||||
setTemporary(true);
|
||||
}
|
||||
|
||||
bool SubmitEditorFile::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||
Core::IDocument::OpenResult SubmitEditorFile::open(QString *errorString, const QString &fileName,
|
||||
const QString &realFileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
return OpenResult::ReadError;
|
||||
|
||||
FileReader reader;
|
||||
if (!reader.fetch(realFileName, QIODevice::Text, errorString))
|
||||
return false;
|
||||
return OpenResult::ReadError;
|
||||
|
||||
const QString text = QString::fromLocal8Bit(reader.data());
|
||||
if (!m_editor->setFileContents(text.toUtf8()))
|
||||
return false;
|
||||
return OpenResult::CannotHandle;
|
||||
|
||||
setFilePath(FileName::fromString(fileName));
|
||||
setModified(fileName != realFileName);
|
||||
return true;
|
||||
return OpenResult::Success;
|
||||
}
|
||||
|
||||
bool SubmitEditorFile::setContents(const QByteArray &contents)
|
||||
|
||||
Reference in New Issue
Block a user