mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
WindowServer: Properly handle OOM on drag-and-drop metadata copy
This commit is contained in:
parent
efbf6b7e5f
commit
d3a6512643
1 changed files with 6 additions and 1 deletions
|
@ -1121,7 +1121,12 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event)
|
||||||
m_dnd_client->async_drag_accepted();
|
m_dnd_client->async_drag_accepted();
|
||||||
if (window->client()) {
|
if (window->client()) {
|
||||||
auto translated_event = event.translated(-window->position());
|
auto translated_event = event.translated(-window->position());
|
||||||
window->client()->async_drag_dropped(window->window_id(), translated_event.position(), m_dnd_text, m_dnd_mime_data->all_data());
|
auto copied_mime_data_or_error = m_dnd_mime_data->all_data().clone();
|
||||||
|
// If the mime data is so large that it causes memory troubles, we should silently drop the drag'n'drop request entirely.
|
||||||
|
if (copied_mime_data_or_error.is_error())
|
||||||
|
dbgln("Drag and drop mimetype data nearly caused OOM and was dropped: {}", copied_mime_data_or_error.release_error());
|
||||||
|
else
|
||||||
|
window->client()->async_drag_dropped(window->window_id(), translated_event.position(), m_dnd_text, copied_mime_data_or_error.release_value());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_dnd_client->async_drag_cancelled();
|
m_dnd_client->async_drag_cancelled();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue