summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt/qwinrtclipboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrtclipboard.cpp')
-rw-r--r--src/plugins/platforms/winrt/qwinrtclipboard.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp
index 2811f1f018..0a38b3df34 100644
--- a/src/plugins/platforms/winrt/qwinrtclipboard.cpp
+++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp
@@ -59,6 +59,7 @@ typedef IEventHandler<IInspectable *> ContentChangedHandler;
QT_BEGIN_NAMESPACE
QWinRTClipboard::QWinRTClipboard()
+ : m_mimeData(Q_NULLPTR)
{
#ifndef Q_OS_WINPHONE
QEventDispatcherWinRT::runOnXamlThread([this]() {
@@ -103,9 +104,16 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode)
const wchar_t *textStr = result.GetRawBuffer(&size);
QString text = QString::fromWCharArray(textStr, size);
text.replace(QLatin1String("\r\n"), QLatin1String("\n"));
- m_mimeData.setText(text);
- return &m_mimeData;
+ if (m_mimeData) {
+ if (m_mimeData->text() == text)
+ return m_mimeData;
+ delete m_mimeData;
+ }
+ m_mimeData = new QMimeData();
+ m_mimeData->setText(text);
+
+ return m_mimeData;
#else // Q_OS_WINPHONE
return QPlatformClipboard::mimeData(mode);
#endif // Q_OS_WINPHONE
@@ -146,7 +154,13 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
return;
#ifndef Q_OS_WINPHONE
- const QString text = data->text();
+ const bool newData = !m_mimeData || m_mimeData != data;
+ if (newData) {
+ if (m_mimeData)
+ delete m_mimeData;
+ m_mimeData = data;
+ }
+ const QString text = data ? data->text() : QString();
HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, text]() {
HRESULT hr;
ComPtr<IDataPackage> package;
@@ -164,7 +178,6 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
return S_OK;
});
RETURN_VOID_IF_FAILED("Could not set clipboard text.");
- emitChanged(mode);
#else // Q_OS_WINPHONE
QPlatformClipboard::setMimeData(data, mode);
#endif // Q_OS_WINPHONE