diff options
Diffstat (limited to 'src/quicktestutils/qml/platformquirks_p.h')
-rw-r--r-- | src/quicktestutils/qml/platformquirks_p.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/quicktestutils/qml/platformquirks_p.h b/src/quicktestutils/qml/platformquirks_p.h index beaf664f5d..afcadeacee 100644 --- a/src/quicktestutils/qml/platformquirks_p.h +++ b/src/quicktestutils/qml/platformquirks_p.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef PLATFORMQUIRKS_P_H #define PLATFORMQUIRKS_P_H @@ -17,7 +17,7 @@ #include <private/qglobal_p.h> -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include <Carbon/Carbon.h> #endif @@ -29,14 +29,26 @@ struct PlatformQuirks { #if !QT_CONFIG(clipboard) return false; -#elif defined(Q_OS_OSX) +#elif defined(Q_OS_MACOS) PasteboardRef pasteboard; OSStatus status = PasteboardCreate(0, &pasteboard); if (status == noErr) CFRelease(pasteboard); return status == noErr; #else - return true; + if (QGuiApplication::platformName() != QLatin1StringView("xcb")) + return true; + + // On XCB a clipboard may be dysfunctional due to platform restrictions + QClipboard *clipBoard = QGuiApplication::clipboard(); + if (!clipBoard) + return false; + const QString &oldText = clipBoard->text(); + QScopeGuard guard([&](){ clipBoard->setText(oldText); }); + const QLatin1StringView prefix("Something to prefix "); + const QString newText = prefix + oldText; + clipBoard->setText(newText); + return QTest::qWaitFor([&](){ return clipBoard->text() == newText; }); #endif } }; |