From 3203ac3f4e245427902bd912cb0c644c7e870657 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Mar 2015 14:24:21 +0200 Subject: Use QDebugStateSaver to restore space setting in stream operators. Returning dbg.space() breaks formatting on streams that already have nospace() set. Change-Id: I55e38b018679a67eb40be6b4664505483a3a7d8e Reviewed-by: David Faure --- src/dbus/qdbusintegrator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/dbus/qdbusintegrator.cpp') diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 74d6a11dee..6edf08ebbe 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -91,18 +91,20 @@ static inline QString dbusInterfaceString() static inline QDebug operator<<(QDebug dbg, const QThread *th) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QThread(ptr=" << (const void*)th; if (th && !th->objectName().isEmpty()) dbg.nospace() << ", name=" << th->objectName(); else if (th) dbg.nospace() << ", name=" << th->metaObject()->className(); dbg.nospace() << ')'; - return dbg.space(); + return dbg; } #if QDBUS_THREAD_DEBUG static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QDBusConnection(" << "ptr=" << (const void*)conn << ", name=" << conn->name @@ -113,7 +115,7 @@ static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn) else dbg.nospace() << conn->thread(); dbg.nospace() << ')'; - return dbg.space(); + return dbg; } void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *conn) -- cgit v1.2.3 From 26edd5a3b127c09ade9e75c45e5271113da81064 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 29 Dec 2014 20:36:17 -0200 Subject: Use QStringLiteral where applicable in QtDBus Move to qdbusutil_p.h the string constants that are used often and in multiple places; use QStringLiteral in qdbusintegrator.cpp for the strings that are used often. Change-Id: I8e1325b9ba015bda91bf01c42175d8032ea32f62 Reviewed-by: Alex Blasche --- src/dbus/qdbusintegrator.cpp | 49 +++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) (limited to 'src/dbus/qdbusintegrator.cpp') diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 6edf08ebbe..9eac1ed933 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -72,23 +72,6 @@ static dbus_int32_t server_slot = -1; static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1); #define qDBusDebug if (::isDebugging == 0); else qDebug -static inline QString orgFreedesktopDBusString() -{ - return QStringLiteral(DBUS_SERVICE_DBUS); -} - -static inline QString dbusServiceString() -{ - return orgFreedesktopDBusString(); -} - -static inline QString dbusInterfaceString() -{ - // it's the same string, but just be sure - Q_ASSERT(orgFreedesktopDBusString() == QLatin1String(DBUS_INTERFACE_DBUS)); - return orgFreedesktopDBusString(); -} - static inline QDebug operator<<(QDebug dbg, const QThread *th) { QDebugStateSaver saver(dbg); @@ -1041,7 +1024,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) // prepopulate watchedServices: // we know that the owner of org.freedesktop.DBus is itself - watchedServices.insert(dbusServiceString(), WatchedServiceData(dbusServiceString(), 1)); + watchedServices.insert(QDBusUtil::dbusService(), WatchedServiceData(QDBusUtil::dbusService(), 1)); // prepopulate matchRefCounts: // we know that org.freedesktop.DBus will never change owners @@ -1377,7 +1360,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, // object may be null const QString interface = msg.interface(); - if (interface.isEmpty() || interface == QLatin1String(DBUS_INTERFACE_INTROSPECTABLE)) { + if (interface.isEmpty() || interface == QDBusUtil::dbusInterfaceIntrospectable()) { if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg; QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path())); @@ -1392,7 +1375,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, } if (node.obj && (interface.isEmpty() || - interface == QLatin1String(DBUS_INTERFACE_PROPERTIES))) { + interface == QDBusUtil::dbusInterfaceProperties())) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters properties" << msg.d_ptr->msg; if (msg.member() == QLatin1String("Get") && msg.signature() == QLatin1String("ss")) { QDBusMessage reply = qDBusPropertyGet(node, msg); @@ -1779,7 +1762,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError // we don't use connectSignal here because we don't need the rules to be sent to the bus // the bus will always send us these two signals SignalHook hook; - hook.service = dbusServiceString(); + hook.service = QDBusUtil::dbusService(); hook.path.clear(); // no matching hook.obj = this; hook.params << QMetaType::Void << QVariant::String; // both functions take a QString as parameter and return void @@ -2205,10 +2188,10 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM return pcall; } else { // we're probably disconnected at this point - lastError = error = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to server")); + lastError = error = QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } } else { - lastError = error = QDBusError(QDBusError::NoMemory, QLatin1String("Out of memory")); + lastError = error = QDBusError(QDBusError::NoMemory, QStringLiteral("Out of memory")); } q_dbus_message_unref(msg); @@ -2279,8 +2262,8 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; if (++data.refcount == 1) { // we need to watch for this service changing - connectSignal(dbusServiceString(), QString(), dbusInterfaceString(), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + connectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), + QStringLiteral("NameOwnerChanged"), QStringList() << hook.service, QString(), this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString))); data.owner = getNameOwnerNoCache(hook.service); qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:" @@ -2359,8 +2342,8 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) if (sit != watchedServices.end()) { if (--sit.value().refcount == 0) { watchedServices.erase(sit); - disconnectSignal(dbusServiceString(), QString(), dbusInterfaceString(), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + disconnectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), + QStringLiteral("NameOwnerChanged"), QStringList() << hook.service, QString(), this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString))); } } @@ -2501,9 +2484,9 @@ QString QDBusConnectionPrivate::getNameOwner(const QString& serviceName) QString QDBusConnectionPrivate::getNameOwnerNoCache(const QString &serviceName) { - QDBusMessage msg = QDBusMessage::createMethodCall(dbusServiceString(), - QLatin1String(DBUS_PATH_DBUS), dbusInterfaceString(), - QLatin1String("GetNameOwner")); + QDBusMessage msg = QDBusMessage::createMethodCall(QDBusUtil::dbusService(), + QDBusUtil::dbusPath(), QDBusUtil::dbusInterface(), + QStringLiteral("GetNameOwner")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << serviceName; QDBusMessage reply = sendWithReply(msg, QDBus::Block); @@ -2526,8 +2509,8 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa // introspect the target object QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_INTROSPECTABLE), - QLatin1String("Introspect")); + QDBusUtil::dbusInterfaceIntrospectable(), + QStringLiteral("Introspect")); QDBusMessagePrivate::setParametersValidated(msg, true); QDBusMessage reply = sendWithReply(msg, QDBus::Block); @@ -2586,7 +2569,7 @@ bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceN { if (!serviceName.isEmpty() && serviceName == baseService) return true; - if (serviceName == dbusServiceString()) + if (serviceName == QDBusUtil::dbusService()) return false; QDBusReadLocker locker(UnregisterServiceAction, this); -- cgit v1.2.3