mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
LibIPC: Explicitly mark HashMap copy, offer move interface
This commit is contained in:
parent
688d8febe4
commit
362773d4a6
4 changed files with 8 additions and 8 deletions
|
@ -150,7 +150,7 @@ ErrorOr<JsonObject> Clipboard::DataAndType::to_json() const
|
||||||
void Clipboard::set_data(ReadonlyBytes data, DeprecatedString const& type, HashMap<DeprecatedString, DeprecatedString> const& metadata)
|
void Clipboard::set_data(ReadonlyBytes data, DeprecatedString const& type, HashMap<DeprecatedString, DeprecatedString> const& metadata)
|
||||||
{
|
{
|
||||||
if (data.is_empty()) {
|
if (data.is_empty()) {
|
||||||
connection().async_set_clipboard_data({}, type, metadata);
|
connection().async_set_clipboard_data({}, type, metadata.clone().release_value_but_fixme_should_propagate_errors());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,18 +161,18 @@ void Clipboard::set_data(ReadonlyBytes data, DeprecatedString const& type, HashM
|
||||||
}
|
}
|
||||||
auto buffer = buffer_or_error.release_value();
|
auto buffer = buffer_or_error.release_value();
|
||||||
memcpy(buffer.data<void>(), data.data(), data.size());
|
memcpy(buffer.data<void>(), data.data(), data.size());
|
||||||
connection().async_set_clipboard_data(move(buffer), type, metadata);
|
connection().async_set_clipboard_data(move(buffer), type, metadata.clone().release_value_but_fixme_should_propagate_errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard::set_bitmap(Gfx::Bitmap const& bitmap, HashMap<DeprecatedString, DeprecatedString> const& additional_metadata)
|
void Clipboard::set_bitmap(Gfx::Bitmap const& bitmap, HashMap<DeprecatedString, DeprecatedString> const& additional_metadata)
|
||||||
{
|
{
|
||||||
HashMap<DeprecatedString, DeprecatedString> metadata(additional_metadata);
|
HashMap<DeprecatedString, DeprecatedString> metadata = additional_metadata.clone().release_value_but_fixme_should_propagate_errors();
|
||||||
metadata.set("width", DeprecatedString::number(bitmap.width()));
|
metadata.set("width", DeprecatedString::number(bitmap.width()));
|
||||||
metadata.set("height", DeprecatedString::number(bitmap.height()));
|
metadata.set("height", DeprecatedString::number(bitmap.height()));
|
||||||
metadata.set("scale", DeprecatedString::number(bitmap.scale()));
|
metadata.set("scale", DeprecatedString::number(bitmap.scale()));
|
||||||
metadata.set("format", DeprecatedString::number((int)bitmap.format()));
|
metadata.set("format", DeprecatedString::number((int)bitmap.format()));
|
||||||
metadata.set("pitch", DeprecatedString::number(bitmap.pitch()));
|
metadata.set("pitch", DeprecatedString::number(bitmap.pitch()));
|
||||||
set_data({ bitmap.scanline(0), bitmap.size_in_bytes() }, "image/x-serenityos", metadata);
|
set_data({ bitmap.scanline(0), bitmap.size_in_bytes() }, "image/x-serenityos", move(metadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard::clear()
|
void Clipboard::clear()
|
||||||
|
|
|
@ -17,8 +17,8 @@ class Dictionary {
|
||||||
public:
|
public:
|
||||||
Dictionary() = default;
|
Dictionary() = default;
|
||||||
|
|
||||||
Dictionary(HashMap<DeprecatedString, DeprecatedString> const& initial_entries)
|
Dictionary(HashMap<DeprecatedString, DeprecatedString>&& initial_entries)
|
||||||
: m_entries(initial_entries)
|
: m_entries(move(initial_entries))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data,
|
||||||
Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data()
|
Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data()
|
||||||
{
|
{
|
||||||
auto& storage = Storage::the();
|
auto& storage = Storage::the();
|
||||||
return { storage.buffer(), storage.mime_type(), storage.metadata() };
|
return { storage.buffer(), storage.mime_type(), storage.metadata().clone().release_value_but_fixme_should_propagate_errors() };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::notify_about_clipboard_change()
|
void ConnectionFromClient::notify_about_clipboard_change()
|
||||||
|
|
|
@ -71,5 +71,5 @@ void ConnectionToClipboardServer::set_bitmap(Gfx::Bitmap const& bitmap)
|
||||||
VERIFY(!buffer_or_error.is_error());
|
VERIFY(!buffer_or_error.is_error());
|
||||||
auto buffer = buffer_or_error.release_value();
|
auto buffer = buffer_or_error.release_value();
|
||||||
memcpy(buffer.data<u8>(), data.data(), data.size());
|
memcpy(buffer.data<u8>(), data.data(), data.size());
|
||||||
this->async_set_clipboard_data(buffer, "image/x-serenityos", metadata);
|
this->async_set_clipboard_data(buffer, "image/x-serenityos", move(metadata));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue