mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-06 21:45:29 +00:00
TextEditor: Exit program when file is not opened
When trying to open files not permitted by the user, display the error message and exit.
This commit is contained in:
committed by
Andreas Kling
parent
67f01fd82e
commit
5df34f6567
@@ -583,12 +583,12 @@ void TextEditorWidget::update_title()
|
||||
window()->set_title(builder.to_string());
|
||||
}
|
||||
|
||||
void TextEditorWidget::open_file(const String& path)
|
||||
bool TextEditorWidget::open_file(const String& path)
|
||||
{
|
||||
auto file = Core::File::construct(path);
|
||||
if (!file->open(Core::IODevice::ReadOnly) && file->error() != ENOENT) {
|
||||
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: {}", path, strerror(errno)), "Error", GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_editor->set_text(file->read_all());
|
||||
@@ -598,6 +598,8 @@ void TextEditorWidget::open_file(const String& path)
|
||||
set_path(LexicalPath(path));
|
||||
|
||||
m_editor->set_focus(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextEditorWidget::request_close()
|
||||
|
||||
Reference in New Issue
Block a user