diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-06-14 10:05:21 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-06-30 19:15:30 +0000 |
commit | 593543675deb0387635e7eadc28ae6b88a60a4e7 (patch) | |
tree | 0cc3ca69e4099cf432bb69ae04cd5e5eeebbbfff /src/input/frontend/qmousehandler.cpp | |
parent | 09ccd2395b5efe9d7bcd0bd92388b8919e2df4b9 (diff) |
QMouseHandler: proper bookkeeping of QMouseDevice
Change-Id: Ib9fc09c038fed225efdd44e6c6286351f4c74ce2
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/frontend/qmousehandler.cpp')
-rw-r--r-- | src/input/frontend/qmousehandler.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/input/frontend/qmousehandler.cpp b/src/input/frontend/qmousehandler.cpp index c36c550ee..99e224142 100644 --- a/src/input/frontend/qmousehandler.cpp +++ b/src/input/frontend/qmousehandler.cpp @@ -244,7 +244,22 @@ void QMouseHandler::setSourceDevice(QMouseDevice *mouseDevice) { Q_D(QMouseHandler); if (d->m_mouseDevice != mouseDevice) { + + if (d->m_mouseDevice) + d->unregisterDestructionHelper(d->m_mouseDevice); + + // We need to add it as a child of the current node if it has been declared inline + // Or not previously added as a child of the current node so that + // 1) The backend gets notified about it's creation + // 2) When the current node is destroyed, it gets destroyed as well + if (mouseDevice && !mouseDevice->parent()) + mouseDevice->setParent(this); d->m_mouseDevice = mouseDevice; + + // Ensures proper bookkeeping + if (d->m_mouseDevice) + d->registerDestructionHelper(d->m_mouseDevice, &QMouseHandler::setSourceDevice, d->m_mouseDevice); + emit sourceDeviceChanged(mouseDevice); } } |