Skip to content

Commit

Permalink
QImageReader: add tracepoints for image loading
Browse files Browse the repository at this point in the history
Change-Id: I5fe25793eeda01a4fa1658091890af23f66b7089
Reviewed-by: Rafael Roquetto <[email protected]>
  • Loading branch information
dangelog committed Oct 14, 2018
1 parent 8ec98fc commit 72fc657
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/gui/image/qimagereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
#endif

#include <private/qimagereaderwriterhelpers_p.h>
#include <qtgui_tracepoints_p.h>

#include <algorithm>

Expand Down Expand Up @@ -1250,7 +1251,18 @@ bool QImageReader::read(QImage *image)
d->handler->setOption(QImageIOHandler::Quality, d->quality);

// read the image
if (!d->handler->read(image)) {
if (Q_TRACE_ENABLED(QImageReader_read_before_reading)) {
QString fileName = QStringLiteral("unknown");
if (QFile *file = qobject_cast<QFile *>(d->device))
fileName = file->fileName();
Q_TRACE(QImageReader_read_before_reading, this, fileName);
}

const bool result = d->handler->read(image);

Q_TRACE(QImageReader_read_after_reading, this, result);

if (!result) {
d->imageReaderError = InvalidDataError;
d->errorString = QImageReader::tr("Unable to read image data");
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/gui/qtgui.tracepoints
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ QFontDatabase_addApplicationFont(const QString &filename)
QFontDatabase_load(const QString &family, int pointSize)
QFontDatabase_loadEngine(const QString &family, int pointSize)
QFontDatabasePrivate_addAppFont(const QString &fileName)

QImageReader_read_before_reading(QImageReader *reader, const QString &filename)
QImageReader_read_after_reading(QImageReader *reader, bool result)

0 comments on commit 72fc657

Please sign in to comment.