From 232075f92e3fac7050412f186bcf7b799d83337c Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 29 Mar 2020 12:14:13 +0200 Subject: [PATCH] Port HDR plugin to qCDebug, to debug CI failure on FreeBSD NO_CHANGELOG --- src/imageformats/eps.cpp | 2 +- src/imageformats/hdr.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/imageformats/eps.cpp b/src/imageformats/eps.cpp index 80c302f..153512c 100644 --- a/src/imageformats/eps.cpp +++ b/src/imageformats/eps.cpp @@ -17,7 +17,7 @@ #include // 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 diff --git a/src/imageformats/hdr.cpp b/src/imageformats/hdr.cpp index 178aae8..6dc0c9e 100644 --- a/src/imageformats/hdr.cpp +++ b/src/imageformats/hdr.cpp @@ -12,11 +12,14 @@ #include #include +#include #include typedef unsigned char uchar; +Q_LOGGING_CATEGORY(HDRPLUGIN, "kf5.kimageformats.hdrplugin", QtWarningMsg) + namespace // Private. { @@ -95,6 +98,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i // Create dst image. img = QImage(width, height, QImage::Format_RGB32); if (img.isNull()) { + qCDebug(HDRPLUGIN) << "Couldn't create image with size" << width << height << "and format RGB32"; 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) { + qCDebug(HDRPLUGIN) << "Line of pixels had width" << (image[2] << 8 | image[3]) << "instead of" << width; 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;) { s >> code; if (s.atEnd()) { + qCDebug(HDRPLUGIN) << "Truncated HDR file"; return false; } if (code > 128) { @@ -183,25 +189,20 @@ bool HDRHandler::read(QImage *outImage) { int len; char line[MAXLINE]; - //bool validHeader = false; bool validFormat = false; // Parse header do { 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) { validFormat = true; } } while ((len > 0) && (line[0] != '\n')); - if (/*!validHeader ||*/ !validFormat) { - // qDebug() << "Unknown HDR format."; + if (!validFormat) { + qCDebug(HDRPLUGIN) << "Unknown HDR format, the header didn't contain FORMAT=32-bit_rle_rgbe"; return false; } @@ -210,9 +211,8 @@ bool HDRHandler::read(QImage *outImage) char s1[3], s2[3]; int width, height; 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; }