mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-06 09:15:23 +08:00
6.5.3 clean
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\page dbus-changes-qt6.html
|
||||
\title Changes to Qt D-Bus
|
||||
\ingroup changes-qt-5-to-6
|
||||
\brief Migrate Qt DBus to Qt 6.
|
||||
\brief Minimal porting effort to be able to switch to Qt 6.
|
||||
|
||||
Qt 6 is a result of the conscious effort to make the framework more
|
||||
efficient and easy to use.
|
||||
|
@ -260,8 +260,8 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
|
||||
// QObject signal (destroyed(QObject *)) -- ignore
|
||||
return;
|
||||
|
||||
const QMetaObject *senderMetaObject = senderObj->metaObject();
|
||||
QMetaMethod mm = senderMetaObject->method(lastSignalIdx);
|
||||
QMetaMethod mm = senderObj->metaObject()->method(lastSignalIdx);
|
||||
const QMetaObject *senderMetaObject = mm.enclosingMetaObject();
|
||||
|
||||
QObject *realObject = senderObj;
|
||||
if (qobject_cast<QDBusAbstractAdaptor *>(senderObj))
|
||||
|
@ -1175,7 +1175,6 @@ void QDBusConnectionPrivate::timerEvent(QTimerEvent *e)
|
||||
void QDBusConnectionPrivate::doDispatch()
|
||||
{
|
||||
if (mode == ClientMode || mode == PeerMode) {
|
||||
while (q_dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) ;
|
||||
if (dispatchEnabled && !pendingMessages.isEmpty()) {
|
||||
// dispatch previously queued messages
|
||||
PendingMessageList::Iterator it = pendingMessages.begin();
|
||||
@ -1186,6 +1185,7 @@ void QDBusConnectionPrivate::doDispatch()
|
||||
}
|
||||
pendingMessages.clear();
|
||||
}
|
||||
while (q_dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,14 +53,14 @@ void QDBusMetaTypeId::init()
|
||||
// reentrancy is not a problem since everything else is locked on their own
|
||||
// set the guard variable at the end
|
||||
if (!initialized.loadRelaxed()) {
|
||||
// register our types with Qt Core (calling qMetaTypeId<T>() does this implicitly)
|
||||
(void)message();
|
||||
(void)argument();
|
||||
(void)variant();
|
||||
(void)objectpath();
|
||||
(void)signature();
|
||||
(void)error();
|
||||
(void)unixfd();
|
||||
// register our types with Qt Core
|
||||
message().registerType();
|
||||
argument().registerType();
|
||||
variant().registerType();
|
||||
objectpath().registerType();
|
||||
signature().registerType();
|
||||
error().registerType();
|
||||
unixfd().registerType();
|
||||
|
||||
#ifndef QDBUS_NO_SPECIALTYPES
|
||||
// and register Qt Core's with us
|
||||
@ -78,7 +78,6 @@ void QDBusMetaTypeId::init()
|
||||
qDBusRegisterMetaType<QVariantList>();
|
||||
qDBusRegisterMetaType<QVariantMap>();
|
||||
qDBusRegisterMetaType<QVariantHash>();
|
||||
qDBusRegisterMetaType<QDBusObjectPath>();
|
||||
|
||||
qDBusRegisterMetaType<QList<bool> >();
|
||||
qDBusRegisterMetaType<QList<short> >();
|
||||
@ -88,6 +87,9 @@ void QDBusMetaTypeId::init()
|
||||
qDBusRegisterMetaType<QList<qlonglong> >();
|
||||
qDBusRegisterMetaType<QList<qulonglong> >();
|
||||
qDBusRegisterMetaType<QList<double> >();
|
||||
|
||||
// plus lists of our own types
|
||||
qDBusRegisterMetaType<QList<QDBusVariant> >();
|
||||
qDBusRegisterMetaType<QList<QDBusObjectPath> >();
|
||||
qDBusRegisterMetaType<QList<QDBusSignature> >();
|
||||
qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >();
|
||||
|
@ -39,6 +39,8 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent)
|
||||
return;
|
||||
|
||||
emit instance->serverRequested(address, this);
|
||||
Q_ASSERT(d != nullptr);
|
||||
|
||||
QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)),
|
||||
this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection);
|
||||
}
|
||||
@ -66,6 +68,8 @@ QDBusServer::QDBusServer(QObject *parent)
|
||||
return;
|
||||
|
||||
emit instance->serverRequested(address, this);
|
||||
Q_ASSERT(d != nullptr);
|
||||
|
||||
QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)),
|
||||
this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection);
|
||||
}
|
||||
@ -75,17 +79,20 @@ QDBusServer::QDBusServer(QObject *parent)
|
||||
*/
|
||||
QDBusServer::~QDBusServer()
|
||||
{
|
||||
QMutex *managerMutex = nullptr;
|
||||
if (QDBusConnectionManager::instance())
|
||||
managerMutex = &QDBusConnectionManager::instance()->mutex;
|
||||
QMutexLocker locker(managerMutex);
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
auto manager = QDBusConnectionManager::instance();
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
QMutexLocker locker(&manager->mutex);
|
||||
QWriteLocker writeLocker(&d->lock);
|
||||
if (QDBusConnectionManager::instance()) {
|
||||
for (const QString &name : std::as_const(d->serverConnectionNames))
|
||||
QDBusConnectionManager::instance()->removeConnection(name);
|
||||
d->serverConnectionNames.clear();
|
||||
locker.unlock();
|
||||
}
|
||||
for (const QString &name : std::as_const(d->serverConnectionNames))
|
||||
manager->removeConnection(name);
|
||||
d->serverConnectionNames.clear();
|
||||
locker.unlock();
|
||||
|
||||
d->serverObject = nullptr;
|
||||
d->ref.storeRelaxed(0);
|
||||
d->deleteLater();
|
||||
@ -138,6 +145,9 @@ QString QDBusServer::address() const
|
||||
*/
|
||||
void QDBusServer::setAnonymousAuthenticationAllowed(bool value)
|
||||
{
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
d->anonymousAuthenticationAllowed = value;
|
||||
}
|
||||
|
||||
@ -150,6 +160,9 @@ void QDBusServer::setAnonymousAuthenticationAllowed(bool value)
|
||||
*/
|
||||
bool QDBusServer::isAnonymousAuthenticationAllowed() const
|
||||
{
|
||||
if (!d)
|
||||
return false;
|
||||
|
||||
return d->anonymousAuthenticationAllowed;
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,11 @@ public:
|
||||
&QDBusServiceWatcherPrivate::setWatchModeForwardToQ)
|
||||
|
||||
void _q_serviceOwnerChanged(const QString &, const QString &, const QString &);
|
||||
void setConnection(const QStringList &services, const QDBusConnection &c, QDBusServiceWatcher::WatchMode watchMode);
|
||||
void setConnection(const QStringList &newServices, const QDBusConnection &newConnection,
|
||||
QDBusServiceWatcher::WatchMode newMode);
|
||||
|
||||
void addService(const QString &service);
|
||||
void removeService(const QString &service);
|
||||
void addService(const QString &service, QDBusServiceWatcher::WatchMode mode);
|
||||
void removeService(const QString &service, QDBusServiceWatcher::WatchMode mode);
|
||||
};
|
||||
|
||||
void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner)
|
||||
@ -56,39 +57,43 @@ void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service,
|
||||
emit q->serviceUnregistered(service);
|
||||
}
|
||||
|
||||
void QDBusServiceWatcherPrivate::setConnection(const QStringList &services,
|
||||
const QDBusConnection &c,
|
||||
QDBusServiceWatcher::WatchMode wm)
|
||||
void QDBusServiceWatcherPrivate::setConnection(const QStringList &newServices,
|
||||
const QDBusConnection &newConnection,
|
||||
QDBusServiceWatcher::WatchMode newMode)
|
||||
{
|
||||
const QStringList oldServices = watchedServicesData.valueBypassingBindings();
|
||||
const QDBusServiceWatcher::WatchMode oldMode = watchMode.valueBypassingBindings();
|
||||
if (connection.isConnected()) {
|
||||
// remove older rules
|
||||
for (const QString &s : std::as_const(watchedServicesData.value()))
|
||||
removeService(s);
|
||||
for (const QString &s : oldServices)
|
||||
removeService(s, oldMode);
|
||||
}
|
||||
|
||||
connection = c;
|
||||
watchMode.setValueBypassingBindings(wm); // caller has to call notify()
|
||||
watchedServicesData.setValueBypassingBindings(services); // caller has to call notify()
|
||||
connection = newConnection;
|
||||
watchMode.setValueBypassingBindings(newMode); // caller has to call notify()
|
||||
watchedServicesData.setValueBypassingBindings(newServices); // caller has to call notify()
|
||||
|
||||
if (connection.isConnected()) {
|
||||
// add new rules
|
||||
for (const QString &s : std::as_const(watchedServicesData.value()))
|
||||
addService(s);
|
||||
for (const QString &s : newServices)
|
||||
addService(s, newMode);
|
||||
}
|
||||
}
|
||||
|
||||
void QDBusServiceWatcherPrivate::addService(const QString &service)
|
||||
void QDBusServiceWatcherPrivate::addService(const QString &service,
|
||||
QDBusServiceWatcher::WatchMode mode)
|
||||
{
|
||||
QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection);
|
||||
if (d && d->shouldWatchService(service))
|
||||
d->watchService(service, watchMode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
|
||||
d->watchService(service, mode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
|
||||
}
|
||||
|
||||
void QDBusServiceWatcherPrivate::removeService(const QString &service)
|
||||
void QDBusServiceWatcherPrivate::removeService(const QString &service,
|
||||
QDBusServiceWatcher::WatchMode mode)
|
||||
{
|
||||
QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection);
|
||||
if (d && d->shouldWatchService(service))
|
||||
d->unwatchService(service, watchMode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
|
||||
d->unwatchService(service, mode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -260,8 +265,9 @@ void QDBusServiceWatcher::setWatchedServices(const QStringList &services)
|
||||
{
|
||||
Q_D(QDBusServiceWatcher);
|
||||
d->watchedServicesData.removeBindingUnlessInWrapper();
|
||||
if (services == d->watchedServicesData)
|
||||
if (services == d->watchedServicesData.valueBypassingBindings())
|
||||
return;
|
||||
// trigger watchMode re-evaluation, but only once for the setter
|
||||
d->setConnection(services, d->connection, d->watchMode);
|
||||
d->watchedServicesData.notify();
|
||||
}
|
||||
@ -283,13 +289,14 @@ void QDBusServiceWatcher::addWatchedService(const QString &newService)
|
||||
{
|
||||
Q_D(QDBusServiceWatcher);
|
||||
d->watchedServicesData.removeBindingUnlessInWrapper();
|
||||
if (d->watchedServicesData.value().contains(newService))
|
||||
auto services = d->watchedServicesData.valueBypassingBindings();
|
||||
if (services.contains(newService))
|
||||
return;
|
||||
d->addService(newService);
|
||||
// re-evaluate watch mode
|
||||
d->addService(newService, d->watchMode);
|
||||
|
||||
auto templist = d->watchedServicesData.valueBypassingBindings();
|
||||
templist << newService;
|
||||
d->watchedServicesData.setValueBypassingBindings(templist);
|
||||
services << newService;
|
||||
d->watchedServicesData.setValueBypassingBindings(services);
|
||||
|
||||
d->watchedServicesData.notify();
|
||||
}
|
||||
@ -308,17 +315,16 @@ bool QDBusServiceWatcher::removeWatchedService(const QString &service)
|
||||
{
|
||||
Q_D(QDBusServiceWatcher);
|
||||
d->watchedServicesData.removeBindingUnlessInWrapper();
|
||||
d->removeService(service);
|
||||
auto tempList = d->watchedServicesData.value();
|
||||
bool result = tempList.removeOne(service);
|
||||
if (result) {
|
||||
d->watchedServicesData.setValueBypassingBindings(tempList);
|
||||
d->watchedServicesData.notify();
|
||||
return true;
|
||||
} else {
|
||||
// nothing changed
|
||||
return false;
|
||||
}
|
||||
auto tempList = d->watchedServicesData.valueBypassingBindings();
|
||||
const bool result = tempList.removeOne(service);
|
||||
if (!result)
|
||||
return false; // nothing changed
|
||||
|
||||
// re-evaluate watch mode
|
||||
d->removeService(service, d->watchMode);
|
||||
d->watchedServicesData.setValueBypassingBindings(tempList);
|
||||
d->watchedServicesData.notify();
|
||||
return true;
|
||||
}
|
||||
|
||||
QDBusServiceWatcher::WatchMode QDBusServiceWatcher::watchMode() const
|
||||
@ -335,8 +341,9 @@ void QDBusServiceWatcher::setWatchMode(WatchMode mode)
|
||||
{
|
||||
Q_D(QDBusServiceWatcher);
|
||||
d->watchMode.removeBindingUnlessInWrapper();
|
||||
if (mode == d->watchMode.value())
|
||||
if (mode == d->watchMode.valueBypassingBindings())
|
||||
return;
|
||||
// trigger watchedServicesData re-evaluation, but only once for the setter
|
||||
d->setConnection(d->watchedServicesData, d->connection, mode);
|
||||
d->watchMode.notify();
|
||||
}
|
||||
|
Reference in New Issue
Block a user