diff options
-rw-r--r-- | src/dbus/qdbusconnection.cpp | 35 | ||||
-rw-r--r-- | src/dbus/qdbusconnection.h | 6 | ||||
-rw-r--r-- | src/dbus/qdbusconnection_p.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbusconnectionmanager_p.h | 3 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 2 | ||||
-rw-r--r-- | tests/auto/dbus/qdbusinterface/myobject.h | 16 |
6 files changed, 17 insertions, 47 deletions
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 1a56f53a63..4f58d640ff 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -58,18 +58,6 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager) -QDBusConnectionPrivate *QDBusConnectionManager::sender() const -{ - QMutexLocker locker(&senderMutex); - return connection(senderName); -} - -void QDBusConnectionManager::setSender(const QDBusConnectionPrivate *s) -{ - QMutexLocker locker(&senderMutex); - senderName = (s ? s->name : QString()); -} - QDBusConnectionPrivate *QDBusConnectionManager::connection(const QString &name) const { return connectionHash.value(name, 0); @@ -1096,29 +1084,20 @@ QDBusConnection QDBusConnection::systemBus() return *_q_systemBus(); } +#if QT_DEPRECATED_SINCE(5,5) /*! - \nonreentrant + \deprecated - Returns the connection that sent the signal, if called in a slot activated - by QDBus; otherwise it returns 0. + Always returns a disconnected, invalid QDBusConnection object. For the old + functionality of determining the sender connection, please use \ref QDBusContext. - \note Please avoid this function. This function is not thread-safe, so if - there's any other thread delivering a D-Bus call, this function may return - the wrong connection. In new code, please use QDBusContext::connection() - (see that class for a description on how to use it). + \sa QDBusContext */ QDBusConnection QDBusConnection::sender() { - return QDBusConnection(_q_manager()->sender()); -} - -/*! - \internal -*/ -void QDBusConnectionPrivate::setSender(const QDBusConnectionPrivate *s) -{ - _q_manager()->setSender(s); + return QDBusConnection(QString()); } +#endif /*! \internal diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 59f6429d4f..76657e0b5b 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtDBus module of the Qt Toolkit. @@ -184,7 +185,10 @@ public: static QDBusConnection sessionBus(); static QDBusConnection systemBus(); - static QDBusConnection sender(); +#if QT_DEPRECATED_SINCE(5,5) + static QT_DEPRECATED_X("This function no longer works, use QDBusContext instead") + QDBusConnection sender(); +#endif protected: explicit QDBusConnection(QDBusConnectionPrivate *dd); diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index dc83ee9af5..85c8719fd1 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -331,8 +331,6 @@ public: static QDBusConnectionPrivate *d(const QDBusConnection& q) { return q.d; } static QDBusConnection q(QDBusConnectionPrivate *connection) { return QDBusConnection(connection); } - static void setSender(const QDBusConnectionPrivate *s); - friend class QDBusActivateObjectEvent; friend class QDBusCallDeliveryEvent; }; diff --git a/src/dbus/qdbusconnectionmanager_p.h b/src/dbus/qdbusconnectionmanager_p.h index d2c8282f6c..6650685180 100644 --- a/src/dbus/qdbusconnectionmanager_p.h +++ b/src/dbus/qdbusconnectionmanager_p.h @@ -63,9 +63,6 @@ public: void removeConnection(const QString &name); void setConnection(const QString &name, QDBusConnectionPrivate *c); - QDBusConnectionPrivate *sender() const; - void setSender(const QDBusConnectionPrivate *s); - mutable QMutex mutex; private: QHash<QString, QDBusConnectionPrivate *> connectionHash; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index e4ad5562f0..c88194b918 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -985,12 +985,10 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q // FIXME: save the old sender! QDBusContextPrivate context(QDBusConnection(this), msg); QDBusContextPrivate *old = QDBusContextPrivate::set(object, &context); - QDBusConnectionPrivate::setSender(this); QPointer<QObject> ptr = object; fail = object->qt_metacall(QMetaObject::InvokeMetaMethod, slotIdx, params.data()) >= 0; - QDBusConnectionPrivate::setSender(0); // the object might be deleted in the slot if (!ptr.isNull()) QDBusContextPrivate::set(object, old); diff --git a/tests/auto/dbus/qdbusinterface/myobject.h b/tests/auto/dbus/qdbusinterface/myobject.h index 9b337b2a28..cb350d043c 100644 --- a/tests/auto/dbus/qdbusinterface/myobject.h +++ b/tests/auto/dbus/qdbusinterface/myobject.h @@ -38,7 +38,7 @@ #include <QtDBus/QtDBus> -class MyObject: public QObject +class MyObject: public QObject, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.QtDBus.MyObject") @@ -123,15 +123,12 @@ public: Q_INVOKABLE void ping_invokable(QDBusMessage msg) { - QDBusConnection sender = QDBusConnection::sender(); - if (!sender.isConnected()) - exit(1); - + Q_ASSERT(QDBusContext::calledFromDBus()); ++callCount; callArgs = msg.arguments(); msg.setDelayedReply(true); - if (!sender.send(msg.createReply(callArgs))) + if (!QDBusContext::connection().send(msg.createReply(callArgs))) exit(1); } @@ -139,15 +136,12 @@ public slots: void ping(QDBusMessage msg) { - QDBusConnection sender = QDBusConnection::sender(); - if (!sender.isConnected()) - exit(1); - + Q_ASSERT(QDBusContext::calledFromDBus()); ++callCount; callArgs = msg.arguments(); msg.setDelayedReply(true); - if (!sender.send(msg.createReply(callArgs))) + if (!QDBusContext::connection().send(msg.createReply(callArgs))) exit(1); } }; |