Fix crash on pasting too soon after copying from XWayland

There seems to be an interval between when you copy something from a Wayland
client and when you attempt to paste it into an X client where m_chunks.first().first
is empty, and trying to access its .data() will cause an assertion. While we can't
really gracefully handle this situation, we can at least terminate the function early
and turn the paste operation into a noop instead of a crash.
This commit is contained in:
Jan Blackquill 2021-02-14 16:47:49 -05:00 committed by Vlad Zahorodnii
parent 04465e996c
commit c6b638267a

View file

@ -111,6 +111,7 @@ void TransferWltoX::startTransferFromSource()
int TransferWltoX::flushSourceData()
{
Q_ASSERT(!m_chunks.isEmpty());
xcb_connection_t *xcbConn = kwinApp()->x11Connection();
xcb_change_property(xcbConn,
@ -258,7 +259,7 @@ void TransferWltoX::handlePropertyDelete()
xcb_flush(xcbConn);
m_flushPropertyOnDelete = false;
endTransfer();
} else {
} else if (!m_chunks.isEmpty()) {
flushSourceData();
}
}