chunks.cpp - send info and warning messages to the iff logging category

For example:
`IFFChunk::innerFromDevice: unkwnown chunk "\x89PNG"`

becomes:
`kf.imageformats.plugins.iff: IFFChunk::innerFromDevice: unknown chunk "\x89PNG"`

bonus: we can filter out such messages if we want using QT_LOGGING_RULES

also note the spelling fix
This commit is contained in:
Allen Winter
2025-07-16 10:21:00 -04:00
parent 0a9f9fe106
commit 083680eb77

View File

@ -9,6 +9,9 @@
#include "packbits_p.h" #include "packbits_p.h"
#include <QDebug> #include <QDebug>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(LOG_IFFPLUGIN)
#define RECURSION_PROTECTION 10 #define RECURSION_PROTECTION 10
@ -282,7 +285,7 @@ IFFChunk::ChunkList IFFChunk::innerFromDevice(QIODevice *d, bool *ok, IFFChunk *
chunk = QSharedPointer<IFFChunk>(new XMP0Chunk()); chunk = QSharedPointer<IFFChunk>(new XMP0Chunk());
} else { // unknown chunk } else { // unknown chunk
chunk = QSharedPointer<IFFChunk>(new IFFChunk()); chunk = QSharedPointer<IFFChunk>(new IFFChunk());
qInfo() << "IFFChunk::innerFromDevice: unkwnown chunk" << cid; qCInfo(LOG_IFFPLUGIN) << "IFFChunk::innerFromDevice: unknown chunk" << cid;
} }
// change the alignment to the one of main chunk (required for unknown Maya IFF chunks) // change the alignment to the one of main chunk (required for unknown Maya IFF chunks)
@ -724,7 +727,7 @@ QByteArray BODYChunk::deinterleave(const QByteArray &planes, const BMHDChunk *he
prev[1] = qGreen(pal.at(idx)); prev[1] = qGreen(pal.at(idx));
prev[2] = qBlue(pal.at(idx)); prev[2] = qBlue(pal.at(idx));
} else { } else {
qWarning() << "BODYChunk::deinterleave: palette index" << idx << "is out of range"; qCWarning(LOG_IFFPLUGIN) << "BODYChunk::deinterleave: palette index" << idx << "is out of range";
} }
break; break;
} }
@ -761,7 +764,7 @@ QByteArray BODYChunk::deinterleave(const QByteArray &planes, const BMHDChunk *he
ba[cnt3 + 1] = qGreen(pal.at(idx)) / div; ba[cnt3 + 1] = qGreen(pal.at(idx)) / div;
ba[cnt3 + 2] = qBlue(pal.at(idx)) / div; ba[cnt3 + 2] = qBlue(pal.at(idx)) / div;
} else { } else {
qWarning() << "BODYChunk::deinterleave: palette index" << idx << "is out of range"; qCWarning(LOG_IFFPLUGIN) << "BODYChunk::deinterleave: palette index" << idx << "is out of range";
} }
} }
} }