From b1bc7a1b5d9f436c7b2178b596b32a57ff990618 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 23 Aug 2019 19:10:14 +0200 Subject: [PATCH] TextEditor: Don't try to load contents of files we didn't even open If the CFile::open() call fails, we shouldn't continue with trying to load the file. --- Applications/TextEditor/TextEditorWidget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index e316e1de78..cf006278fb 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -192,11 +192,10 @@ void TextEditorWidget::set_path(const FileSystemPath& file) void TextEditorWidget::open_sesame(const String& path) { - dbgprintf("Our path to file in open_sesame: %s\n", path.characters()); CFile file(path); - if (!file.open(CIODevice::ReadOnly)) { GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + return; } m_editor->set_text(file.read_all());