Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.6.3
-
None
-
Windows 10
Description
If QAxControl is used to load an ActiveX control, and this object is then put on the D-Bus with QDBusConnection::registerObject() then slots and signals are all visible via the D-Bus interface, and you can call the object's slots via the D-Bus as you would expect, but QAxControl never emits any of the signals defined by the underlying ActiveX control.
If you then connect one of these signals to a regular slot, they are emitted, both on the normal slot, and via the D-Bus.
Pseudocode:
auto ax = new QAxObject(this); if (!ax->setControl("someaxcontrol")) { delete ax; return false; } QDBusConnection::sessionBus().registerObject("/MyAXObject, "org.qtproject.Qt.QAxObject", ax, QDBusConnection::ExportAllContents); // at this point, if someaxcontrol dispatches an event, ax will not emit a Qt signal // now, connect any other slot to the signal QObject::connect(ax, SIGNAL(somesignal()), this, SLOT(dummy())); // and now, if somecontrol dispatches the somesignal event, it will be // emitted as Qt signal, so dummy() will be called, and the corresponding // signal will be emitted on the D-Bus as well
The problem seems to be a combination of factors:
- After QDBusConnection::registerObject tries to connect the object's signals, QObject::receivers() still returns 0. Apparently it does not count the receivers connected in this manner.
- In QAxEventSink::Invoke, signalHasReceivers is called, which again calls QObject::receivers(). As this returns 0, QAxEventSink decides that no on is listening for the signal, and skips emitting it.
I'm unsure if the root cause is that QObject::receivers() doesn't count connections made through QDBusConnection::registerObject, or if QAxEventSink should be smarter about how it tests if anything is connected to the signal.
If the object being registered on the D-Bus is a regular QObject with statically defined slots, it works correctly. The signals are then emitted through QMetaObject::activate, which uses different logic to determine if anyone is connected to the signal, which correctly count the QDBusConnection as being connected.