QClipboard: Fix autotest fails
tst_qclipboard.cpp still has Q_WS_WIN which must be clear away. After clean up, auto test will fail under windows: When setMimeData() is called, dataChanged() signal will be emited twice. The solution for QTBUG-24184 has partially solved the problem, but it still there. Make sure emitChanged() only called by QPlatformClipboard will give our more control for this. Task-number: QTBUG-24484 Change-Id: I23566c6d3b32828b6865234c311af3635fe9e299 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
e76d72aec5
commit
63017136a1
@ -76,8 +76,6 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
|
||||
if (!clipboard->supportsMode(mode)) return;
|
||||
|
||||
clipboard->setMimeData(src,mode);
|
||||
|
||||
emitChanged(mode);
|
||||
}
|
||||
|
||||
bool QClipboard::supportsMode(Mode mode) const
|
||||
|
@ -96,6 +96,8 @@ void QPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
|
||||
//we know its clipboard
|
||||
Q_UNUSED(mode);
|
||||
q_clipboardData()->setSource(data);
|
||||
|
||||
emitChanged(mode);
|
||||
}
|
||||
|
||||
bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
|
||||
|
@ -287,8 +287,7 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w
|
||||
const bool owned = ownsClipboard();
|
||||
if (QWindowsContext::verboseOLE)
|
||||
qDebug("Clipboard changed owned %d", owned);
|
||||
if (!owned) // changed is emitted by QClipboard in that case.
|
||||
emitChanged(QClipboard::Clipboard);
|
||||
emitChanged(QClipboard::Clipboard);
|
||||
// clean up the clipboard object if we no longer own the clipboard
|
||||
if (!owned && m_data)
|
||||
releaseIData();
|
||||
|
@ -295,6 +295,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
|
||||
qWarning("QClipboard::setData: Cannot set X11 selection owner");
|
||||
}
|
||||
|
||||
emitChanged(mode);
|
||||
}
|
||||
|
||||
bool QXcbClipboard::supportsMode(QClipboard::Mode mode) const
|
||||
|
@ -223,6 +223,7 @@ void QXlibClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
|
||||
qWarning("QClipboard::setData: Cannot set X11 selection owner");
|
||||
}
|
||||
|
||||
emitChanged(mode);
|
||||
}
|
||||
|
||||
bool QXlibClipboard::supportsMode(QClipboard::Mode mode) const
|
||||
|
@ -291,19 +291,17 @@ void tst_QClipboard::setMimeData()
|
||||
QGuiApplication::clipboard()->clear(QClipboard::Selection); // used to crash on X11
|
||||
QGuiApplication::clipboard()->clear(QClipboard::FindBuffer);
|
||||
|
||||
#if defined(Q_WS_X11)
|
||||
QCOMPARE(spySelection.count(), 1);
|
||||
if (QGuiApplication::clipboard()->supportsSelection())
|
||||
QCOMPARE(spySelection.count(), 1);
|
||||
else
|
||||
QCOMPARE(spySelection.count(), 0);
|
||||
|
||||
if (QGuiApplication::clipboard()->supportsFindBuffer())
|
||||
QCOMPARE(spyFindBuffer.count(), 1);
|
||||
else
|
||||
QCOMPARE(spyFindBuffer.count(), 0);
|
||||
|
||||
QCOMPARE(spyData.count(), 1);
|
||||
QCOMPARE(spyFindBuffer.count(), 0);
|
||||
#elif defined(Q_OS_MAC)
|
||||
QCOMPARE(spySelection.count(), 0);
|
||||
QCOMPARE(spyData.count(), 1);
|
||||
QCOMPARE(spyFindBuffer.count(), 1);
|
||||
#elif defined(Q_WS_WIN)
|
||||
QCOMPARE(spySelection.count(), 0);
|
||||
QCOMPARE(spyData.count(), 1);
|
||||
QCOMPARE(spyFindBuffer.count(), 0);
|
||||
#endif
|
||||
|
||||
// an other crash test
|
||||
data = new QMimeData;
|
||||
@ -324,19 +322,17 @@ void tst_QClipboard::setMimeData()
|
||||
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11
|
||||
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer);
|
||||
|
||||
#if defined(Q_WS_X11)
|
||||
QCOMPARE(spySelection.count(), 1);
|
||||
if (QGuiApplication::clipboard()->supportsSelection())
|
||||
QCOMPARE(spySelection.count(), 1);
|
||||
else
|
||||
QCOMPARE(spySelection.count(), 0);
|
||||
|
||||
if (QGuiApplication::clipboard()->supportsFindBuffer())
|
||||
QCOMPARE(spyFindBuffer.count(), 1);
|
||||
else
|
||||
QCOMPARE(spyFindBuffer.count(), 0);
|
||||
|
||||
QCOMPARE(spyData.count(), 1);
|
||||
QCOMPARE(spyFindBuffer.count(), 0);
|
||||
#elif defined(Q_OS_MAC)
|
||||
QCOMPARE(spySelection.count(), 0);
|
||||
QCOMPARE(spyData.count(), 1);
|
||||
QCOMPARE(spyFindBuffer.count(), 1);
|
||||
#elif defined(Q_WS_WIN)
|
||||
QCOMPARE(spySelection.count(), 0);
|
||||
QCOMPARE(spyData.count(), 1);
|
||||
QCOMPARE(spyFindBuffer.count(), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QClipboard::clearBeforeSetText()
|
||||
|
Loading…
Reference in New Issue
Block a user