From d30ce747c2641e23c87aeca78541db3cdbdab1b9 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 21 Jul 2024 18:40:24 +0300 Subject: [PATCH] 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 --- src/plugins/platforms/wayland/qwaylandclipboard.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index df6cf5d2b0c..c00e4c2eafd 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -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");