Skip to content

Commit

Permalink
TextEditor: Don't try to load contents of files we didn't even open
Browse files Browse the repository at this point in the history
If the CFile::open() call fails, we shouldn't continue with trying to
load the file.
  • Loading branch information
awesomekling committed Aug 23, 2019
1 parent d56786c commit b1bc7a1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Applications/TextEditor/TextEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit b1bc7a1

Please sign in to comment.