1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 22:15:06 +00:00

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.
This commit is contained in:
Andreas Kling 2019-08-23 19:10:14 +02:00
parent d56786ccd8
commit b1bc7a1b5d

View file

@ -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());