summaryrefslogtreecommitdiff
path: root/Userland/Applications/HexEditor/HexEditorWidget.cpp
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-06-29 20:12:53 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-30 11:13:54 +0200
commitd8be530397bb10dd7f700babcaffcfce5a14b12c (patch)
tree7d368afed723ff54ebaecc02a23628395af99840 /Userland/Applications/HexEditor/HexEditorWidget.cpp
parent4c018909f72719b8916cd1480216e9ecb7a16d7a (diff)
downloadserenity-d8be530397bb10dd7f700babcaffcfce5a14b12c.zip
AK+Everywhere: Remove "null state" of LexicalPath
This removes the default constructor of LexicalPath, and subsequently modifies all its users to accommodate the change.
Diffstat (limited to 'Userland/Applications/HexEditor/HexEditorWidget.cpp')
-rw-r--r--Userland/Applications/HexEditor/HexEditorWidget.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp
index 44805956c0..5534ebe744 100644
--- a/Userland/Applications/HexEditor/HexEditorWidget.cpp
+++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp
@@ -78,7 +78,7 @@ HexEditorWidget::HexEditorWidget()
if (file_size.has_value() && file_size.value() > 0) {
m_document_dirty = false;
m_editor->set_buffer(ByteBuffer::create_zeroed(file_size.value()));
- set_path(LexicalPath());
+ set_path({});
update_title();
} else {
GUI::MessageBox::show(window(), "Invalid file size entered.", "Error", GUI::MessageBox::Type::Error);
@@ -130,7 +130,7 @@ HexEditorWidget::HexEditorWidget()
}
m_document_dirty = false;
- set_path(LexicalPath(save_path.value()));
+ set_path(save_path.value());
dbgln("Wrote document to {}", save_path.value());
});
@@ -311,11 +311,18 @@ void HexEditorWidget::initialize_menubar(GUI::Menubar& menubar)
help_menu.add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"), window()));
}
-void HexEditorWidget::set_path(const LexicalPath& lexical_path)
+void HexEditorWidget::set_path(StringView const& path)
{
- m_path = lexical_path.string();
- m_name = lexical_path.title();
- m_extension = lexical_path.extension();
+ if (path.is_empty()) {
+ m_path = {};
+ m_name = {};
+ m_extension = {};
+ } else {
+ auto lexical_path = LexicalPath(path);
+ m_path = lexical_path.string();
+ m_name = lexical_path.title();
+ m_extension = lexical_path.extension();
+ }
update_title();
}
@@ -342,7 +349,7 @@ void HexEditorWidget::open_file(const String& path)
m_document_dirty = false;
m_editor->set_buffer(file->read_all()); // FIXME: On really huge files, this is never going to work. Should really create a framework to fetch data from the file on-demand.
- set_path(LexicalPath(path));
+ set_path(path);
}
bool HexEditorWidget::request_close()