Port HDR plugin to qCDebug, to debug CI failure on FreeBSD

NO_CHANGELOG
This commit is contained in:
David Faure 2020-03-29 12:14:13 +02:00
parent 1d12b345f9
commit 232075f92e
2 changed files with 10 additions and 10 deletions

View File

@ -17,7 +17,7 @@
#include <QCoreApplication> #include <QCoreApplication>
// logging category for this framework, default: log stuff >= warning // logging category for this framework, default: log stuff >= warning
Q_LOGGING_CATEGORY(EPSPLUGIN, "epsplugin", QtWarningMsg) Q_LOGGING_CATEGORY(EPSPLUGIN, "kf5.kimageformats.epsplugin", QtWarningMsg)
//#define EPS_PERFORMANCE_DEBUG 1 //#define EPS_PERFORMANCE_DEBUG 1

View File

@ -12,11 +12,14 @@
#include <QImage> #include <QImage>
#include <QDataStream> #include <QDataStream>
#include <QLoggingCategory>
#include <QDebug> #include <QDebug>
typedef unsigned char uchar; typedef unsigned char uchar;
Q_LOGGING_CATEGORY(HDRPLUGIN, "kf5.kimageformats.hdrplugin", QtWarningMsg)
namespace // Private. namespace // Private.
{ {
@ -95,6 +98,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
// Create dst image. // Create dst image.
img = QImage(width, height, QImage::Format_RGB32); img = QImage(width, height, QImage::Format_RGB32);
if (img.isNull()) { if (img.isNull()) {
qCDebug(HDRPLUGIN) << "Couldn't create image with size" << width << height << "and format RGB32";
return false; return false;
} }
@ -141,6 +145,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
} }
if ((image[2] << 8 | image[3]) != width) { if ((image[2] << 8 | image[3]) != width) {
qCDebug(HDRPLUGIN) << "Line of pixels had width" << (image[2] << 8 | image[3]) << "instead of" << width;
return false; return false;
} }
@ -149,6 +154,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
for (int j = 0; j < width;) { for (int j = 0; j < width;) {
s >> code; s >> code;
if (s.atEnd()) { if (s.atEnd()) {
qCDebug(HDRPLUGIN) << "Truncated HDR file";
return false; return false;
} }
if (code > 128) { if (code > 128) {
@ -183,25 +189,20 @@ bool HDRHandler::read(QImage *outImage)
{ {
int len; int len;
char line[MAXLINE]; char line[MAXLINE];
//bool validHeader = false;
bool validFormat = false; bool validFormat = false;
// Parse header // Parse header
do { do {
len = device()->readLine(line, MAXLINE); len = device()->readLine(line, MAXLINE);
/*if (strcmp(line, "#?RADIANCE\n") == 0 || strcmp(line, "#?RGBE\n") == 0)
{
validHeader = true;
}*/
if (strcmp(line, "FORMAT=32-bit_rle_rgbe\n") == 0) { if (strcmp(line, "FORMAT=32-bit_rle_rgbe\n") == 0) {
validFormat = true; validFormat = true;
} }
} while ((len > 0) && (line[0] != '\n')); } while ((len > 0) && (line[0] != '\n'));
if (/*!validHeader ||*/ !validFormat) { if (!validFormat) {
// qDebug() << "Unknown HDR format."; qCDebug(HDRPLUGIN) << "Unknown HDR format, the header didn't contain FORMAT=32-bit_rle_rgbe";
return false; return false;
} }
@ -210,9 +211,8 @@ bool HDRHandler::read(QImage *outImage)
char s1[3], s2[3]; char s1[3], s2[3];
int width, height; int width, height;
if (sscanf(line, "%2[+-XY] %d %2[+-XY] %d\n", s1, &height, s2, &width) != 4) if (sscanf(line, "%2[+-XY] %d %2[+-XY] %d\n", s1, &height, s2, &width) != 4)
//if( sscanf(line, "-Y %d +X %d", &height, &width) < 2 )
{ {
// qDebug() << "Invalid HDR file."; qCDebug(HDRPLUGIN) << "Invalid HDR file, the first line after the header didn't have the expected format";
return false; return false;
} }