fix accessibility on XCB when running as root
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Wed, 12 Apr 2023 23:24:34 +0000 (00:24 +0100)
committerLisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
Wed, 12 Apr 2023 23:24:34 +0000 (00:24 +0100)
Origin: https://codereview.qt-project.org/c/qt/qtbase/+/205196
Bug: https://bugs.debian.org/1033995
Last-Update: 2023-04-12

Accessibility actually works when running applications as root, but we
would never properly connect, since the enabledChanged signal would be
emitted from the constructor in this case. So after connecting the
signal, check the value by hand to make sure not to miss the
notification.

Only applications running as root would be affected, because all other
applications would go through the asynchronous pattern of getting the
bus address from dbus instead.

Gbp-Pq: Name a11y_root.diff

src/platformsupport/linuxaccessibility/bridge.cpp

index fdc8cd31982167d5001b4012b4168cb071e93168..438a20c31195685ee1ceaec60629daee993f428e 100644 (file)
@@ -65,6 +65,16 @@ QSpiAccessibleBridge::QSpiAccessibleBridge()
 {
     dbusConnection = new DBusConnection();
     connect(dbusConnection, SIGNAL(enabledChanged(bool)), this, SLOT(enabledChanged(bool)));
+    // Now that we have connected the signal, make sure we didn't miss a change,
+    // e.g. when running as root or when AT_SPI_BUS_ADDRESS is set by hand.
+    // But do that only on next loop, once dbus is really settled.
+    QMetaObject::invokeMethod(
+        this,
+        [this] {
+            if (dbusConnection->isEnabled())
+                enabledChanged(true);
+        },
+        Qt::QueuedConnection);
 }
 
 void QSpiAccessibleBridge::enabledChanged(bool enabled)