1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:17:34 +00:00

LibGUI: Make clipboard-as-bitmap parsing less data-race-y

This encourages the caller to first fetch data and type atomically, and
then parse that, instead of potentially making multiple requests.
This commit is contained in:
Ben Wiederhake 2021-11-20 13:04:38 +01:00 committed by Linus Groh
parent 55526634b6
commit b6419f2cf2
3 changed files with 13 additions and 12 deletions

View file

@ -32,6 +32,8 @@ public:
ByteBuffer data;
String mime_type;
HashMap<String, String> metadata;
RefPtr<Gfx::Bitmap> as_bitmap() const;
};
static void initialize(Badge<Application>);
@ -40,7 +42,6 @@ public:
DataAndType data_and_type() const;
ByteBuffer data() const { return data_and_type().data; }
String mime_type() const { return data_and_type().mime_type; }
RefPtr<Gfx::Bitmap> bitmap() const;
void set_data(ReadonlyBytes data, String const& mime_type = "text/plain", HashMap<String, String> const& metadata = {});
void set_plain_text(String const& text) { set_data(text.bytes()); }