diff options
author | Raphael Kubo da Costa <rakuco@FreeBSD.org> | 2012-01-17 01:10:46 -0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-17 17:41:14 +0100 |
commit | 3de1e6f26b692a8261b40decc2d81286b01c1461 (patch) | |
tree | 3be14a17fa171cb8bacd4844dabd27e47590af19 /src/dbus | |
parent | 314da0ae017d664b3f05e6474f17c6610fb0257f (diff) | |
download | qtbase-3de1e6f26b692a8261b40decc2d81286b01c1461.tar.gz |
Remove the default address parameter from QDBusServer's constructor.
Commit 5be6cf0a6e306ed3a51ed5ba89317b1317544eea introduced an implicit
cast from const char* to QString in QDBusServer's constructor, which
breaks the compilation of applications which use QtDBus when
QT_NO_CAST_FROM_ASCII is defined and clang is used.
Fix it by splitting the current constructor with the broken default
argument into one which takes a non-default QString and one which only
takes a QObject* parent and calls the other with the current default
argument.
It would have been better not to have mostly duplicate code in both
constructors, but QDBusConnectionPrivate is also used in other places.
Task-number: QTBUG-23398
Change-Id: Ia001d63878e7ff720c6630a3372adc571124448d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusserver.cpp | 25 | ||||
-rw-r--r-- | src/dbus/qdbusserver.h | 3 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index 078f56aa61..6d97893235 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -82,6 +82,31 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent) } /*! + Constructs a QDBusServer with the given \a parent. The server will listen + for connections in \c {/tmp}. +*/ +QDBusServer::QDBusServer(QObject *parent) + : QObject(parent) +{ + const QString address = QLatin1String("unix:tmpdir=/tmp"); + + if (!qdbus_loadLibDBus()) { + d = 0; + return; + } + d = new QDBusConnectionPrivate(this); + + QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); + QDBusConnectionManager::instance()->setConnection(QLatin1String("QDBusServer-") + QString::number(reinterpret_cast<qulonglong>(d)), d); + + QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)), + this, SIGNAL(newConnection(QDBusConnection))); + + QDBusErrorInternal error; + d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); +} + +/*! Destructs a QDBusServer */ QDBusServer::~QDBusServer() diff --git a/src/dbus/qdbusserver.h b/src/dbus/qdbusserver.h index 900c652d37..b3ccebc505 100644 --- a/src/dbus/qdbusserver.h +++ b/src/dbus/qdbusserver.h @@ -61,7 +61,8 @@ class Q_DBUS_EXPORT QDBusServer: public QObject { Q_OBJECT public: - QDBusServer(const QString &address = "unix:tmpdir=/tmp", QObject *parent = 0); + explicit QDBusServer(const QString &address, QObject *parent = 0); + explicit QDBusServer(QObject *parent = 0); virtual ~QDBusServer(); bool isConnected() const; |