FakeVim: Don't try to read from file which could not be opened

Change-Id: I3468d1a4c9e3ba7bcfd6526f5541b3ec4e84a3e4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Robert Loehning
2017-02-17 17:45:56 +01:00
parent 2d9dc5a27f
commit 6c8b1e268a

View File

@@ -1964,12 +1964,13 @@ void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handle
saved = !editor->document()->isModified();
if (saved) {
QFile file3(fileName);
file3.open(QIODevice::ReadOnly);
const QByteArray ba = file3.readAll();
handler->showMessage(MessageInfo, Tr::tr("\"%1\" %2 %3L, %4C written")
.arg(fileName).arg(' ').arg(ba.count('\n')).arg(ba.size()));
if (cmd.cmd == "wq")
delayedQuitRequested(cmd.hasBang, m_editorToHandler.key(handler));
if (file3.open(QIODevice::ReadOnly)) {
const QByteArray ba = file3.readAll();
handler->showMessage(MessageInfo, Tr::tr("\"%1\" %2 %3L, %4C written")
.arg(fileName).arg(' ').arg(ba.count('\n')).arg(ba.size()));
if (cmd.cmd == "wq")
delayedQuitRequested(cmd.hasBang, m_editorToHandler.key(handler));
}
}
}