QInputDevice: Parent default keyboard to core app singleton

With this we can avoid leaking the QInputDevice which is created when
the platform plugin does not provide any. The onwership is solved in a
similar way as in the plugins, except that here we have no parent which
really fits, so we use QCoreApplication::instance instead.

Pick-to: 6.0
Change-Id: I77a212fb592ba3d5a42b2ecd486763e3b4d3410e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Fabian Kosmale 2020-12-04 12:52:06 +01:00
parent 94dfb18865
commit bc093cd294

View File

@ -297,7 +297,7 @@ const QInputDevice *QInputDevice::primaryKeyboard(const QString& seatName)
qCDebug(lcQpaInputDevices) << "no keyboards registered for seat" << seatName
<< "The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default one for now.";
ret = new QInputDevice(QLatin1String("core keyboard"), 0, DeviceType::Keyboard, seatName);
ret = new QInputDevice(QLatin1String("core keyboard"), 0, DeviceType::Keyboard, seatName, QCoreApplication::instance());
QInputDevicePrivate::registerDevice(ret);
return ret;
}