dbus: Put the qWarnings in qdbusintegrator.cpp into its own category

We already have a category for the integrator debug information, we
might as well start using it for all warnings.

Change-Id: I13239035a334a03036611ccac49cb8c2bf9233b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Aleix Pol 2022-11-24 16:34:03 +01:00
parent 5812c36cd5
commit 683ed1e526

View File

@ -987,7 +987,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
send(msg.createReply(outputArgs)); send(msg.createReply(outputArgs));
} else { } else {
// generate internal error // generate internal error
qWarning("Internal error: Failed to deliver message"); qCWarning(dbusIntegration, "Internal error: Failed to deliver message");
send(msg.createErrorReply(QDBusError::InternalError, "Failed to deliver message"_L1)); send(msg.createErrorReply(QDBusError::InternalError, "Failed to deliver message"_L1));
} }
} }
@ -1044,9 +1044,10 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
QDBusConnectionPrivate::~QDBusConnectionPrivate() QDBusConnectionPrivate::~QDBusConnectionPrivate()
{ {
if (thread() && thread() != QThread::currentThread()) if (thread() && thread() != QThread::currentThread())
qWarning("QDBusConnection(name=\"%s\")'s last reference in not in its creation thread! " qCWarning(dbusIntegration,
"Timer and socket errors will follow and the program will probably crash", "QDBusConnection(name=\"%s\")'s last reference in not in its creation thread! "
qPrintable(name)); "Timer and socket errors will follow and the program will probably crash",
qPrintable(name));
auto lastMode = mode; // reset on connection close auto lastMode = mode; // reset on connection close
closeConnection(); closeConnection();
@ -1263,8 +1264,8 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
DBusMessage *msg = DBusMessage *msg =
QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error); QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error);
if (!msg) { if (!msg) {
qWarning("QDBusConnection: Could not emit signal %s.%s: %s", qPrintable(interface), memberName.constData(), qCWarning(dbusIntegration, "QDBusConnection: Could not emit signal %s.%s: %s",
qPrintable(error.message())); qPrintable(interface), memberName.constData(), qPrintable(error.message()));
lastError = error; lastError = error;
return; return;
} }
@ -1285,8 +1286,9 @@ void QDBusConnectionPrivate::serviceOwnerChangedNoLock(const QString &name,
if (it == watchedServices.end()) if (it == watchedServices.end())
return; return;
if (oldOwner != it->owner) if (oldOwner != it->owner)
qWarning("QDBusConnection: name '%s' had owner '%s' but we thought it was '%s'", qCWarning(dbusIntegration,
qPrintable(name), qPrintable(oldOwner), qPrintable(it->owner)); "QDBusConnection: name '%s' had owner '%s' but we thought it was '%s'",
qPrintable(name), qPrintable(oldOwner), qPrintable(it->owner));
qDBusDebug() << this << "Updating name" << name << "from" << oldOwner << "to" << newOwner; qDBusDebug() << this << "Updating name" << name << "from" << oldOwner << "to" << newOwner;
it->owner = newOwner; it->owner = newOwner;
@ -1928,22 +1930,26 @@ bool QDBusConnectionPrivate::send(const QDBusMessage& message)
QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error); QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error);
if (!msg) { if (!msg) {
if (message.type() == QDBusMessage::MethodCallMessage) if (message.type() == QDBusMessage::MethodCallMessage)
qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s", qCWarning(dbusIntegration,
qPrintable(message.service()), qPrintable(message.path()), "QDBusConnection: error: could not send message to service \"%s\" path "
qPrintable(message.interface()), qPrintable(message.member()), "\"%s\" interface \"%s\" member \"%s\": %s",
qPrintable(error.message())); qPrintable(message.service()), qPrintable(message.path()),
qPrintable(message.interface()), qPrintable(message.member()),
qPrintable(error.message()));
else if (message.type() == QDBusMessage::SignalMessage) else if (message.type() == QDBusMessage::SignalMessage)
qWarning("QDBusConnection: error: could not send signal to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s", qCWarning(dbusIntegration,
qPrintable(message.service()), "QDBusConnection: error: could not send signal to service \"%s\" path \"%s\" "
qPrintable(message.path()), qPrintable(message.interface()), "interface \"%s\" member \"%s\": %s",
qPrintable(message.member()), qPrintable(message.service()), qPrintable(message.path()),
qPrintable(error.message())); qPrintable(message.interface()), qPrintable(message.member()),
qPrintable(error.message()));
else else
qWarning("QDBusConnection: error: could not send %s message to service \"%s\": %s", qCWarning(dbusIntegration,
message.type() == QDBusMessage::ReplyMessage ? "reply" : "QDBusConnection: error: could not send %s message to service \"%s\": %s",
message.type() == QDBusMessage::ErrorMessage ? "error" : message.type() == QDBusMessage::ReplyMessage ? "reply"
"invalid", qPrintable(message.service()), : message.type() == QDBusMessage::ErrorMessage ? "error"
qPrintable(error.message())); : "invalid",
qPrintable(message.service()), qPrintable(error.message()));
lastError = error; lastError = error;
return false; return false;
} }
@ -1990,7 +1996,10 @@ public:
if (ok) if (ok)
mainThreadWarningAmount = tmp; mainThreadWarningAmount = tmp;
else else
qWarning("QDBusBlockingCallWatcher: Q_DBUS_BLOCKING_CALL_MAIN_THREAD_WARNING_MS must be an integer; value ignored"); qCWarning(
dbusIntegration,
"QDBusBlockingCallWatcher: Q_DBUS_BLOCKING_CALL_MAIN_THREAD_WARNING_MS "
"must be an integer; value ignored");
} }
env = qgetenv("Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS"); env = qgetenv("Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS");
@ -1999,7 +2008,10 @@ public:
if (ok) if (ok)
otherThreadWarningAmount = tmp; otherThreadWarningAmount = tmp;
else else
qWarning("QDBusBlockingCallWatcher: Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS must be an integer; value ignored"); qCWarning(dbusIntegration,
"QDBusBlockingCallWatcher: "
"Q_DBUS_BLOCKING_CALL_OTHER_THREAD_WARNING_MS must be an integer; "
"value ignored");
} }
initializedAmounts = true; initializedAmounts = true;
@ -2024,10 +2036,13 @@ public:
return; // disabled return; // disabled
if (m_callTimer.elapsed() >= m_maxCallTimeoutMs) { if (m_callTimer.elapsed() >= m_maxCallTimeoutMs) {
qWarning("QDBusConnection: warning: blocking call took a long time (%d ms, max for this thread is %d ms) to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"", qCWarning(
int(m_callTimer.elapsed()), m_maxCallTimeoutMs, dbusIntegration,
qPrintable(m_message.service()), qPrintable(m_message.path()), "QDBusConnection: warning: blocking call took a long time (%d ms, max for this "
qPrintable(m_message.interface()), qPrintable(m_message.member())); "thread is %d ms) to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"",
int(m_callTimer.elapsed()), m_maxCallTimeoutMs, qPrintable(m_message.service()),
qPrintable(m_message.path()), qPrintable(m_message.interface()),
qPrintable(m_message.member()));
} }
} }
@ -2089,9 +2104,12 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
// if the message was handled, there might be a reply // if the message was handled, there might be a reply
QDBusMessage localReplyMsg = QDBusMessagePrivate::makeLocalReply(*this, localCallMsg); QDBusMessage localReplyMsg = QDBusMessagePrivate::makeLocalReply(*this, localCallMsg);
if (localReplyMsg.type() == QDBusMessage::InvalidMessage) { if (localReplyMsg.type() == QDBusMessage::InvalidMessage) {
qWarning("QDBusConnection: cannot call local method '%s' at object %s (with signature '%s') " qCWarning(
"on blocking mode", qPrintable(message.member()), qPrintable(message.path()), dbusIntegration,
qPrintable(message.signature())); "QDBusConnection: cannot call local method '%s' at object %s (with signature '%s') "
"on blocking mode",
qPrintable(message.member()), qPrintable(message.path()),
qPrintable(message.signature()));
return QDBusMessage::createError( return QDBusMessage::createError(
QDBusError(QDBusError::InternalError, QDBusError(QDBusError::InternalError,
"local-loop message cannot have delayed replies"_L1)); "local-loop message cannot have delayed replies"_L1));
@ -2142,10 +2160,12 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
DBusMessage *msg = DBusMessage *msg =
QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error); QDBusMessagePrivate::toDBusMessage(message, connectionCapabilities(), &error);
if (!msg) { if (!msg) {
qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s", qCWarning(dbusIntegration,
qPrintable(message.service()), qPrintable(message.path()), "QDBusConnection: error: could not send message to service \"%s\" path \"%s\" "
qPrintable(message.interface()), qPrintable(message.member()), "interface \"%s\" member \"%s\": %s",
qPrintable(error.message())); qPrintable(message.service()), qPrintable(message.path()),
qPrintable(message.interface()), qPrintable(message.member()),
qPrintable(error.message()));
pcall->replyMessage = QDBusMessage::createError(error); pcall->replyMessage = QDBusMessage::createError(error);
lastError = error; lastError = error;
processFinishedCall(pcall); processFinishedCall(pcall);
@ -2351,7 +2371,9 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it)
bool erase = false; bool erase = false;
MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule); MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule);
if (i == matchRefCounts.end()) { if (i == matchRefCounts.end()) {
qWarning("QDBusConnectionPrivate::disconnectSignal: MatchRule not found in matchRefCounts!!"); qCWarning(dbusIntegration,
"QDBusConnectionPrivate::disconnectSignal: MatchRule not found in "
"matchRefCounts!!");
} else { } else {
if (i.value() == 1) { if (i.value() == 1) {
erase = true; erase = true;