summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qktxhandler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix unsigned/signed mismatch warning in KTX file readingMatthias Rauter2024-02-131-1/+1
| | | | | | | | | | | | On MSCV x86 (32bit) the comparison of qsizetype with std::numeric_limits<quint32>::max() leads to a warning. This patch adds a static cast to avoid the warning. This is an ammendment to 28ecb523ce8490bff38b251b3df703c72e057519 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Ie50572165ac31aafa7d23570bc133c5c96cf8b00 Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
* Improve KTX file reading memory safetyJonas Karlsson2024-02-091-51/+180
| | | | | | | | | | | | | | | | | | | | * Use qAddOverflow/qSubOverflow methods for catching additions and subtractions with overflow and handle these scenarios when reading the file. * Add 'safeView' method that checks that the byte array view constructed is not out of bounds. * Return error if number of levels is higher than what is reasonable. * Return error if number of faces is incorrect. * Add unit test with invalid KTX file previously causing a segmentation fault. This fixes CVE-2024-25580. Fixes: QTBUG-121918 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ie0824c32a5921de30cf07c1fc1b49a084e6d07b2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtGui: Disambiguate static variablesFriedemann Kleint2023-02-031-6/+6
| | | | | | | | | | | | They cause clashes in CMake Unity (Jumbo) builds. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I3c51fb41d29e5c649537b999dced7e2d413b26a7 Done-with: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-1/+3
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix use-after-free because QByteArray::data() was copying dataDimitrios Apostolou2022-04-121-3/+3
| | | | | | | | | | | | | | | | | | | Previously there was a mixture of buf.constData() and buf.data() with buf not being const QByteArray. As a result, buf.data() returned a re-allocated buffer and texData was keeping pointers to that one, which became invalid once the function returned and the re-allocated buffer was cleaned up by destructor. Change buf to const QByteArray so that there is no difference between data() and constData(). Additionally convert all constData() calls to data() to avoid confusion. Detected by Address Sanitizer on testcase tst_qtexturefilereader::checkMetadata() Pick-to: 6.3 6.2 Change-Id: Idb6f6141898678bf95ed9233a92b7bb3ad12e250 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Misc: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | | | | As a drive-by, remove superfluous includes from qnetworkmanagerservice.h and obey the coding conventions for includes in a few more places. Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* De-inline dtors of QTextureFileHandler hierarchyMarc Mutz2022-03-111-0/+2
| | | | | | | | | | | Destructors of polymorphic classes should be out-of-line to pin vtable and type_info objects to a single TU. Pick-to: 6.3 Task-number: QTBUG-45582 Change-Id: I541437a3ff53852527f6278355f7b549e62e17f7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix compiler warnings in 32-bit buildsRobert Löhning2021-03-171-2/+2
| | | | | | | | | comparison of integers of different signs: 'unsigned int' and 'qsizetype' (aka 'int') [-Wsign-compare] Pick-to: 6.1 Change-Id: Ia27f79ab4abca8b757b65ef5f1d30151842088fe Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QTextureFileData: support key value metadataJonas Karlsson2021-02-091-2/+39
| | | | | | | Task-Id: QTBUG-76970 Pick-to: 6.1 Change-Id: I9dba1b373250cea4d0c806997290a7afcdc900d7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Support cubemap ktx filesJonas Karlsson2021-02-011-16/+36
| | | | | | Change-Id: I6905c393647d31fab958cdd9471bb0a6ffe83596 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add face support to texture fileJonas Karlsson2021-01-211-0/+1
| | | | | | Task-Id: QTBUG-76970 Change-Id: I3bbd43357c7fcce8949522b089a4572b948f08f4 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Disentangle QIODevice dependenciesLars Knoll2020-08-151-0/+1
| | | | | | | | | | | | | | | | | Move the QIODevice::OpenMode enum into a base class, so that we can remove the full QIODevice (and thus QObject) dependency from qdatastream.h and qtextstream.h. This is required so that we can include QDataStream in qmetatype.h without getting circular dependencies. As a nice side effect, QDataStream and QTextStream can now inherit QIODeviceBase and provide the OpenMode enum directly in their class scope. Change-Id: Ifa68b7b1d8d95687ed032f6c9206f92e63bfacdf Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-1/+1
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Texture file support: add mipmap reading to ktx handlerv5.12.0-alpha1Eirik Aavitsland2018-09-121-10/+20
| | | | | Change-Id: Ic2c10b3e64d63d2272a8a3922d2b3f99dfd45bdb Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add API for reading and decoding graphical texture filesEirik Aavitsland2018-07-241-0/+189
Add a framework for reading and decoding stored graphical texture file formats. Includes decoders for the PKM and KTX formats. This is basically the same texture file reading that was added to qtdeclarative for 5.11, but has been refactored to be independent of the scenegraph and opengl. Task-number: QTBUG-67026 Change-Id: I87d8117550d8a2112f4f58c03e9ac6b3249cbc5a Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>