summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <[email protected]>2024-07-16 11:46:39 +0200
committerVolker Hilsheimer <[email protected]>2024-07-16 17:59:05 +0200
commit1e1c68017338c89265d6664a27f4137fc8960473 (patch)
tree360ae1bc38bf6185302d5d7e0b3ca930e058956c
parent6aa1cb05e357cf4221aaedd4cf742c45983af446 (diff)
Logging: use qCDebug/Warning/Info when for categorized logging
When building qt with QT_NO_DEBUG/WARNING/INFO_OUTPUT set, then the qDebug/Warning/Info macros expand to `QMessageLogger::noDebug`. That helper is not defined to take a logging category or category function, so using `qDebug(lcX, ...)` breaks the build. The correct way to emit categorized logging is to use the qCDebug/Warning/Info macros. Task-number: QTBUG-125589 Pick-to: 6.8 6.7 6.5 Change-Id: I968b0e826871a09023c11fec9e51caa5a2c4dc0b Reviewed-by: Jonas Karlsson <[email protected]>
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/plugin/qlibrary.cpp2
-rw-r--r--src/gui/text/qdistancefield.cpp2
-rw-r--r--src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp4
-rw-r--r--src/gui/util/qktxhandler.cpp48
-rw-r--r--src/gui/vulkan/qbasicvulkanplatforminstance.cpp6
-rw-r--r--src/gui/vulkan/qvulkanwindow.cpp2
-rw-r--r--src/network/kernel/qnetconmonitor_darwin.mm6
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3json.cpp4
-rw-r--r--src/plugins/tls/openssl/qdtls_openssl.cpp2
-rw-r--r--src/plugins/tls/openssl/qx509_openssl.cpp2
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp2
12 files changed, 41 insertions, 41 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index dee2e9fa975..85d14e79e38 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2920,7 +2920,7 @@ void QCoreApplication::requestPermission(const QPermission &requestedPermission,
Q_ASSERT(slotObj);
if (QThread::currentThread() != QCoreApplicationPrivate::mainThread()) {
- qWarning(lcPermissions, "Permissions can only be requested from the GUI (main) thread");
+ qCWarning(lcPermissions, "Permissions can only be requested from the GUI (main) thread");
return;
}
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 4d3249d3d96..cc935251421 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -364,7 +364,7 @@ inline void QLibraryStore::cleanup()
if (lcDebugLibrary().isDebugEnabled()) {
for (auto &[_, lib] : data->libraryMap) {
if (lib)
- qDebug(lcDebugLibrary)
+ qCDebug(lcDebugLibrary)
<< "On QtCore unload," << lib->fileName << "was leaked, with"
<< lib->libraryRefCount.loadRelaxed() << "users";
}
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 66cb26c2ecc..8b5efe24721 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -732,7 +732,7 @@ static void initialDistanceFieldFactor()
}
if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_RADIUS")) {
QT_DISTANCEFIELD_DEFAULT_RADIUS = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_RADIUS");
- qDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_RADIUS:" << QT_DISTANCEFIELD_DEFAULT_RADIUS;
+ qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_RADIUS:" << QT_DISTANCEFIELD_DEFAULT_RADIUS;
}
if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT")) {
QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT");
diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp
index 2e15fbb1ac1..5674f766de2 100644
--- a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp
+++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp
@@ -754,7 +754,7 @@ void QWindowsDirectWriteFontDatabase::populateFontDatabase()
fontFamily->AddRef();
if (defaultLocaleName == defaultFontName && defaultFontName != systemDefaultFontName) {
- qDebug(lcQpaFonts) << "Adding default font" << systemDefaultFontName << "as alternative to" << defaultLocaleName;
+ qCDebug(lcQpaFonts) << "Adding default font" << systemDefaultFontName << "as alternative to" << defaultLocaleName;
m_populatedFonts.insert(systemDefaultFontName, *fontFamily);
fontFamily->AddRef();
@@ -767,7 +767,7 @@ void QWindowsDirectWriteFontDatabase::populateFontDatabase()
fontFamily->AddRef();
if (englishLocaleName == defaultFontName && defaultFontName != systemDefaultFontName) {
- qDebug(lcQpaFonts) << "Adding default font" << systemDefaultFontName << "as alternative to" << englishLocaleName;
+ qCDebug(lcQpaFonts) << "Adding default font" << systemDefaultFontName << "as alternative to" << englishLocaleName;
m_populatedFonts.insert(systemDefaultFontName, *fontFamily);
fontFamily->AddRef();
diff --git a/src/gui/util/qktxhandler.cpp b/src/gui/util/qktxhandler.cpp
index 35f1df1185a..2c37c2f5f5f 100644
--- a/src/gui/util/qktxhandler.cpp
+++ b/src/gui/util/qktxhandler.cpp
@@ -106,24 +106,24 @@ QTextureFileData QKtxHandler::read()
const QByteArray buf = device()->readAll();
if (static_cast<size_t>(buf.size()) > std::numeric_limits<quint32>::max()) {
- qWarning(lcQtGuiTextureIO, "Too big KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Too big KTX file %s", logName().constData());
return QTextureFileData();
}
if (!canRead(QByteArray(), buf)) {
- qWarning(lcQtGuiTextureIO, "Invalid KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Invalid KTX file %s", logName().constData());
return QTextureFileData();
}
if (buf.size() < qsizetype(qktxh_headerSize)) {
- qWarning(lcQtGuiTextureIO, "Invalid KTX header size in %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Invalid KTX header size in %s", logName().constData());
return QTextureFileData();
}
KTXHeader header;
memcpy(&header, buf.data(), qktxh_headerSize);
if (!checkHeader(header)) {
- qWarning(lcQtGuiTextureIO, "Unsupported KTX file format in %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Unsupported KTX file format in %s", logName().constData());
return QTextureFileData();
}
@@ -141,13 +141,13 @@ QTextureFileData QKtxHandler::read()
const quint32 bytesOfKeyValueData = decode(header.bytesOfKeyValueData);
quint32 headerKeyValueSize;
if (qAddOverflow(qktxh_headerSize, bytesOfKeyValueData, &headerKeyValueSize)) {
- qWarning(lcQtGuiTextureIO, "Overflow in size of key value data in header of KTX file %s",
+ qCWarning(lcQtGuiTextureIO, "Overflow in size of key value data in header of KTX file %s",
logName().constData());
return QTextureFileData();
}
if (headerKeyValueSize >= quint32(buf.size())) {
- qWarning(lcQtGuiTextureIO, "OOB request in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "OOB request in KTX file %s", logName().constData());
return QTextureFileData();
}
@@ -155,13 +155,13 @@ QTextureFileData QKtxHandler::read()
if (bytesOfKeyValueData > 0) {
auto keyValueDataView = safeView(buf, qktxh_headerSize, bytesOfKeyValueData);
if (keyValueDataView.isEmpty()) {
- qWarning(lcQtGuiTextureIO, "Invalid view in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Invalid view in KTX file %s", logName().constData());
return QTextureFileData();
}
auto keyValues = decodeKeyValues(keyValueDataView);
if (!keyValues) {
- qWarning(lcQtGuiTextureIO, "Could not parse key values in KTX file %s",
+ qCWarning(lcQtGuiTextureIO, "Could not parse key values in KTX file %s",
logName().constData());
return QTextureFileData();
}
@@ -177,12 +177,12 @@ QTextureFileData QKtxHandler::read()
{ header.pixelWidth, header.pixelHeight, header.pixelDepth }));
if (texData.numLevels() > maxLevels) {
- qWarning(lcQtGuiTextureIO, "Too many levels in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Too many levels in KTX file %s", logName().constData());
return QTextureFileData();
}
if (texData.numFaces() != 1 && texData.numFaces() != 6) {
- qWarning(lcQtGuiTextureIO, "Invalid number of faces in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Invalid number of faces in KTX file %s", logName().constData());
return QTextureFileData();
}
@@ -190,7 +190,7 @@ QTextureFileData QKtxHandler::read()
for (int level = 0; level < texData.numLevels(); level++) {
const auto imageSizeView = safeView(buf, offset, sizeof(quint32));
if (imageSizeView.isEmpty()) {
- qWarning(lcQtGuiTextureIO, "OOB request in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "OOB request in KTX file %s", logName().constData());
return QTextureFileData();
}
@@ -204,13 +204,13 @@ QTextureFileData QKtxHandler::read()
// Add image data and padding to offset
const auto padded = nearestMultipleOf4(imageSize);
if (!padded) {
- qWarning(lcQtGuiTextureIO, "Overflow in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "Overflow in KTX file %s", logName().constData());
return QTextureFileData();
}
quint32 offsetNext;
if (qAddOverflow(offset, *padded, &offsetNext)) {
- qWarning(lcQtGuiTextureIO, "OOB request in KTX file %s", logName().constData());
+ qCWarning(lcQtGuiTextureIO, "OOB request in KTX file %s", logName().constData());
return QTextureFileData();
}
@@ -219,7 +219,7 @@ QTextureFileData QKtxHandler::read()
}
if (!texData.isValid()) {
- qWarning(lcQtGuiTextureIO, "Invalid values in header of KTX file %s",
+ qCWarning(lcQtGuiTextureIO, "Invalid values in header of KTX file %s",
logName().constData());
return QTextureFileData();
}
@@ -273,7 +273,7 @@ std::optional<QMap<QByteArray, QByteArray>> QKtxHandler::decodeKeyValues(QByteAr
while (offset < quint32(view.size())) {
const auto keyAndValueByteSizeView = safeView(view, offset, sizeof(quint32));
if (keyAndValueByteSizeView.isEmpty()) {
- qWarning(lcQtGuiTextureIO, "Invalid view in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Invalid view in KTX key-value");
return std::nullopt;
}
@@ -282,19 +282,19 @@ std::optional<QMap<QByteArray, QByteArray>> QKtxHandler::decodeKeyValues(QByteAr
quint32 offsetKeyAndValueStart;
if (qAddOverflow(offset, quint32(sizeof(quint32)), &offsetKeyAndValueStart)) {
- qWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
return std::nullopt;
}
quint32 offsetKeyAndValueEnd;
if (qAddOverflow(offsetKeyAndValueStart, keyAndValueByteSize, &offsetKeyAndValueEnd)) {
- qWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
return std::nullopt;
}
const auto keyValueView = safeView(view, offsetKeyAndValueStart, keyAndValueByteSize);
if (keyValueView.isEmpty()) {
- qWarning(lcQtGuiTextureIO, "Invalid view in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Invalid view in KTX key-value");
return std::nullopt;
}
@@ -304,13 +304,13 @@ std::optional<QMap<QByteArray, QByteArray>> QKtxHandler::decodeKeyValues(QByteAr
const int idx = keyValueView.indexOf('\0');
if (idx == -1) {
- qWarning(lcQtGuiTextureIO, "Invalid key in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Invalid key in KTX key-value");
return std::nullopt;
}
const QByteArrayView keyView = safeView(view, offsetKeyAndValueStart, idx);
if (keyView.isEmpty()) {
- qWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
return std::nullopt;
}
@@ -318,19 +318,19 @@ std::optional<QMap<QByteArray, QByteArray>> QKtxHandler::decodeKeyValues(QByteAr
quint32 offsetValueStart;
if (qAddOverflow(offsetKeyAndValueStart, keySize, &offsetValueStart)) {
- qWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
return std::nullopt;
}
quint32 valueSize;
if (qSubOverflow(keyAndValueByteSize, keySize, &valueSize)) {
- qWarning(lcQtGuiTextureIO, "Underflow in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Underflow in KTX key-value");
return std::nullopt;
}
const QByteArrayView valueView = safeView(view, offsetValueStart, valueSize);
if (valueView.isEmpty()) {
- qWarning(lcQtGuiTextureIO, "Invalid view in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Invalid view in KTX key-value");
return std::nullopt;
}
@@ -338,7 +338,7 @@ std::optional<QMap<QByteArray, QByteArray>> QKtxHandler::decodeKeyValues(QByteAr
const auto offsetNext = nearestMultipleOf4(offsetKeyAndValueEnd);
if (!offsetNext) {
- qWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
+ qCWarning(lcQtGuiTextureIO, "Overflow in KTX key-value");
return std::nullopt;
}
diff --git a/src/gui/vulkan/qbasicvulkanplatforminstance.cpp b/src/gui/vulkan/qbasicvulkanplatforminstance.cpp
index 04ede49c39b..b6a820199c0 100644
--- a/src/gui/vulkan/qbasicvulkanplatforminstance.cpp
+++ b/src/gui/vulkan/qbasicvulkanplatforminstance.cpp
@@ -173,7 +173,7 @@ void QBasicPlatformVulkanInstance::init(QLibrary *lib)
m_supportedExtensions.append(ext);
}
}
- qDebug(lcPlatVk) << "Supported Vulkan instance extensions:" << m_supportedExtensions;
+ qCDebug(lcPlatVk) << "Supported Vulkan instance extensions:" << m_supportedExtensions;
}
QVulkanInfoVector<QVulkanLayer> QBasicPlatformVulkanInstance::supportedLayers() const
@@ -248,13 +248,13 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const
if (!m_supportedLayers.contains(layerName))
m_enabledLayers.removeAt(i--);
}
- qDebug(lcPlatVk) << "Enabling Vulkan instance layers:" << m_enabledLayers;
+ qCDebug(lcPlatVk) << "Enabling Vulkan instance layers:" << m_enabledLayers;
for (int i = 0; i < m_enabledExtensions.size(); ++i) {
const QByteArray &extName(m_enabledExtensions[i]);
if (!m_supportedExtensions.contains(extName))
m_enabledExtensions.removeAt(i--);
}
- qDebug(lcPlatVk) << "Enabling Vulkan instance extensions:" << m_enabledExtensions;
+ qCDebug(lcPlatVk) << "Enabling Vulkan instance extensions:" << m_enabledExtensions;
VkInstanceCreateInfo instInfo = {};
instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp
index 2430ee2ab89..9bfc7d229bd 100644
--- a/src/gui/vulkan/qvulkanwindow.cpp
+++ b/src/gui/vulkan/qvulkanwindow.cpp
@@ -377,7 +377,7 @@ QVulkanInfoVector<QVulkanExtension> QVulkanWindow::supportedDeviceExtensions()
exts.append(ext);
}
d->supportedDevExtensions.insert(physDev, exts);
- qDebug(lcGuiVk) << "Supported device extensions:" << exts;
+ qCDebug(lcGuiVk) << "Supported device extensions:" << exts;
return exts;
}
}
diff --git a/src/network/kernel/qnetconmonitor_darwin.mm b/src/network/kernel/qnetconmonitor_darwin.mm
index 60b3cd65818..b94cbabab1a 100644
--- a/src/network/kernel/qnetconmonitor_darwin.mm
+++ b/src/network/kernel/qnetconmonitor_darwin.mm
@@ -229,20 +229,20 @@ bool QNetworkConnectionMonitor::startMonitoring()
auto queue = qt_reachability_queue();
if (!queue) {
- qWarning(lcNetMon, "Failed to create a dispatch queue to schedule a probe on");
+ qCWarning(lcNetMon, "Failed to create a dispatch queue to schedule a probe on");
return false;
}
SCNetworkReachabilityContext context = {};
context.info = d;
if (!SCNetworkReachabilitySetCallback(d->probe, QNetworkConnectionMonitorPrivate::probeCallback, &context)) {
- qWarning(lcNetMon, "Failed to set a reachability callback");
+ qCWarning(lcNetMon, "Failed to set a reachability callback");
return false;
}
if (!SCNetworkReachabilitySetDispatchQueue(d->probe, queue)) {
- qWarning(lcNetMon, "Failed to schedule a reachability callback on a queue");
+ qCWarning(lcNetMon, "Failed to schedule a reachability callback on a queue");
return false;
}
diff --git a/src/plugins/platformthemes/gtk3/qgtk3json.cpp b/src/plugins/platformthemes/gtk3/qgtk3json.cpp
index a517fec63ff..535b3b2dc84 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3json.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3json.cpp
@@ -249,7 +249,7 @@ bool QGtk3Json::load(QGtk3Storage::PaletteMap &map, const QString &fileName)
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err);
if (err.error != QJsonParseError::NoError) {
- qWarning(lcQGtk3Interface) << "Unable to parse Json document from" << fileName
+ qCWarning(lcQGtk3Interface) << "Unable to parse Json document from" << fileName
<< err.error << err.errorString();
return false;
}
@@ -417,7 +417,7 @@ bool QGtk3Json::load(QGtk3Storage::PaletteMap &map, const QJsonDocument &doc)
break;
case QGtk3Storage::SourceType::Invalid:
- qInfo(lcQGtk3Interface) << "Invalid source type for palette" << paletteName
+ qCInfo(lcQGtk3Interface) << "Invalid source type for palette" << paletteName
<< "Brush." << colorRoleName;
return false;
}
diff --git a/src/plugins/tls/openssl/qdtls_openssl.cpp b/src/plugins/tls/openssl/qdtls_openssl.cpp
index fc07a29ec86..01978551bb5 100644
--- a/src/plugins/tls/openssl/qdtls_openssl.cpp
+++ b/src/plugins/tls/openssl/qdtls_openssl.cpp
@@ -353,7 +353,7 @@ extern "C" long q_dgram_ctrl(BIO *bio, int cmd, long num, void *ptr)
// command.
if (!bio) {
- qDebug(lcTlsBackend, "invalid 'bio' parameter (nullptr)");
+ qCDebug(lcTlsBackend, "invalid 'bio' parameter (nullptr)");
return -1;
}
diff --git a/src/plugins/tls/openssl/qx509_openssl.cpp b/src/plugins/tls/openssl/qx509_openssl.cpp
index 0cd3749f882..21c81b105de 100644
--- a/src/plugins/tls/openssl/qx509_openssl.cpp
+++ b/src/plugins/tls/openssl/qx509_openssl.cpp
@@ -256,7 +256,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
else if (meth->ext_free)
meth->ext_free(ext_internal);
else
- qWarning(lcTlsBackend, "Cannot free an extension, a potential memory leak?");
+ qCWarning(lcTlsBackend, "Cannot free an extension, a potential memory leak?");
});
const char * hexString = nullptr; // The value returned by meth->i2s.
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index 6fe4faec034..85ab23620e3 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -771,7 +771,7 @@ void tst_QHighDpi::mouseVelocity()
{
velocity = ev->points().first().velocity();
if (ev->buttons())
- qDebug(lcTests) << "velocity" << velocity << ev;
+ qCDebug(lcTests) << "velocity" << velocity << ev;
}
};