diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-06 01:20:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-08 00:35:27 +0100 |
commit | e2eabb41321bbac5d9b2aca1930f734379e490ab (patch) | |
tree | e231b9773da7b85b7a377fbbc4b52c6e9eee0d3e /Userland/Libraries/LibGUI | |
parent | c4edb9f6c2cc6755f5e108af93c90e97a4b2e778 (diff) | |
download | serenity-e2eabb41321bbac5d9b2aca1930f734379e490ab.zip |
LibCore: Use ErrorOr<T> in Core::AnonymousBuffer
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Clipboard.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Window.cpp | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGUI/Clipboard.cpp b/Userland/Libraries/LibGUI/Clipboard.cpp index 2fdc5b1e3b..09622a979e 100644 --- a/Userland/Libraries/LibGUI/Clipboard.cpp +++ b/Userland/Libraries/LibGUI/Clipboard.cpp @@ -106,11 +106,12 @@ RefPtr<Gfx::Bitmap> Clipboard::bitmap() const void Clipboard::set_data(ReadonlyBytes const& data, String const& type, HashMap<String, String> const& metadata) { - auto buffer = Core::AnonymousBuffer::create_with_size(data.size()); - if (!buffer.is_valid()) { + auto buffer_or_error = Core::AnonymousBuffer::create_with_size(data.size()); + if (buffer_or_error.is_error()) { dbgln("GUI::Clipboard::set_data() failed to create a buffer"); return; } + auto buffer = buffer_or_error.release_value(); if (!data.is_empty()) memcpy(buffer.data<void>(), data.data(), data.size()); diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index 67a5d0dd7b..67138b90ab 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -862,14 +862,14 @@ OwnPtr<WindowBackingStore> Window::create_backing_store(const Gfx::IntSize& size size_t pitch = Gfx::Bitmap::minimum_pitch(size.width(), format); size_t size_in_bytes = size.height() * pitch; - auto buffer = Core::AnonymousBuffer::create_with_size(round_up_to_power_of_two(size_in_bytes, PAGE_SIZE)); - if (!buffer.is_valid()) { + auto buffer_or_error = Core::AnonymousBuffer::create_with_size(round_up_to_power_of_two(size_in_bytes, PAGE_SIZE)); + if (buffer_or_error.is_error()) { perror("anon_create"); return {}; } // FIXME: Plumb scale factor here eventually. - auto bitmap = Gfx::Bitmap::try_create_with_anonymous_buffer(format, move(buffer), size, 1, {}); + auto bitmap = Gfx::Bitmap::try_create_with_anonymous_buffer(format, buffer_or_error.release_value(), size, 1, {}); if (!bitmap) { VERIFY(size.width() <= INT16_MAX); VERIFY(size.height() <= INT16_MAX); |