summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2023-01-14 22:11:56 -0500
committerAndrew Kaster <andrewdkaster@gmail.com>2023-02-04 17:20:31 -0700
commit689b3c2c264402e5901b1dc7a41ec19209f67164 (patch)
treeac94911d57387d34ff5d47ef82b3550b781ab9aa /Userland
parenta2dca2b76247157376d91d7948adb99e7626f224 (diff)
downloadserenity-689b3c2c264402e5901b1dc7a41ec19209f67164.zip
HexEditor: Propagate errors from `HexDocumentFile::set_title()`
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/HexEditor/HexDocument.cpp7
-rw-r--r--Userland/Applications/HexEditor/HexDocument.h2
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp2
3 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Applications/HexEditor/HexDocument.cpp b/Userland/Applications/HexEditor/HexDocument.cpp
index 2ce1677a6e..ce98bc65af 100644
--- a/Userland/Applications/HexEditor/HexDocument.cpp
+++ b/Userland/Applications/HexEditor/HexDocument.cpp
@@ -73,7 +73,7 @@ ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Co
{
auto document = TRY(adopt_nonnull_own_or_enomem(new HexDocumentFile(move(file))));
// FIXME: Remove this hackery
- document->set_file(move(document->m_file));
+ TRY(document->set_file(move(document->m_file)));
return document;
}
@@ -150,7 +150,7 @@ void HexDocumentFile::clear_changes()
m_changes.clear();
}
-void HexDocumentFile::set_file(NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<void> HexDocumentFile::set_file(NonnullOwnPtr<Core::Stream::File> file)
{
m_file = move(file);
@@ -159,11 +159,12 @@ void HexDocumentFile::set_file(NonnullOwnPtr<Core::Stream::File> file)
else
m_file_size = result.value();
- m_file->seek(0, SeekMode::SetPosition).release_value_but_fixme_should_propagate_errors();
+ TRY(m_file->seek(0, SeekMode::SetPosition));
clear_changes();
// make sure the next get operation triggers a read
m_buffer_file_pos = m_file_size + 1;
+ return {};
}
NonnullOwnPtr<Core::Stream::File> const& HexDocumentFile::file() const
diff --git a/Userland/Applications/HexEditor/HexDocument.h b/Userland/Applications/HexEditor/HexDocument.h
index 92c5f7ca09..3f19b8f3e6 100644
--- a/Userland/Applications/HexEditor/HexDocument.h
+++ b/Userland/Applications/HexEditor/HexDocument.h
@@ -64,7 +64,7 @@ public:
HexDocumentFile(HexDocumentFile&&) = default;
HexDocumentFile(HexDocumentFile const&) = delete;
- void set_file(NonnullOwnPtr<Core::Stream::File> file);
+ ErrorOr<void> set_file(NonnullOwnPtr<Core::Stream::File> file);
NonnullOwnPtr<Core::Stream::File> const& file() const;
ErrorOr<void> write_to_file();
ErrorOr<void> write_to_file(Core::Stream::File& file);
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp
index 623f33c242..e3c28811db 100644
--- a/Userland/Applications/HexEditor/HexEditor.cpp
+++ b/Userland/Applications/HexEditor/HexEditor.cpp
@@ -141,7 +141,7 @@ ErrorOr<void> HexEditor::save_as(NonnullOwnPtr<Core::Stream::File> new_file)
if (m_document->type() == HexDocument::Type::File) {
auto& file_document = static_cast<HexDocumentFile&>(*m_document);
TRY(file_document.write_to_file(*new_file));
- file_document.set_file(move(new_file));
+ TRY(file_document.set_file(move(new_file)));
} else {
auto& memory_document = static_cast<HexDocumentMemory&>(*m_document);
TRY(memory_document.write_to_file(*new_file));