1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 02:13:56 +09: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
Notes: sideshowbarker 2024-07-19 12:33:38 +09:00

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