QEvent copy constructor: copy the type flags too
Failure to copy m_inputEvent and m_pointerEvent actually left them uninitialized, and resulted in random behavior in Qt Quick when Flickable clones a pointer event for later replay. Remove the comment about copying events being a "bad idea" in Qt 4, while we're at it. Copying became more common in Qt 5, and we probably won't be able to stop doing it now. Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
21d3916817
commit
9aba868571
@ -301,14 +301,11 @@ QEvent::QEvent(Type type)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
Attempts to copy the \a other event.
|
Copies the \a other event.
|
||||||
|
*/
|
||||||
Copying events is a bad idea, yet some Qt 4 code does it (notably,
|
|
||||||
QApplication and the state machine).
|
|
||||||
*/
|
|
||||||
QEvent::QEvent(const QEvent &other)
|
QEvent::QEvent(const QEvent &other)
|
||||||
: d(other.d), t(other.t), posted(other.posted), spont(other.spont),
|
: d(other.d), t(other.t), posted(other.posted), spont(other.spont),
|
||||||
m_accept(other.m_accept)
|
m_accept(other.m_accept), m_inputEvent(other.m_inputEvent), m_pointerEvent(other.m_pointerEvent)
|
||||||
{
|
{
|
||||||
Q_TRACE(QEvent_ctor, this, t);
|
Q_TRACE(QEvent_ctor, this, t);
|
||||||
// if QEventPrivate becomes available, make sure to implement a
|
// if QEventPrivate becomes available, make sure to implement a
|
||||||
|
@ -179,6 +179,15 @@ void tst_QMouseEvent::mouseEventBasic()
|
|||||||
me = QMouseEvent(QEvent::MouseButtonRelease, local, scene, screen, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
|
me = QMouseEvent(QEvent::MouseButtonRelease, local, scene, screen, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
|
||||||
QVERIFY(!me.isBeginEvent());
|
QVERIFY(!me.isBeginEvent());
|
||||||
QVERIFY(me.isEndEvent());
|
QVERIFY(me.isEndEvent());
|
||||||
|
// Try out the copy constructor
|
||||||
|
QMouseEvent copy(me);
|
||||||
|
QVERIFY(copy.isInputEvent());
|
||||||
|
QVERIFY(copy.isPointerEvent());
|
||||||
|
QVERIFY(!copy.isBeginEvent());
|
||||||
|
QVERIFY(copy.isEndEvent());
|
||||||
|
QCOMPARE(copy.position(), local);
|
||||||
|
QCOMPARE(copy.scenePosition(), scene);
|
||||||
|
QCOMPARE(copy.globalPosition(), screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMouseEvent::checkMousePressEvent_data()
|
void tst_QMouseEvent::checkMousePressEvent_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user