diff options
Diffstat (limited to 'src/input/frontend/qabstractaxisinput.cpp')
-rw-r--r-- | src/input/frontend/qabstractaxisinput.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/input/frontend/qabstractaxisinput.cpp b/src/input/frontend/qabstractaxisinput.cpp index 77966eb1d..ff7c69c12 100644 --- a/src/input/frontend/qabstractaxisinput.cpp +++ b/src/input/frontend/qabstractaxisinput.cpp @@ -73,10 +73,21 @@ void QAbstractAxisInput::setSourceDevice(QAbstractPhysicalDevice *sourceDevice) Q_D(QAbstractAxisInput); if (d->m_sourceDevice != sourceDevice) { + if (d->m_sourceDevice) + d->unregisterDestructionHelper(d->m_sourceDevice); + + // 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 (sourceDevice && !sourceDevice->parent()) sourceDevice->setParent(this); d->m_sourceDevice = sourceDevice; + // Ensures proper bookkeeping + if (d->m_sourceDevice) + d->registerDestructionHelper(sourceDevice, &QAbstractAxisInput::setSourceDevice, d->m_sourceDevice); + emit sourceDeviceChanged(sourceDevice); } } |