summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMoody Liu <mooodyhunter@outlook.com>2022-06-17 23:58:18 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-21 21:42:25 +0000
commitb258a410579e9e54e9d81019af142ebf7eee8d8c (patch)
tree92ea906d709338fd1995fff261bb1f87bd3bb810 /src
parentc009468ee8013df3072c63a9c885886492d88145 (diff)
jp2: use new APIs for jasper 3
using new APIs prevents the runtime deprecated warning. also note the memory limit is now set to 500MB Task-number: QTBUG-104398 Change-Id: I1b307ec33c6a540a5fb9121214d89a73a509a0d3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 4011d03f84d19bdfa6e30b6b7a6792f90b30a259) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/imageformats/jp2/qjp2handler.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/imageformats/jp2/qjp2handler.cpp b/src/plugins/imageformats/jp2/qjp2handler.cpp
index 4e3308d..fe08995 100644
--- a/src/plugins/imageformats/jp2/qjp2handler.cpp
+++ b/src/plugins/imageformats/jp2/qjp2handler.cpp
@@ -7,6 +7,7 @@
#include "qimage.h"
#include "qvariant.h"
#include "qcolor.h"
+#include "qimagereader.h"
#include <jasper/jasper.h>
#include <math.h> // for pow
@@ -297,16 +298,46 @@ private:
Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
: jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
{
+#if JAS_VERSION_MAJOR < 3
if (jas_init()) {
jasperOk = false;
qDebug("Jasper Library initialization failed");
}
+#else
+ jas_conf_clear();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
+#else
+ // 128MB seems to be enough.
+ jas_conf_set_max_mem_usage(128 * 1024 * 1024);
+#endif
+ if (jas_init_library()) {
+ jasperOk = false;
+ qDebug("Jasper library initialization failed");
+ }
+ if (jas_init_thread()) {
+ jas_cleanup_library();
+ jasperOk = false;
+ qDebug("Jasper thread initialization failed");
+ }
+#endif
}
Jpeg2000JasperReader::~Jpeg2000JasperReader()
{
+#if JAS_VERSION_MAJOR < 3
if (jasperOk)
jas_cleanup();
+#else
+ if (jasperOk) {
+ if (jas_cleanup_thread()) {
+ qDebug("Jasper thread cleanup failed");
+ }
+ if (jas_cleanup_library()) {
+ qDebug("Jasper library cleanup failed");
+ }
+ }
+#endif
}
/*! \internal