Make it possible to avoid loading comments from JPEG and PNG files

Skip reading JPEG and PNG comments information from the header to save
the memory.

This can now be configured through the feature system.

Change-Id: I3744312f69aa3201d5188776cbd99fe690b75d32
Task-number: QTBUG-83123
Pick-to: 5.15
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Elvis Lee 2017-04-26 12:29:24 +09:00 committed by Dominik Holland
parent c549ff3fd4
commit ab6fd84c62
4 changed files with 17 additions and 0 deletions

View File

@ -812,6 +812,10 @@ qt_feature("system-png" PRIVATE
ENABLE INPUT_libpng STREQUAL 'system'
DISABLE INPUT_libpng STREQUAL 'qt'
)
qt_feature("imageio-text-loading" PRIVATE
LABEL "Image Text section loading"
)
qt_feature_definition("imageio-text-loading" "QT_NO_IMAGEIO_TEXT_LOADING" NEGATE)
qt_feature("sessionmanager" PUBLIC
SECTION "Kernel"
LABEL "Session Management"

View File

@ -1366,6 +1366,13 @@
"condition": "features.png && libs.libpng",
"output": [ "privateFeature" ]
},
"imageio-text-loading": {
"label": "Image Text section loading",
"output": [
"privateFeature",
{ "type": "define", "negative": true, "name": "QT_NO_IMAGEIO_TEXT_LOADING" }
]
},
"qpa_default_platform": {
"label": "QPA default platform",
"condition": "features.gui",

View File

@ -530,6 +530,7 @@ static void qt_png_warning(png_structp /*png_ptr*/, png_const_charp message)
void QPngHandlerPrivate::readPngTexts(png_info *info)
{
#ifndef QT_NO_IMAGEIO_TEXT_LOADING
png_textp text_ptr;
int num_text=0;
png_get_text(png_ptr, info, &text_ptr, &num_text);
@ -552,6 +553,9 @@ void QPngHandlerPrivate::readPngTexts(png_info *info)
readTexts.append(value);
text_ptr++;
}
#else
Q_UNUSED(info)
#endif
}

View File

@ -956,6 +956,7 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
for (jpeg_saved_marker_ptr marker = info.marker_list; marker != nullptr; marker = marker->next) {
if (marker->marker == JPEG_COM) {
#ifndef QT_NO_IMAGEIO_TEXT_LOADING
QString key, value;
QString s = QString::fromUtf8((const char *)marker->data, marker->data_length);
int index = s.indexOf(QLatin1String(": "));
@ -971,6 +972,7 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
description += key + QLatin1String(": ") + value.simplified();
readTexts.append(key);
readTexts.append(value);
#endif
} else if (marker->marker == JPEG_APP0 + 1) {
exifData.append((const char*)marker->data, marker->data_length);
} else if (marker->marker == JPEG_APP0 + 2) {