Switch all plugins to QLoggingCategory

This commit is contained in:
Mirco Miranda
2025-09-19 10:00:26 +02:00
parent a4e18734bd
commit fda751c641
17 changed files with 372 additions and 286 deletions

View File

@@ -12,8 +12,14 @@
#include "util_p.h"
#include <QDataStream>
#include <QDebug>
#include <QImage>
#include <QLoggingCategory>
#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(LOG_RASPLUGIN, "kf.imageformats.plugins.ras", QtDebugMsg)
#else
Q_LOGGING_CATEGORY(LOG_RASPLUGIN, "kf.imageformats.plugins.ras", QtWarningMsg)
#endif
/* *** RAS_MAX_IMAGE_WIDTH and RAS_MAX_IMAGE_HEIGHT ***
* The maximum size in pixel allowed by the plugin.
@@ -73,14 +79,14 @@ static QDataStream &operator>>(QDataStream &s, RasHeader &head)
s >> head.Type;
s >> head.ColorMapType;
s >> head.ColorMapLength;
/*qDebug() << "MagicNumber: " << head.MagicNumber
<< "Width: " << head.Width
<< "Height: " << head.Height
<< "Depth: " << head.Depth
<< "Length: " << head.Length
<< "Type: " << head.Type
<< "ColorMapType: " << head.ColorMapType
<< "ColorMapLength: " << head.ColorMapLength;*/
// qCDebug(LOG_RASPLUGIN) << "MagicNumber: " << head.MagicNumber
// << "Width: " << head.Width
// << "Height: " << head.Height
// << "Depth: " << head.Depth
// << "Length: " << head.Length
// << "Type: " << head.Type
// << "ColorMapType: " << head.ColorMapType
// << "ColorMapLength: " << head.ColorMapLength;
return s;
}
@@ -218,7 +224,7 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
if (rasLineSize & 1)
++rasLineSize;
if (rasLineSize > kMaxQVectorSize) {
qWarning() << "LoadRAS() unsupported line size" << rasLineSize;
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unsupported line size" << rasLineSize;
return false;
}
@@ -256,7 +262,7 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
for (quint32 y = 0; y < ras.Height; ++y) {
auto rasLine = dec.readLine(rasLineSize);
if (rasLine.size() != rasLineSize) {
qWarning() << "LoadRAS() unable to read line" << y << ": the seems corrupted!";
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unable to read line" << y << ": the seems corrupted!";
return false;
}
@@ -336,8 +342,8 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
continue;
}
qWarning() << "LoadRAS() unsupported format!"
<< "ColorMapType:" << ras.ColorMapType << "Type:" << ras.Type << "Depth:" << ras.Depth;
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unsupported format!"
<< "ColorMapType:" << ras.ColorMapType << "Type:" << ras.Type << "Depth:" << ras.Depth;
return false;
}
@@ -373,7 +379,7 @@ bool RASHandler::canRead() const
bool RASHandler::canRead(QIODevice *device)
{
if (!device) {
qWarning("RASHandler::canRead() called with no device");
qCWarning(LOG_RASPLUGIN) << "RASHandler::canRead() called with no device";
return false;
}
@@ -399,19 +405,19 @@ bool RASHandler::read(QImage *outImage)
s >> ras;
if (ras.ColorMapLength > kMaxQVectorSize) {
qWarning() << "read() unsupported image color map length in file header" << ras.ColorMapLength;
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unsupported image color map length in file header" << ras.ColorMapLength;
return false;
}
// Check supported file types.
if (!IsSupported(ras)) {
// qDebug() << "This RAS file is not supported.";
// qCDebug(LOG_RASPLUGIN) << "This RAS file is not supported.";
return false;
}
QImage img;
if (!LoadRAS(s, ras, img)) {
// qDebug() << "Error loading RAS file.";
// qCDebug(LOG_RASPLUGIN) << "Error loading RAS file.";
return false;
}