mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 10:57:35 +00:00
LibGUI: Make paste access to Clipboard atomic
This avoids data race issues and saves a synchronous request to the ClipboardServer.
This commit is contained in:
parent
81128c5100
commit
c80dcc4671
1 changed files with 5 additions and 6 deletions
|
@ -1453,18 +1453,17 @@ void TextEditor::paste()
|
||||||
if (!is_editable())
|
if (!is_editable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Clipboard::the().mime_type().starts_with("text/"))
|
auto [data, mime_type, _] = GUI::Clipboard::the().data_and_type();
|
||||||
|
if (!mime_type.starts_with("text/"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto paste_text = Clipboard::the().data();
|
if (data.is_empty())
|
||||||
|
|
||||||
if (paste_text.is_empty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbgln_if(TEXTEDITOR_DEBUG, "Paste: \"{}\"", String::copy(paste_text));
|
dbgln_if(TEXTEDITOR_DEBUG, "Paste: \"{}\"", String::copy(data));
|
||||||
|
|
||||||
TemporaryChange change(m_automatic_indentation_enabled, false);
|
TemporaryChange change(m_automatic_indentation_enabled, false);
|
||||||
insert_at_cursor_or_replace_selection(paste_text);
|
insert_at_cursor_or_replace_selection(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditor::defer_reflow()
|
void TextEditor::defer_reflow()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue