summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-11-20 14:44:31 +0100
committerLinus Groh <mail@linusgroh.de>2021-11-21 11:49:06 +0000
commit81128c5100894141db88aa1b2e9eb0e981b49fa6 (patch)
tree55c353c0c91abac65d8380128fffb9e0d5d9b6ad /Userland
parentd29f094ffa8fdc49b63fc8cedcf4d0d731fdfdf0 (diff)
downloadserenity-81128c5100894141db88aa1b2e9eb0e981b49fa6.zip
Browser: Make paste access to Clipboard atomic
This avoids data race issues and saves a synchronous request to the ClipboardServer.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Browser/Tab.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 88c788377b..7fbae4a550 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -136,9 +136,10 @@ Tab::Tab(BrowserWindow& window)
};
m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste && Go", [this](auto&) {
- if (!GUI::Clipboard::the().mime_type().starts_with("text/"))
+ auto [data, mime_type, _] = GUI::Clipboard::the().data_and_type();
+ if (!mime_type.starts_with("text/"))
return;
- auto const& paste_text = GUI::Clipboard::the().data();
+ auto const& paste_text = data;
if (paste_text.is_empty())
return;
m_location_box->set_text(paste_text);