QtAndroidAccessibility: fix unneeded runtime initialization

Initializing QPointer with nullptr is currently still going through
the (T*) ctor, which is not constexpr, so is initialized at runtime.
This will change in Qt 6.7, but that doesn't help the older branches.

Use the default constructor, which is constexpr, and assert that no
runtime initialization happens by using Q_CONSTINIT.

Amends f9297565784e7eae87588417c8080cc1c9eede5f.

Not picking to 6.2, 5.15 because, while affected, they're in too
stable a mode for this, and they also lack Q_CONSTINIT.

Pick-to: 6.5
Change-Id: I41bb6f36d529effda008f166fd05a8896157edc9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit c0ba4ad49d9099e723518d9f4384e00bfb6ae1a7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-10-05 13:59:57 +02:00 committed by Qt Cherry-pick Bot
parent 546dae9285
commit c5db4a8bd1

View File

@ -48,7 +48,7 @@ namespace QtAndroidAccessibility
// Because of that almost every method here is split into two parts.
// The _helper part is executed in the context of m_accessibilityContext
// on the main thread. The other part is executed in Java thread.
static QPointer<QObject> m_accessibilityContext = nullptr;
Q_CONSTINIT static QPointer<QObject> m_accessibilityContext = {};
// This method is called from the Qt main thread, and normally a
// QGuiApplication instance will be used as a parent.