summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusintegrator.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-11-22 14:46:58 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-12-06 12:13:20 +0100
commitece0c0a5e7e0b18beb58ccd868bde54c7be64f78 (patch)
treefa4a0fdbda040d24f1a2d07a320635c76980f431 /src/dbus/qdbusintegrator.cpp
parentb19220d17fa66de5ded41690ffff263ee2af5c63 (diff)
Tidy nullptr usage
Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r--src/dbus/qdbusintegrator.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index fb4f927a87..bca02be59e 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -127,7 +127,7 @@ void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *
"condition unknown")
<< "in connection" << conn;
}
-qdbusThreadDebugFunc qdbusThreadDebug = 0;
+qdbusThreadDebugFunc qdbusThreadDebug = nullptr;
#endif
typedef QVarLengthArray<QDBusSpyCallEvent::Hook, 4> QDBusSpyHookList;
@@ -400,7 +400,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
// match
node = it;
else
- node = 0;
+ node = nullptr;
start = end + 1;
}
@@ -413,7 +413,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
else
// there really is no object here
// we're just looking at an unused space in the QVector
- node = 0;
+ node = nullptr;
}
return node;
}
@@ -440,7 +440,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
const QObjectList children = obj->children();
// find a child with the proper name
- QObject *next = 0;
+ QObject *next = nullptr;
QObjectList::ConstIterator it = children.constBegin();
QObjectList::ConstIterator end = children.constEnd();
for ( ; it != end; ++it)
@@ -458,7 +458,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
}
// object not found
- return 0;
+ return nullptr;
}
static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode)
@@ -599,7 +599,7 @@ static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNo
haystack.children.end());
if (needle == haystack.obj) {
- haystack.obj = 0;
+ haystack.obj = nullptr;
haystack.flags = 0;
}
}
@@ -609,7 +609,7 @@ static void huntAndUnregister(const QVector<QStringRef> &pathComponents, int i,
{
if (pathComponents.count() == i) {
// found it
- node->obj = 0;
+ node->obj = nullptr;
node->flags = 0;
if (mode == QDBusConnection::UnregisterTree) {
@@ -660,7 +660,7 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
qDBusDebug() << QThread::currentThread() << "emitting signal at" << p;
DBusMessage *msg2 = q_dbus_message_copy(msg);
q_dbus_message_set_path(msg2, p);
- q_dbus_connection_send(connection, msg2, 0);
+ q_dbus_connection_send(connection, msg2, nullptr);
q_dbus_message_unref(msg2);
}
}
@@ -727,12 +727,12 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
++i;
// make sure that the output parameters have signatures too
- if (returnType != QMetaType::UnknownType && returnType != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == 0)
+ if (returnType != QMetaType::UnknownType && returnType != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == nullptr)
continue;
bool ok = true;
for (int j = i; ok && j < metaTypes.count(); ++j)
- if (QDBusMetaType::typeToSignature(metaTypes.at(i)) == 0)
+ if (QDBusMetaType::typeToSignature(metaTypes.at(i)) == nullptr)
ok = false;
if (!ok)
continue;
@@ -790,13 +790,13 @@ QDBusCallDeliveryEvent* QDBusConnectionPrivate::prepareReply(QDBusConnectionPriv
--n;
if (msg.arguments().count() < n)
- return 0; // too few arguments
+ return nullptr; // too few arguments
// check that types match
for (int i = 0; i < n; ++i)
if (metaTypes.at(i + 1) != msg.arguments().at(i).userType() &&
msg.arguments().at(i).userType() != qMetaTypeId<QDBusArgument>())
- return 0; // no match
+ return nullptr; // no match
// we can deliver
// prepare for the call
@@ -944,7 +944,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
params.append(const_cast<void *>(arg.constData()));
else if (arg.userType() == qMetaTypeId<QDBusArgument>()) {
// convert to what the function expects
- void *null = 0;
+ void *null = nullptr;
auxParameters.append(QVariant(id, null));
const QDBusArgument &in =
@@ -972,7 +972,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
// output arguments
const int numMetaTypes = metaTypes.count();
QVariantList outputArgs;
- void *null = 0;
+ void *null = nullptr;
if (metaTypes[0] != QMetaType::Void && metaTypes[0] != QMetaType::UnknownType) {
outputArgs.reserve(numMetaTypes - i + 1);
QVariant arg(metaTypes[0], null);
@@ -1026,8 +1026,8 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
extern bool qDBusInitThreads();
QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
- : QObject(p), ref(1), mode(InvalidMode), busService(0),
- connection(0),
+ : QObject(p), ref(1), mode(InvalidMode), busService(nullptr),
+ connection(nullptr),
rootNode(QString(QLatin1Char('/'))),
anonymousAuthenticationAllowed(false),
dispatchEnabled(true)
@@ -1087,11 +1087,11 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
}
if (connection)
q_dbus_connection_unref(connection);
- connection = 0;
+ connection = nullptr;
} else if (lastMode == ServerMode) {
if (server)
q_dbus_server_unref(server);
- server = 0;
+ server = nullptr;
}
}
@@ -1531,7 +1531,7 @@ void QDBusConnectionPrivate::handleObjectCall(const QDBusMessage &msg)
// user code, if necessary.
ObjectTreeNode result;
int usedLength;
- QThread *objThread = 0;
+ QThread *objThread = nullptr;
QSemaphore sem;
bool semWait;
@@ -1718,7 +1718,7 @@ void QDBusConnectionPrivate::setServer(QDBusServer *object, DBusServer *s, const
qDBusAddWatch,
qDBusRemoveWatch,
qDBusToggleWatch,
- this, 0);
+ this, nullptr);
//qDebug() << "watch_functions_set" << watch_functions_set;
Q_UNUSED(watch_functions_set);
@@ -1726,13 +1726,13 @@ void QDBusConnectionPrivate::setServer(QDBusServer *object, DBusServer *s, const
qDBusAddTimeout,
qDBusRemoveTimeout,
qDBusToggleTimeout,
- this, 0);
+ this, nullptr);
//qDebug() << "time_functions_set" << time_functions_set;
Q_UNUSED(time_functions_set);
- q_dbus_server_set_new_connection_function(server, qDBusNewConnection, this, 0);
+ q_dbus_server_set_new_connection_function(server, qDBusNewConnection, this, nullptr);
- dbus_bool_t data_set = q_dbus_server_set_data(server, server_slot, this, 0);
+ dbus_bool_t data_set = q_dbus_server_set_data(server, server_slot, this, nullptr);
//qDebug() << "data_set" << data_set;
Q_UNUSED(data_set);
}
@@ -1752,16 +1752,16 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal
qDBusAddWatch,
qDBusRemoveWatch,
qDBusToggleWatch,
- this, 0);
+ this, nullptr);
q_dbus_connection_set_timeout_functions(connection,
qDBusAddTimeout,
qDBusRemoveTimeout,
qDBusToggleTimeout,
- this, 0);
- q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, 0);
+ this, nullptr);
+ q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, nullptr);
q_dbus_connection_add_filter(connection,
qDBusSignalFilter,
- this, 0);
+ this, nullptr);
watchForDBusDisconnection();
@@ -1772,7 +1772,7 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti
{
QDBusConnection::ConnectionCapabilities result;
typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int);
- static can_send_type_t can_send_type = 0;
+ static can_send_type_t can_send_type = nullptr;
#if defined(QT_LINKED_LIBDBUS)
# if DBUS_VERSION-0 >= 0x010400
@@ -1809,11 +1809,11 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
q_dbus_connection_set_exit_on_disconnect(connection, false);
q_dbus_connection_set_watch_functions(connection, qDBusAddWatch, qDBusRemoveWatch,
- qDBusToggleWatch, this, 0);
+ qDBusToggleWatch, this, nullptr);
q_dbus_connection_set_timeout_functions(connection, qDBusAddTimeout, qDBusRemoveTimeout,
- qDBusToggleTimeout, this, 0);
- q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, 0);
- q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0);
+ qDBusToggleTimeout, this, nullptr);
+ q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, nullptr);
+ q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, nullptr);
// Initialize the hooks for the NameAcquired and NameLost signals
// we don't use connectSignal here because we don't need the rules to be sent to the bus
@@ -1904,7 +1904,7 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call)
if (call->pending) {
q_dbus_pending_call_unref(call->pending);
- call->pending = 0;
+ call->pending = nullptr;
}
// Are there any watchers?
@@ -2046,7 +2046,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
{
QDBusBlockingCallWatcher watcher(message);
- QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, 0, 0, 0, timeout);
+ QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, nullptr, nullptr, nullptr, timeout);
Q_ASSERT(pcall);
if (pcall->replyMessage.type() == QDBusMessage::InvalidMessage) {
@@ -2161,7 +2161,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void *message, int timeout)
{
QDBusError error;
- DBusPendingCall *pending = 0;
+ DBusPendingCall *pending = nullptr;
DBusMessage *msg = static_cast<DBusMessage *>(message);
bool isNoReply = !pcall;
Q_ASSERT(isNoReply == !!q_dbus_message_get_no_reply(msg));
@@ -2175,7 +2175,7 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void *
q_dbus_message_unref(msg);
pcall->pending = pending;
- q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, 0);
+ q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, nullptr);
// DBus won't notify us when a peer disconnects or server terminates so we need to track these ourselves
if (mode == QDBusConnectionPrivate::PeerMode || mode == QDBusConnectionPrivate::ClientMode)
@@ -2261,7 +2261,7 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
if (connection) {
if (mode != QDBusConnectionPrivate::PeerMode) {
qDBusDebug() << this << "Adding rule:" << hook.matchRule;
- q_dbus_bus_add_match(connection, hook.matchRule, NULL);
+ q_dbus_bus_add_match(connection, hook.matchRule, nullptr);
// Successfully connected the signal
// Do we need to watch for this name?
@@ -2274,7 +2274,7 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
q_dbus_bus_add_match(connection,
buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(),
QDBusUtil::nameOwnerChanged(), rules, QString()),
- NULL);
+ nullptr);
data.owner = getNameOwnerNoCache(hook.service);
qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:"
<< data.owner << ")";
@@ -2362,7 +2362,7 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it)
if (connection && erase) {
if (mode != QDBusConnectionPrivate::PeerMode) {
qDBusDebug() << this << "Removing rule:" << hook.matchRule;
- q_dbus_bus_remove_match(connection, hook.matchRule, NULL);
+ q_dbus_bus_remove_match(connection, hook.matchRule, nullptr);
// Successfully disconnected the signal
// Were we watching for this name?
@@ -2375,7 +2375,7 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it)
q_dbus_bus_remove_match(connection,
buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(),
QDBusUtil::nameOwnerChanged(), rules, QString()),
- NULL);
+ nullptr);
}
}
}
@@ -2575,7 +2575,7 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
// it doesn't exist yet, we have to create it
QDBusWriteLocker locker(FindMetaObject2Action, this);
- QDBusMetaObject *mo = 0;
+ QDBusMetaObject *mo = nullptr;
if (!interface.isEmpty())
mo = cachedMetaObjects.value(interface, 0);
if (mo)
@@ -2591,7 +2591,7 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
error = QDBusError(reply);
lastError = error;
if (reply.type() != QDBusMessage::ErrorMessage || error.type() != QDBusError::UnknownMethod)
- return 0; // error
+ return nullptr; // error
}
// release the lock and return