QWaylandClipboard: fix crash when setting the same QMimeData* more than once

This also fixes a crash in qtbase's tst_qclipboard, one of the tests
there expects that calling setMimeData() on the same QMimeData* won't
cause a crash. This matches how QXcbClipboard behaves.

Amends 5925c3110df258e78e6086e3bf526b8f6f779039.

Pick-to: 6.8 6.7
Change-Id: I057315aa1466857b7cd7181eba92068e92154ef5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Ahmad Samir 2024-07-21 18:40:24 +03:00
parent 279406aa20
commit d30ce747c2

View File

@ -67,6 +67,9 @@ void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
return;
}
if (data && m_clientClipboard[mode] == data) // Already set before?
return;
static const QString plain = QStringLiteral("text/plain");
static const QString utf8 = QStringLiteral("text/plain;charset=utf-8");