summaryrefslogtreecommitdiff
path: root/Applications/TextEditor
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-23 19:10:14 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-23 19:11:56 +0200
commitb1bc7a1b5d9f436c7b2178b596b32a57ff990618 (patch)
treee524f0d511f02f6ec5d41ea523e9cc6fc889ddf2 /Applications/TextEditor
parentd56786ccd8dc6761d28e7ef0f4d6732c9a1d0c77 (diff)
downloadserenity-b1bc7a1b5d9f436c7b2178b596b32a57ff990618.zip
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.
Diffstat (limited to 'Applications/TextEditor')
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp3
1 files changed, 1 insertions, 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());