Compare commits

...

273 Commits

Author SHA1 Message Date
Thiago Macieira
6ce164b3e0 QThread/Unix: move the pthread_key to a file-scope static
So that the pthread_key is destroyed much later than now, at QtCore
unload time instead of a bit earlier in exit(). That's important so it
runs later than the Q_DESTRUCTOR_FUNCTION for QLibraryStore
(qlibrary.cpp), which is what unloads plugins, whose unload-time
destructors may be attempting to quit() & wait() for their worker
threads.

I had to keep the destruction of the exiting thread's adopted thread
where it was: a function-local static's destructor. As noted in the
comment added by 1da7558bfd7626bcc40a214a90ae5027f32f6c7f, we need
QThreadData::cleanup() to run before the libraries start to unload
because we need to delete the event dispatcher.

Init priority 10 will place it after the QHash random seed and qsimd
initialization, on ELF systems and on Windows. On other systems (incl.
Apple ones), the order probably depends on the order of the files in the
CMakeLists.txt. I thought that would mean the destructor for thread/
would run before plugin/ but that apparently is not the case. But that's
fragile.

Amends 1da7558bfd7626bcc40a214a90ae5027f32f6c7f, which amended other
things...

Fixes: QTBUG-132697
Task-number: QTBUG-102984
Task-number: QTBUG-132381
Pick-to: 6.8
Change-Id: Id7263d6ffe7a5949cd84e35d942ad0e02df1b455
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 2f69a05bd0cd7ce63890f709ff3ed7a4f78acd70)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-12 17:40:00 +00:00
Thiago Macieira
ea6d467c05 tst_Q*Application: add tests for unusual qApp creations and exits
This commit adds one unusual creation and three more unusual exits:
* creation of the Q*Application in a thread (QTBUG-130895)
* exits using ::exit() instead of returning from main():
  * from the main thread's event loop
  * from an auxiliary thread
  * from inside an auxiliary thread's event loop

All of these exercise the moment the QAdoptedThread & QThreadData for
the main thread is destroyed, which are, respectively:
* thread exit time, running thread-specific destructors
* inside exit(), running atexit()-like callbacks (qthread_*.cpp)
* [tst_static_q*application] inside exit(), running static destructors
  (added in commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)

Unlike the tst_static_q*application tests, the calls to ::exit() cannot
be a regular QtTest because that would cause the log output to be
incomplete. The threaded Q*Application could be a test of its own, but
since I needed to add the helper anyway, I chose to add the test there.

For the majority of the tests, the failure mode is going to be a crash
on exit.

Task-number: QTBUG-12673
Task-number: QTBUG-132429
Pick-to: 6.8
Change-Id: I1062ef500356bd97dd0cfffda4aeeda9afa138e8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit bfbd1a281dd00c47df315c06e895bf5d53cd8764)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-12 17:40:00 +00:00
Christian Ehrlicher
2bb83f6b16 QIcon: don't search for high-res svg icons
There is no need to search for high-res svg icons - a svg scalable by
design. Also the QSvgIconEngine does not support it.

Pick-to: 6.8
Change-Id: Ib76c887900ce77268e9c0253cb697b8de9e7f10e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit c64774eef72411029f7c2fb611328f25b83ff8ca)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-12 09:05:44 +00:00
Tor Arne Vestbø
197a46313d coin: Ignore exit code of LastTest.log copy if COIN_CTEST_IGNORE_EXIT_CODE
If COIN_CTEST_IGNORE_EXIT_CODE is in effect and ctest aborts for some
reason (for example due to the workitem being cancelled) the ctest exit
code will be ignored, as expected, but we will not have a LastTest.log
to copy, which will fail the workitem unexpectedly.

We now match the ignoreExitCode of the LastTest.log copy with the ctest
run.

Change-Id: I9df0f863a42dd4cf25cee1694e85cb32058a4e5b
Reviewed-by: Toni Saario <toni.saario@qt.io>
(cherry picked from commit 0e2067334d58787464a3554730042dba37413c6d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 14:02:54 +00:00
Marc Mutz
58221c1955 QTemporaryFile: fix incorrect info about duplicate placeholders
The docs said only the first placeholder would be considered; in fact,
it considers only the last.

Fix the docs and add a test (also for QTemporaryDir).

Amends b4bb4449aea7592afdb9b9134bb90c40fe29735a.

While 6.6 and earlier are unaffected by the incorrect documentation,
pick this to all active branches in order to verify the behavior is
the same everywhere.

Pick-to: 6.8 6.5 6.2 5.15
Fixes: QTBUG-132597
Change-Id: Ia7a37f714f834191b07420d31ca9024702b537cc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit e7abbc7bf3ab06359b2847b1e1a46c38d8bc6581)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 08:48:30 +00:00
Alexandru Croitor
0cb2413219 CMake: Fix sbom git vars not being available in various scopes
Initially the git vars were assigned to the parent scope of the
_qt_internal_sbom_begin_project function, with the intent to set them
in the global scope. But the function was later wrapped in other
functions, so the variables stopped being accessible.

Instead of playing with recursive PARENT_SCOPEs, save the variables in
global properties like we do for other info, and use a new
_qt_internal_sbom_get_git_version_vars() function to query the vars in
the code that needs them.

This fixes generated purls to contain the git version and hashes.

Also add a new internal API wrapper macro called
qt_internal_sbom_get_git_version_vars to allow calling it
in other repos.

Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: I061b34f418c1ecc1c66c8c01ef758d2f40611ede
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 41a92bf6f1486259ef25db775520cba647e1cc15)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 08:48:30 +00:00
Alexandru Croitor
65b1756d01 CMake: Split SBOM implementation into separate files
The SBOM implementation got somewhat large. Split the code into
several new QtPublicSbomFooHelpers.cmake files, to make it more
manageable.

No code or behavior was changed.

Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: Ia0ca1792eec21d12c4bb4cabe63279e1f5c07e3d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 27d2b54b5d2bc5a69edc2de703b2ca34cb2637dc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 08:48:29 +00:00
Christian Ehrlicher
3536eb32bf QStandardItem: correctly set model during insertRows()
When calling insertRows(), the model of the child items was not
correctly updated. insertRow() is behaving correctly.

Pick-to: 6.8
Fixes: QTBUG-131372
Change-Id: I8b6aef7ab97887c6eb46eb21b992d76e4d59b3a0
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 5bab8448feb2661f871e71d71a95afaffcb1656a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 08:48:29 +00:00
Marc Mutz
3660ff9ff8 tst_QSaveFile: QVERIFY the commit() return value in symlink() test
It's kinda is important to verify that commit() worked; all the
follow-up tests assume it, so wrap the calls in QVERIFY().

Amends 7e5e7eeaa1418d959906cdf9d717c984c9fc7a7e.

Pick-to: 6.8 6.5 5.15
Change-Id: I01185d65a5ec06ed122e59c43d9cdcc3a7157259
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 97fe38ff0d1e60f92c0bfa6fb3571a0433e60352)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 00:04:16 +00:00
Marc Mutz
b2dad9724d tst_QSaveFile: mark a QString const
To ensure we don't overwrite it in this quite long function.

Amends 7e5e7eeaa1418d959906cdf9d717c984c9fc7a7e.

Pick-to: 6.8 6.5 5.15
Change-Id: Ie5f81b50d2d66ba9e064810f8cbc1a7af298cc2b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 67a906b5564a1ccf03e547aa78fc6fd910d9cd15)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 00:04:09 +00:00
Marc Mutz
ab9021e2d6 QSaveFile: mention that you need to setFileName() before open()
... in the descriptiong of the (QObject*) ctor.

Pick-to: 6.8 6.5 5.15
Change-Id: I1b8a788eff1fbb50134b51de7d9ee8f7cb2af785
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6397dac97962e40104e6a94bc147e093af8186e2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-11 00:04:03 +00:00
Alexandru Croitor
3ee0cb32e0 CMake: Fix LINK_LIBRARIES not being properly processed for SBOM
There was a typo in the link_libraries variable name, where an upper
case 'L' was used instead of a lower case 'l'.

Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: I206a161107cf7510856ad8740dada88e12341e94
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 2affe46b2543f7d2de1939e049a0d783b5a7dcfb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-10 17:30:19 +00:00
Alexandru Croitor
7d0b4be42d CMake: Fix purl variant list iteration
The correct syntax is IN LISTS, not IN_LIST.

Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: Ibf64e48ffcf0b061887b7b015096d588b14bce57
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 4c5d9a3ca339f36f10922f9b1d5849fca1f2bdc4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-10 17:30:19 +00:00
Tor Arne Vestbø
b07580da56 macOS: Completely disable lldb backtraces in QtTestLib on Apple Silicon
They result in lldb hanging, which was previously only a case when SIP
was enabled, but can now be reproduced on macOS 15 even with SIP disabled.

 https://github.com/llvm/llvm-project/issues/53254

Pick-to: 6.8
Change-Id: Ifa09f8cf22522b5a1028db1f250ebe9e1543cf9d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 50d5914f28b535790f8eca6210adad24fe76940b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-10 14:49:26 +00:00
Tor Arne Vestbø
b04935ed9f macOS: Enable crash reporting for tests via Swift
Swift 5.9 includes built in crash reporting, printing stack traces,
libraries, and registers to stdout/err.

https://www.swift.org/blog/swift-5.9-backtraces/

As (Core)Foundation is written in Swift nowadays, we get this feature
for free even in our "C++" apps, as we always link to CoreFoundation.

To enable the feature the binary needs the com.apple.security.get-task-allow
entitlement, so we add it for all our tests automatically.

The final piece is to run the tests with SWIFT_BACKTRACE=enable=yes,
but we'll do this in our CI provisioning, as setting it from within
testlib doesn't seem to work.

Pick-to: 6.8
Change-Id: I31090efee06460f45522093e17f900e76590b282
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 9bebdc97f161cc58461530fa0171e0defc6cc1ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-10 14:49:24 +00:00
Ivan Solovev
0db648ba3b QMetaEnum::valueToKeys: fix REMOVED_SINCE version
Should be 6.9. The entries in removed_api.cpp are already added to the
correct place, just the macro in the public header used wrong version.

Amends d41b87e06742b491c4e36aeae32e03f85b078d69.

Change-Id: I88749dbeb070206c42feb4ffc504f260f8857823
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit da799c20d763b5534152dca52fef12fda875acc2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-10 14:17:26 +00:00
Ivan Solovev
5e84f22a0a [docs] Fix a typo in the QColorSpace class name
That prevented qdoc from generating the docs for the fromPrimaries()
function.

Amends bde2292247bf4849852355c0dcc71f97c9daace9.

Found in Qt 6.9 API review.

Change-Id: I2f5c57a4dc4a437798907c64fb657c9fda61e0df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit e2756158dcf87fea757475d711ac9cda20f42152)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-10 10:47:34 +00:00
Christian Ehrlicher
c74f0ccf15 QTreeView: fix Private::intersectedRect()
Don't try to update the left and right boundaries when no valid idxRect
was found.
Also fix the early exit check - we can exit when the idxRect is
completely below *or* completely above the current viewport.

This amends 2f9c72028d2481f587f378a256654d0a362e3d44.

Pick-to: 6.8
Fixes: QTBUG-132670
Task-number: QTBUG-124173
Change-Id: I51f9e12c66268318e597facfbe4df74367d1089a
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 9d4b5fa017199627a42477a842a4e1ef349bb1ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 23:20:17 +00:00
Alexandru Croitor
2220e447ca CMake: Fix file path in checksum computation to allow spaces
Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: Ica5f830e6d7ca9d8acbc13ebec543ee3cf96b3fe
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 242e29332373d91e1ffff344e1733bd38094606e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:47 +00:00
Alexandru Croitor
fafb4f11ef CMake: Use the $<VERSION> placeholder in qt_attribution.json
For all CPE and PURL fields where it makes sense, to avoid
duplication.

Pick-to: 6.8
Task-number: QTBUG-132181
Change-Id: Icd1c5267e4e9b582eea28150ebd1b2cca3852229
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 82dc92cb1b94de12761f23ad6ec27feb2aca43cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:41 +00:00
Alexandru Croitor
21815ae5e5 CMake: Replace placeholders in CPE and PURL strings in SBOMs
Replace instances of $<VERSION> in CPE and PURL strings read from
qt_attribution.json files with the version of the package being
processed.

This avoids duplicating the version in qt_attribution.json files in 3
different fields Version, CPE, and PURL.

Pick-to: 6.8
Task-number: QTBUG-132181
Change-Id: I91af17c82dbb936739f4811bf86043e00ee49a78
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit bc3bbb51b7b48d3c4a44a432441938863582242c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:34 +00:00
Alexandru Croitor
a32359a101 CMake: Add internal functions to get various kinds of spdx ids
These can be useful when adding custom relationships to the generated
SBOM document.

Sample usages could be:

qt_internal_sbom_get_target_spdx_id(Svg svg_spdx_id)
qt_internal_sbom_get_project_spdx_id(project_spdx_id)
qt_internal_sbom_get_external_document_ref_spdx_id(
    "qt5compat" document_ref_spdx_id)

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: Idbd5c8bffece50871f995805b619226e32957866
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 97ac4053137c7d0ff5ec71de22cf8c0c7af7006a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:28 +00:00
Alexandru Croitor
97775f43a1 CMake: Add way to convert JSON SPDX to tag/value SPDX document
Add a new qt_internal_sbom_generate_tag_value_spdx_document function
that takes an input SPDX JSON file and generates a tag/value SPDX
file. This is needed by WebEngine to convert the Chromium JSON file to
a tag/value SPDX file so we can reference it as an external document.

To ensure the external document is found, we now always add the
current sbom build directories as install prefixes. This was
previously done only for top-level builds.

To ensure the converted external document is referenced only after it
is converted, it needs to be converted before any targets mention
packages from within it.

A sample usage might be:

qt_internal_sbom_generate_tag_value_spdx_document(
    OPERATION_ID qt5compat
    INPUT_JSON_FILE_PATH "${external_sbom_file_path}"
    OUT_VAR_OUTPUT_FILE_NAME external_output_file_name
    OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH external_output_file_path
)

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I5d5397f788c8c7960b6fc233c2868244e5816e0b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit b8f5e5f554c0c8b340b532b998fed5ef2a87eefd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:21 +00:00
Alexandru Croitor
5a878ca693 CMake: Allow adding custom SBOM relationships to targets and projects
Add a new SBOM_RELATIONSHIPS option to qt_internal_extend_target and
friends that allows adding custom relationships to the current target.

Add a new function qt_internal_sbom_add_project_relationship that
allows adding custom relationships to the current project SBOM
document.

A sample usage might be:

qt_internal_sbom_get_project_spdx_id(project_spdx_id)
qt_internal_sbom_get_target_spdx_id(Svg svg_spdx_id)

qt_internal_extend_target(Svg
    SBOM_RELATIONSHIPS
        "${svg_spdx_id} DESCENDANT_OF ${project_spdx_id}"
)

qt_internal_sbom_add_project_relationship(
    RELATIONSHIPS
        "${svg_spdx_id} CONTAINS NOASSERTION"
        "${svg_spdx_id} DESCRIBES NOASSERTION"
        "${project_spdx_id} DESCRIBES NOASSERTION"
)

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: Ie0119ca71b047c7515e1deaf84a5a67ea01b5274
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit d079fdd76cf3f44181c6099b845ba9b41892740e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:15 +00:00
Alexandru Croitor
a33ce2a2ca CMake: Fix project spdx id used in implicit relationships
We shouldn't be using the direct project name in spdx relationships,
but rather the sanitized name which is prefixed with
'SPDXRef-Package-', to ensure sbom validation succeeds.

Also we should default PROJECT_FOR_SPDX_ID to
"Package-${arg_PROJECT}" if it's not set.

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I354babcf4fea5f6efd9b32422dd8d3835ef50f15
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit f086e72b7e6332412a7c87bc435398a0e3dee305)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:08 +00:00
Alexandru Croitor
31237ffd5f CMake: Add API to allow referencing external packages in the SPDX SBOM
This change modifies the existing implementation of the
external references API to have better named options and better
behavior.
It also adds comments and exposes an internal API wrapper around the
existing implementation.
It's meant to be used by qtwebengine to reference the
Chromium-generated SBOM.

As a drive-by, it removes the previously unused RENAME option.

A sample usage could be:

qt_internal_sbom_get_external_document_ref_spdx_id(
    "qt5compat" document_ref_spdx_id)
qt_internal_sbom_add_external_reference(
    EXTERNAL_DOCUMENT_FILE_PATH "/path/to/qt5compat-6.8.1.spdx.json"
    EXTERNAL_DOCUMENT_SPDX_ID "${document_ref_spdx_id}"
)

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I13d0fe4d803449bec42f8b454c8131e4d727669a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Moss Heim <moss.heim@qt.io>
(cherry picked from commit 9a3998692c10964a919942147d8d8035e878b167)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:34:01 +00:00
Alexandru Croitor
419979e0dc CMake: Add API to include custom cmake files during SBOM generation
Allow including custom cmake files at predefined steps of the sbom
generation using the new internal
qt_internal_sbom_add_cmake_include_step API.

This covers pre-existing steps like BEGIN, END, POST_GENERATION, and
VERIFY, as well as two new steps, BEFORE_CHECKSUM and AFTER_CHECKSUM.

A sample usage of the new API could be:

set(step_path "${CMAKE_CURRENT_BINARY_DIR}/run_some_cmake.cmake")
file(WRITE "${step_path}"
    "
    # This is a CMake script to run some CMake code.
    message(STATUS \"Running some CMake code...\")
    message(STATUS \"Done running some CMake code.\")
    "
)

foreach(step IN ITEMS BEGIN END BEFORE_CHECKSUM
                      AFTER_CHECKSUM POST_GENERATION VERIFY)
    qt_internal_sbom_add_cmake_include_step(
        STEP "${step}"
        INCLUDE_PATH "${step_path}"
    )
endforeach()

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I6f9512bf3a3bc3ebeb7d21426e5a3833280e42a5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 8c754dcbb139ba83f033b3b3fc1d9edb8a909811)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:33:55 +00:00
Alexandru Croitor
6ed0b578a8 CMake: Add SBOM support for translations, custom files and friends
This change introduces a new SBOM API to add info about various kinds
of files to a target SBOM package. The new function name is called
qt_internal_sbom_add_files().

The motivating case is including SBOM information for qt translation
files, resources (e.g. webengine data files) and any other kind of
custom files.

A sample call might look like:

qt_internal_sbom_add_files(Translations
    FILES "${qm_files}"
    SOURCE_FILES_ONE_PER_INPUT_FILE "${ts_files}"
    FILE_TYPE "QT_TRANSLATION"
    INSTALL_PATH "${INSTALL_TRANSLATIONSDIR}"
)

While the motivating case is Qt-specific, the function implementation
is being somewhat future proofed for the not-yet created public SBOM
API.

The new API supports adding files to any target that is backed by an
SBOM package, so all targets created by qt_internal_add_module()
and friends, as well as ones created by qt_internal_add_sbom().

It can be called multiple times for the same target, with a different
set of files, to e.g. assign a different license, or file type per
file set. Note that the file set doesn't have anything to do with
CMake's concept of file sets.
The function is also multi-config aware, and allows specifying
different install paths per config, as well as generator expressions
in file names. But the multi-config support is a bit wonky, and might
need some rethinking in the future.

Note that the custom files must be installed and available in the
specified qt install path, because the file contents will be
checksummed at install time and embedded into the sbom document.
Calling the new API does not do installation itself.

Implementation wise, the function call flow is
- project calls qt_internal_sbom_add_files() one or more times
- at finalization time, the _qt_internal_sbom_add_target finalizer is
  called for a target, which then calls
  _qt_internal_sbom_handle_target_custom_files()
- the latter calls _qt_internal_sbom_handle_target_custom_file_set()
  for each file set that was added to the target
- the latter calls _qt_internal_sbom_handle_multi_config_custom_file()
  for each input file in the file set, which ultimately calls
  _qt_internal_sbom_add_custom_file()

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-128320
Change-Id: Iafde26ebd68f4168b49e55fbc8ad1c251e98d4b0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit b085fe6ad9eee69791bc3c15bfeb7cc41245519a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:33:48 +00:00
Alexandru Croitor
04c3e5e5a7 CMake: Remove SBOM multi-config dead code
These variables were not used anywhere.

Pick-to: 6.8
Task-number: QTBUG-128893
Task-number: QTBUG-122899
Change-Id: If53b3fd8200971dcfde69cefa4df07b67d5669c5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 42a58d661947cbbe8c1c5f26cea2d92e25a54f46)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:33:41 +00:00
Alexandru Croitor
6e74281ba3 CMake: Move SBOM project ops setup to run at project begin time
Previously Python and other sbom tooling was looked up at SBOM
project end time.
This was fine for the use cases we had so far, but it prevents
introducing new API that wants call the spdx tools before the end of
the project. Such API will be introduced in a follow up change.

Move the python interpreter, python dependency lookup and other sbom
tooling setup to happen at project begin time.

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: Ic8884e378c0ffd9720ede26b0c61f4122f3bb9d9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 2fa815341c68148ff00c6d16be017f80e4032ef1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 18:33:35 +00:00
Alexey Edelev
df5c9259af Split the tool dendencies lookup to Qt and 3rd party
Tool dependencies that are added using the
qt_record_extra_package_dependency function now are considered as
the third party dependencies. This allows using two different
approaches when looking for the dependencies of Qt tools.

All dependencies that are Qt tools now go to the path invented in
035fbd068b5a3fbc18b7868ecac9a6a6a2f6602c and use the
_qt_internal_find_tool_dependencies function which is designed to
look for Qt packages and uses CONFIG signature of find_package.

To look for the non-Qt modules we should use more generic find_package
signature and _qt_internal_find_third_party_dependencies fits perfecly
for these purpose.

Note that it's known issue that the
_qt_internal_find_third_party_dependencies command also may find
"target" tools when crosscompiling, but this commmit doesn't reinvent
it. We already have various places which make the scoped "host"
dependencies lookups to ensure that "host" tools look for the "host"
dependencies in build systems like yocto.

Ammends 035fbd068b5a3fbc18b7868ecac9a6a6a2f6602c

Task-number: QTBUG-132340
Fixes: QTBUG-132622
Fixes: QTBUG-132616
Pick-to: 6.8 6.5
Change-Id: I9effba3d405ceec720a8a2a332250619cd56f598
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit f881e06dd44c377772dd3b99793ab7552c7cd64e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 10:58:45 +00:00
Even Oscar Andersen
887601bf0e Make QWasmScreen::allWindows return all (wasm) windows
It seems that findChildren does not return every window if called
at an inconvenient time.

This causes not all windows to be returned, and later the
QWasmCompositor will not detect a valid window to compose,
and therefor goes to disabled.

Fixes: QTBUG-132414
Change-Id: I6c872071751d5a2fbdeea36fb8f4c7e9677fd7d0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 5c5844cedb938c38ea595957b172c48a67c502fc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 05:56:51 +00:00
Joerg Bornemann
83cb2ca344 CMake: Simplify Qt6FooPrivate -> Qt6Foo package dependency setup
This amends commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f.

Remove the EXTRA_PACKAGE_DEPENDENCIES argument that was added in
mentioned commit, and use the qt_register_target_dependencies function
instead to add the package dependency Qt6FooPrivate -> Qt6Foo.

Task-number: QTBUG-87776
Change-Id: I08a48954576dc3c0b6fde809f90d2022201d7eb0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 2d38af3125d18255007f7451f31e26e9c16af45a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 00:51:20 +00:00
Volker Hilsheimer
58113ca96e QFontIconEngine: implement actualSize correctly and fit pixmap to it
Some icon glyphs might not be square, and actualSize needs to return a
size that fits into, and maintains the aspect ratio of, the requested
size.

Compute the bounding rect of the text/glyph that would be rendered, and
scale it to fit into the requested size.

Use that to return a pixmap of the correct size.

As a drive-by, fix the cache-testing by comparing the
deviceIndependentSize of the stored pixmap with the size we want.

Change-Id: Ic6fd0f0e260b3e3946d032941d9b677463d5c145
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit be9682d372e0021ff112817dc146f5768ac6f28c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-09 00:51:20 +00:00
Marc Mutz
96c5792d5b QUuid: mark Version::UnixEpoch as since 6.9
... because it is.

Amends d89cef439f5c1a58aeff879a12d9a33292764b7f.

Change-Id: I82cfb386c058a0dda873022377ec91368c71e026
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4af8a20e8e0384d3de4af6c2b47a0783ba28bbc3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:27:36 +00:00
Volker Hilsheimer
59420d3a0b JNI: avoid detach attempt when populating an uninitialized QString
QString::data on a non-const string will needlessly try to detach.
Avoid that by accessing the raw data pointer.

Addresses header review comment.

Change-Id: I89b4d3451cda517e5c5ca08173510b3529ce73aa
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit bf2491acc74528004af8d5f4caf50e88fcb86f89)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:08 +00:00
Volker Hilsheimer
30e7ce0fc1 JNI: add missing qxptype_traits.h include to qjniobject.h
We use qxp::is_detected_v. Addresses header review comment.

Change-Id: I57bb2bb2158d82e2cd5e6df5885cde8aedb63b4f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 611914421d8dae7546842aa5097000ed135117db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:08 +00:00
Volker Hilsheimer
1ed487f1ac JNI: Simplify Traits specialization for QJniArrayMutableValueRef<T>
Just inherit from Traits<T>. Addresses header review comment.

Change-Id: If11df666a925a13e54e94b30e42316a6aa06bbc7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit c5c3730400d0f7bb1f1b93117f8ad5c1262ed695)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:07 +00:00
Joerg Bornemann
a090ecbdd1 CMake: Don't export 3rdparty dependency find_package calls
...of private modules in public modules. This isn't necessary anymore
since the Qt6FooPrivateDependencies.cmake files contain these 3rdparty
dependencies proper.

This reverts commit dae078e521c3932c66436cbdbfaf5294a1842901.
This amends commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f.

Task-number: QTBUG-87776
Change-Id: I2c425d49fe7beb790abf9a94f089d43fde8b047e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit e7816586b612050adf0cd872b81d04b606ec2b54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:07 +00:00
Volker Hilsheimer
087db1d000 JNI: fix declaration of QJniArray(Mutable)Iterator postfix operators
As per the standard at [1], the second parameter has to be int, while
difference_type is jint (which is also int, so no difference in
practice, esp for the already released QJniArrayIterator).

https://eel.is/c++draft/over.oper#over.inc-1.sentence-3

Addresses API review comment.

Change-Id: Idea11f83048b9b65548ec1ac8abc2586c6e61a27
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 291c5ec433131d43921e77f3b6565e89cc0b3420)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:07 +00:00
Ivan Solovev
b18c3ecdbd [docs] Add description of other C++20 features to the overview
Task-number: QTBUG-128837
Pick-to: 6.8
Change-Id: I07731cd75c97c16eb008a76727b2ae831c029284
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
(cherry picked from commit 82f6938d8ad66468576c52da7d85a2288f78af7e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:07 +00:00
Topi Reinio
85088954de Third party code attribution: Change Id to lower case
Each 3rd party license attribution is identified by a
unique Id key, which should be all lower case and without
spaces. See QUIP-7 for more info. about the
qt_attribution.json file format:
https://contribute.qt-project.org/quips/7.

Pick-to: 6.8
Change-Id: Iaa233a0e6180945e014b9a407bbd61df591f1dea
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
(cherry picked from commit 1926df8d57c2b6c600a5486b1939d96b21f7f812)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 20:22:06 +00:00
Alexandru Croitor
fa8effc7da Silence qcompare.h "zero as null pointer constant" warnings on macOS
When using qmake to build a user project on macOS, the Qt headers are
included with the -I option, rather than the -isystem option. This
means that the compiler will not silence warnings that are generated
while parsing Qt headers.

If the user project compiles their code with the
-Wzero-as-null-pointer-constant compiler option, this leads to
warnings like:

/QtCore.framework/Headers/qcompare.h:226:78:
 warning: zero as null pointer constant
     [-Wzero-as-null-pointer-constant]
  friend constexpr bool is_eq  (partial_ordering o) noexcept
  { return o == 0; }
                ^
                nullptr

Fixing qmake to use -isystem instead of -I is not trivial.
We already silence these warnings for gcc in the header file.
Do it for clang as well.

Amends bdd41f491c0f85ae0897a1c7372c5ecda62a5aab

Pick-to: 6.8
Fixes: QTBUG-132581
Change-Id: I7883248b7be548580a03333e76620ac10f57733a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 0711eb60716b53dc86cacb2fc19b72aa4ffee3d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 17:23:58 +00:00
Ahmad Samir
69277b9ed9 tst_Q{Chrono,}Timer: fix typo in CMakelists.txt
Spotted by Thiago in code review.

Amends bd764cc1ca578759f16fbe292fbe14a243b7d263 and
9cf47946fc872ed95f1b3a766658dd5076a5d473.

Pick-to: 6.8
Change-Id: I01b04d2c80c62158917e6f190418053edc0a0fe5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4073a75959e00722271b8784cb8cb2ee40756ff6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 16:57:15 +00:00
Volker Hilsheimer
103aa5afb2 JNI: replace va_arg helper with variadic template
Android 15 (at least) seems to have changed how float arguments are
passed to native functions, breaking our (conceptually correct) code for
processing the va_arg list into a list of static argument types of the
function implementation.

To fix this, we have to move away from using a va_arg function, and
register a function with statically typed arguments instead.

Use a template function that we instantiate with variadic arguments
deduced from the actual function, using a factory-helper that generates
a JNINativeMethod struct with that template instantiation as the
function pointer. Move all of that into a struct where we can also
declare the signature string as compile-time constant without cluttering
the namespace with static objects.

We can now remove the helpers that took care of type promotion in va_arg
functions, and of the tuple-construction from a va_list.

As a drive-by, don't cast function pointers to void *; it's strictly
speaking undefined behavior in C and should have generated a compiler
warning, if not a hard error [1]. We must initialize the
JNINativeMethod::fnPtr member with the address of the function pointer
instead.

[1] https://port70.net/~nsz/c/c11/n1570.html#6.3.2.3p8

Also, declare the native method as the JNICALL calling convention. That
is only defined on Windows, so makes no difference in practice, but it's
the correct thing to do anyway.

Fixes: QTBUG-132410
Pick-to: 6.8
Change-Id: I190b95fcbcd07cf99c6765fa426c3c351f91994a
Reviewed-by: Volker Krause <vkrause@kde.org>
(cherry picked from commit e91a17873ee4ae58d369b8eb70029cf895b31d03)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 03:05:46 +00:00
Christian Ehrlicher
37effa5dd3 Windows11Style: Misc cleanup for drawControl(CE_ItemViewItem)
Cleanup CE_ItemViewItem branch in drawControl():
 - use local rect instead rect, vopt->rect or option->rect for
   consistency
 - move out viewItemPosition comparisons into local booleans
 - fix coding style
 - merge two QPainter::drawLine() calls into one

Pick-to: 6.8
Task-number: QTBUG-131585
Change-Id: I7cd2f96a2a733a55d5e7fb5956c59bd043317cb2
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
(cherry picked from commit 44edab7c84be101025dc6f9a74f87944ea3a22e9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 03:05:43 +00:00
Giuseppe D'Angelo
1426bd170b QBitmap: undeprecate the QBitmap(QSize) constructor
There is no reason why the QBitmap(int w,int h) constructor is not
deprecated, and the one taking a QSize is. Since there's no deprecation
marker in the source code, I'm assuming this is just a documentation
issue.

Amends 111115bf8862b7cd1197c2ef8a4b475c882776d4.

Change-Id: I700de1821ab23ce85e793734c7048d1b2031ce9d
Pick-to: 6.8 6.5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7f7605c22f0e1847612e9e283eead75a1ace409e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 03:05:41 +00:00
Volker Krause
e342a52613 Expand tst_qjniobject to cover float arguments in JNI native methods
Demonstrates the problem described in the bug report on Android
15/x86_64. QEXPECT_FAIL the relevant test cases until the next
commit fixes the problem.

Task-number: QTBUG-132410
Pick-to: 6.8
Change-Id: I065fd29282ef42ed75a2ed8177ded183c92aa6e3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 749367da8c3309c98b3285836c2bd8abcd7274b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 03:05:40 +00:00
Axel Spoerl
8b7bf25f7f QtGuiTest namespace: Export symbols
Export functions in the namespace explicitly, to enable usage outside
Qt.

Change-Id: I1d3ea8f043b83cc38a9c6f4ff372e7bb37f2b0cc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 31e1a79120e1ef9b681b45b2d2c3a7dfef752b8b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 03:05:37 +00:00
Volker Hilsheimer
6a6ce2474e JNI: fix JNI warning from local reference mixup
When making an object array, we use a LocalFrame to get access to the
conversion routine, but manage the frame of local references manually in
chunks of 100 objects. If any of the conversion routines uses the
LocalFrame's implicit frame management, then we push and pop frames out
of order.

Disable the frame's implicit frame management, and only use our chunk
management.

Amends 37638c84efaf2810ad49da0b987f19287d8c4ad6.

Pick-to: 6.8
Change-Id: I93be77ffc8750bb90fd7daed8c273169b03a29e4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit fe6222b7561faa52f12a961d7c5417e364cf0236)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 03:05:35 +00:00
Thiago Macieira
b39b3551b7 QStandardPaths: use qTokenizer
Avoids allocating memory for the array.

Change-Id: I425235b948609e5f0ffcfffd0f93375a224e5bcb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 403a47cfd571c9954e91234084c6994901939326)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 02:49:40 +00:00
Shawn Rutledge
96fe113608 doc: Fix description of QSizeF::fromCGSize
Change-Id: I22c3c5a50d624dc1f6a46aa5f1630c08267c4925
Pick-to: 6.8 6.5 5.15
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 9d6614d74cda8eae886f72a688271cdcd3ddcddd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 02:49:40 +00:00
Thiago Macieira
875ccc41f4 tst_QSaveFile: add a test for attempting to overwrite a dir
This is not the same as the 'directory' test below, which tests that we
can't open() a QSaveFile on something that already is a directory. For
this one, the target file did not exist when we open()ed, but has become
a directory since then.

Change-Id: I92d13f103693d375e742fffdd74053dd1b86d81f
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit f4ff7c40588a4515504e22266d15816ca8616cba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 02:49:40 +00:00
Thiago Macieira
765aa27aa3 QMessagePattern: "precompile" the default pattern
So we don't have to parse it on first use if it isn't set. This should
be a small performance gain for everyone who uses the default, which is
usually the majority of people.

Change-Id: I10c471715457dcfa3a1dfffd2768ce605e4f7e30
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit e04f109456bbcb184963b8ed71944b958b35c201)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-08 02:49:39 +00:00
Mårten Nordheim
9a1edf52d4 tst_Http2: Test SETTINGS_HEADER_TABLE_SIZE handling
This somewhat duplicates some other tests, namely the QHttp2Connection
one, but tst_http2 is our only coverage of the HTTP/2 code prior to 6.8.

This change adds a test where the server sets the
SETTINGS_HEADER_TABLE_SIZE to 0, effectively disabling the dynamic
table. We, in an earlier patch, makes the HPack table error out if
a new header entry is about to be added if the table has not been
resized below a changed 'max'. So, we take advantage of that here and
set the new 'max' capacity without resizing the table, or updating
dynamic capacity causing it to fail if the client doesn't send the
expected Dynamic Table Size Update.

Task-number: QTBUG-132277
Pick-to: 6.8 6.5
Change-Id: I1ca8ca7828d5b83606e7adbcfc13c154fa1e3cab
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit f7c3acd27ff48b24f99086be206acbe7e00e3208)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:06 +00:00
Assam Boudjelthia
aae66d7518 Android: fix warnings about Class raw type usage
Using Class<?> fixes the warning.

Pick-to: 6.8
Change-Id: Ia65aa78509c41d041970631dc21c8dd72459e674
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit f342f27a0cc6c82f9503c0002b6fd32cb3ada3c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:06 +00:00
Jøger Hansegård
11abd87046 Implement QUniqueHandle move assignment using MOVE_AND_SWAP macro
This removes boilerplate and the extra complication of std::addressof.

Task-number: QTBUG-132507
Pick-to: 6.8
Change-Id: I07091ec0ac526975cf55361a9811fad77eb152c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 30ae70a110ee2460744e4fb78bae29b75effbf72)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:06 +00:00
Assam Boudjelthia
a892eb50d3 Android: add android test runner docs to the build
Amends 5735d7ac861fe99a71d8044977e5f487c401ca12.

Pick-to: 6.8
Task-number: QTBUG-84330
Change-Id: Ie78f88cf84376c08e44d887b09d116845882788b
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
(cherry picked from commit 1fb369211e3e477de8531485a33241d5d99b7a21)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:06 +00:00
Assam Boudjelthia
e3feb85abc Android: pass safe area margins to relevant windows only
Instead of passing the safe area margins to all windows
or top windows, we can instead call the listener for
setOnApplyWindowInsetsListener() on specific QtWindow
and have it pass the windowId with the callback to C++.
What was missing before was that the listner was not reset
after removing the window and also, we don't need to
necessarily require a window matching the id to be found,
so that if no window is found we can assume that the callback
is not valid.

Task-number: QTBUG-131519
Change-Id: Idd411e407ac8f5992aa6684ece70329198de1bc2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit d7860d445d462dae853358c8b956fa6b1b6a2fc7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:06 +00:00
Jøger Hansegård
bded4bd5fc Require that the handle type used with QUniqueHandle is quite noexcept
QUniqueHandle is intended for handle types or opaque pointers that are
no-throw constructible, copyable, and assignable, and has nothrow
comparison and relation operators. This patch ensures that this holds
true, and makes most of the QUniqueHandle noexcept specifiers valid.

This will make it easier to implement the comparison and relation
operators in terms of the Qt comparison framework.

Task-number: QTBUG-132507
Pick-to: 6.8
Change-Id: Id9fc3fac72a2337541e49c3b4613b8fd082796af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 49f1877bbbb8f96d81144861558bdcc81e758a58)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:06 +00:00
Mårten Nordheim
55dc2af21d QHttp2Connection: Fix handling of MAX_HEADER_TABLE_SIZE setting
We need to, following the RFC, send a Dynamic Table Size Update using
HPack once we have acknowledged the setting as long as the new size is
smaller, or if we decide to use the new, larger size.

It's further complicated by the fact that we need to send this update on
the next 'field block' (anything with headers in it), and we may have
multiple SETTING frames come in, and we need to then acknowledge the
_smallest_ one as well as the _final_ one. This is so the decoder on the
peer's side can know that we have set the smallest size, and trimmed our
tables thusly, before going to the larger size.

This could, for example, be used to clear the table.

Task-number: QTBUG-132277
Pick-to: 6.8
Change-Id: I2b886e125f2c197bc3d42aa0b2bbd308ed2a687c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 57f44d6d882e09f1560f86816fac6ca8d06264fc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 22:33:05 +00:00
Peter Kling
40608d0a37 CMake: fix absolute paths w/o suffix in pri/prl files
In the update from 6.7.2 to 6.7.3, commit `ea0f00d5d` changed how linker
flags like `ws2_32` are treated when generating pri/prl files.
Specifically, before the commit a flag like `ws2_32` was left
untouched. The above commit changed it such that such flags are
converted to `-lws2_32` (seemingly in order to better support FFmpeg,
according to the commit message). However, this change also affects
absolute paths if the file has no extension. That is, after the above
mentioned commit, an absolute path linker flag to, say, a dylib on macOS
without a suffix will result in prepending the `-l` flag. This will
result in errors during link time.

An example where this caused problems can be found in the nixpkgs PR
draft #367206 (https://github.com/NixOS/nixpkgs/pull/367206).

This adds a small check to ensure that `-l` is not prepended if the
linker flag is an absolute path without a suffix.

Change-Id: I2c7ce3aac6624e1a27c59af233e3da2c1ae7ba60
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 714ae22b84553271a2809c393dd1a5a90089cc19)
2025-01-07 18:14:42 +00:00
Tor Arne Vestbø
b5c3a3fe73 Add change-notification signal to QInputDevice::capabilities property
On some platforms the capabilities of a device can change at runtime,
and we don't want to model this as a "new device" appearing in place
of the old one.

We already made the capabilities property non-CONSTANT, but let's add
a NOTIFY as well for completeness.

I considered making the capabilities member protected, but
QXcbConnection's xi2 handling relies on modifying the caps
as part of creating the device.

Fixes: QTBUG-132281
Change-Id: Ic345475b179f4562cdd39ecf51c7d6738ad47a74
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit d74079873bbbff8701ec9b254647624775ced27a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:09 +00:00
Marc Mutz
79bd27a82b CompactContinuation: make sure what is being deleted by runObj
A lambda creates a struct with a function-call operator. So use of
'this' in a lambda body is always a bit ambiguous (the outer object?
Or the lambda itself? even though C++ defines it unabiguously to the
former).

Use a named capture variable instead of 'this' to make it obvious what
is being deleted.

Amends 699162c6fa6121cc496338f1d8d6e1b4287f7760.

Change-Id: I48d82d788d495bac43c6adb114dfdd95a8dd0d1f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 21811161c9109c28da70b7bb9b28df33fa9b7766)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:09 +00:00
David Faure
2a121a9506 Fix wrong value for 'noon' in tst_bench_qdatetime
12 hours corresponds to 43,200 seconds, not 43,200 milliseconds.
Amends commit 3febcd6286a3cd22db4f294e7f31a94c07c51fb0

Pick-to: 6.8 6.5
Change-Id: I2eb3abcab18cd87d51ae70b5fbaeac71a8fcd0a8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 0e2656f9371f92db3bb95ee5ba52c44a91e5ce68)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:09 +00:00
Marc Mutz
1b09c46051 CompactContinuation: make type member const
Because it can be.

Helps readers understand that the type of a continuation doesn't
change once constructed.

Amends 699162c6fa6121cc496338f1d8d6e1b4287f7760.

Change-Id: I43848204cfd8584e6e55d7fbca1b22d30b391e50
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 9dadca4d4e6058299f9d50ae28fd734717d7fdc5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:09 +00:00
Christian Ehrlicher
bf535c4c66 Windows11 style: fix drawing horizontal progressbar in rtl mode
The progressbar content calculation assumes that
subElementRect(SE_ProgressBarContents) returns a rect at 0/0 which is
not the case for progressbars in rtl mode. Fix it by moving the topLeft
edge to 0/0 and translating the painter accordingly

Pick-to: 6.8
Task-number: QTBUG-132459
Change-Id: I614589c9094b0da3c02867b45570d4dfdca61a18
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 314a5b972646a4f2ef9c1f49ddfd335f546336ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:09 +00:00
Christian Ehrlicher
5ff8c2eb00 Windows11Style: enable mouse tracking for QTableView
Mouse tracking is needed for windows 11 style since it is using
QStyle::State_MouseOver to draw the cells.

Pick-to: 6.8
Fixes: QTBUG-129242
Change-Id: Ib79ac5a8c14ac8c70365e87120f80b4e4ee4c5b9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 85333b3d8cb89bf58c6c6c0db7c3db5c95b4cbfc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:08 +00:00
Volker Hilsheimer
11b9657b08 JNI: don't access null jobject
When Java calls a native function that expects a QString with a null
String object, then we get a nullptr jstring. We must not try to convert
that to a QString.

Add the necessary checks at the call-site of the toQString helper, and
an assert to the helper itself. Add test case.

Change-Id: If5c55c702bdb3f89ac45fdf3912af2ac295f5e5c
Reviewed-by: Volker Krause <vkrause@kde.org>
(cherry picked from commit db6a9834d2b109e81cc73ef3c64d0c420237e9dc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 13:17:08 +00:00
Thiago Macieira
6dc19b55fc QThread/Unix: revert to pthread destruction instead of thread_local
Amends 65093a84c2b94b1543fd4593bc45d491951d28d4, which changed how we
destroyed the main thread's QThreadData. This merges the call to
destroy_current_thread_data() for both types of Unix systems: those with
broken thread_local destructors and those with working ones. It turns
out that the function got called too early for us in those working
systems (see updated comment).

The clean up of the QThreadData is split into two different mechanisms:
 * for any auxiliary thread, when it exits, PThread will call back to
   destroy_current_thread_data()
 * for the thread that called ::exit(), PThread won't, but ::exit() will
   invoke set_thread_data()::TlsKey's destructor

This is different from the situation that existed prior to commit
65093a84c2b94b1543fd4593bc45d491951d28d4: first, there's no code in
qcoreapplication.cpp for this (all in qthread_unix.cpp). Second one may
call ::exit() from any thread, whether that is the thread that called
main(), the thread Qt thinks is theMainThread, or any other.

This commit moves the tst_QCoreApplication check for no extant objects
to a new test. I've chosen to add a new test instead of running a helper
binary via QProcess because we do have a couple of !QT_CONFIG(process)
platforms in the CI, and this is too important.

Credit to OSS-Fuzz for finding this, though it is not itself a fuzzying
problem (all tests of a given structure were crashing on exit).

Fixes: QTBUG-132381
Task-number: QTBUG-130895
Task-number: QTBUG-129927
Task-number: QTBUG-129846
Task-number: QTBUG-130341
Task-number: QTBUG-117996
Pick-to: 6.8
Change-Id: Ie294dce7263b4189f89ffffd9155ec71d31b89d9
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 03:46:12 +00:00
Thiago Macieira
60eaa42a25 Revert "Add categorized logging of delete later machinery"
This reverts commit c3a2b9f35a9a12ff3c6f5f0d11844de161b47c2a.

Unfortunately, some of the log messages happen WAY too late at process
exit time, when QtCore is unloading. In particular, the worst offender
is the one in QThreadPrivate::finish(), which is called after the last
QObject in the thread that called ::exit() was getting destroyed. This
implies we have Static (De)Initialization Order Fiascos happening (the
logging recurses into qlocale.cpp and the defaultLocalePrivate global
static has already been destroyed).

I need to revert this commit in order to fix QThreadData destruction.
The functionality is welcome back in QtCore once the fixes are in, so
long as whoever does it fixes the issues we're seeing in the CI (and I
can't reproduce on my development machine). I've created QTBUG-132429 to
track the reversal and see if the functionality can be brought back in.

Task-number: QTBUG-120124
Task-number: QTBUG-132429
Pick-to: 6.8
Change-Id: Iecf8f14529c7a2bb2185fffdfd328066098826b1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 357351b7ab8ab2eee865d2449ffcca9c9f502fd3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-07 03:46:07 +00:00
Friedemann Kleint
7f78908b44 Mime type browser example: Add translator loader code
Enable testing translations.

Task-number: QTBUG-127004
Pick-to: 6.8
Change-Id: Ie83092b4db5bcf516834cf0b5b564a67d7ab6227
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 8778a493606c8733d72db1c09fff5e4bf1f13cc0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 18:08:10 +00:00
Mate Barany
9413c19cc1 Update CLDR to v46
New languages added with v46
- Kara-Kalpak
- Swampy Cree

Several new Chinese-language locales have been added, including one
using Latin script, which invalidated some prior QLocale tests, which
have been adjusted to fit.

Some obsolete time-zone identifiers are now treated as deprecated
aliases. These have lost their AnyTerritory association, implying
changes to QTimeZone tests.

Many redundant likely sub-tag rules for unspecified language have been
dropped, in favor of simpler rules.

[ChangeLog][Third-Party Code] Updated CLDR data, used by QLocale, to
v46.

Task-number: QTBUG-130877
Pick-to: 6.8
Change-Id: I92cf210422c7759dd829a7ca2f845d20e263d25b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit e316276b76b9c3768ca4e19a04d03308ef21fe12)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 17:56:36 +00:00
Mårten Nordheim
2101e91465 HPack: test and fix Dynamic Table Size Update
Expose some new API to make it easier to test too.
Will be used in follow-up patches for a http2 bugfix.

The setMaxDynamicTableSize() method no longer sets capacity or evicts
entries. This can then be used to set the new maximum size which we will
accept later when we receive a Dynamic Table Size Update.

This flow makes sense with both encoder and decoder. The decoder would
usually be set by us when we send our SETTINGS frame, and then the
Dynamic Table Size Update would be sent by the peer.
For the encoder we would set the maximum size when we receive the
SETTINGS frame, and then we must defer the actual resizing until we
can send the Dynamic Table Size Update ourselves, usually along with the
next HEADERS frame.

Pick-to: 6.8 6.5
Task-number: QTBUG-132277
Change-Id: I959f5006eb09427d130735efe136da8c04453fa2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit be477819ac17850632bca6ce59ee2c8ef11191cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 17:56:33 +00:00
Jan Moeller
a306131977 Check for valid QAccessibleInterface before invoking action
To avoid illegal access, the change ensures that the QAccessibleInterface
is non-null and valid before accessing its QAccessibleActionInterface.

The check for the validity was also added to existing code which
previously only checked for the QAccessibleInterface not being null.

Fixes: QTBUG-132059
Pick-to: 6.8
Change-Id: I69fc4f9bb052ded8f188032d324666d0c00b9c3c
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 279c891ddf0ad10dd86c8fc836ce385df57593c4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 17:44:48 +00:00
Morteza Jamshidi
59861df8ce Draw icon overlay manually instead of relying on the api
Even with SHGSI_LINKOVERLAY flag set, loaded Icon with
SHDefExtractIcon doesn't have any overlay, so we draw
it manually.

Pick-to: 6.8
Fixes: QTBUG-131843
Change-Id: Iae4c2da12104a361b9a8cf05c78adcdb698f1f82
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit fd7bc16e9fbdc63bd22ba90d0c20b36ccffd2bae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 17:44:48 +00:00
Richard Moe Gustavsen
9db6df1a56 iOS: remove registered undo/redo actions upon qiostextresponder dealloc
QIOSTextResponder add actions to its own NSUndoManager. But
we need to remove those actions again when the responder is
deallocated, otherwise it can lead to a crash in UIKit when
swiping between apps.

Fixes: QTBUG-123843
Pick-to: 6.8 6.5 6.2
Change-Id: I404751bc50692a960e568ff2eb0f1754da0cec31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 42f29da7a5b6c6969c169e9a868696a968ca930d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 17:44:48 +00:00
Morteza Jamshidi
6d8afaac84 Windows: Add Key_Backtab as possible key combination for Shift+Tab
In windows Backtab key event always comes as "Shift+Backtab".
So in order for Backtab key to be recognized as a shortcut sequence,
we also consider Backtab without shift modifier a possibility.

Fixes: QTBUG-94890
Change-Id: I20a7b404b57d8df5bea23765257a178f2e098ed0
Pick-to: 6.8
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 4d9f99c4ea70cdae58c80e1bfdbabefe3abb455f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 17:09:27 +00:00
Jøger Hansegård
64c5043a40 Add missing noexcept specifiers for QUniqueHandle handle traits
Handle traits should be simple, and not require exceptions. Note that
we should not make calls to fclose() or close() noexcept, because these
are POSIX cancellation points.

Pick-to: 6.8
Change-Id: I8bbf573b1346eafd52c6080dbb024f8b3bc89359
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit a80d1bf2716b1ba404799d6a09003b145b73b079)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 14:03:25 +00:00
Kaloyan Chehlarski
0ce8e1db2b Fixup minimum MSVC version check when configuring Qt
The message displayed to the user says they need "at least Visual Studio
2019", but in reality the minimum is now 2022.

Amends 9a409295c7cfe74b4fb6b1892f4ff86d4f3c23f3

Pick-to: 6.8
Change-Id: Idaedd72d114b994fddd2ba7574fb7a45ca0a3e85
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 652250295c7f9812b49c522ab2fbe518ac9690e4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 14:03:25 +00:00
Alexandru Croitor
0e14e9042d CMake: Handle DESTDIR for SBOM doc references in top-level builds
When installing a top-level build using the DESTDIR env var mechanism,
the SBOM generation process could not find the qtbase sbom document,
while generating the qtshadertools document.

Make sure to prepend the DESTDIR env var to the install-time install
prefix, when looking for external SBOM documents.

Pick-to: 6.8
Fixes: QTBUG-132188
Change-Id: I1cdb75842fc552b43d982f05444b5ddc1fe58595
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit f2ce68d8f31f4c90471183d66075bd6fd5955d6a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 14:03:25 +00:00
Ivan Solovev
7b356f0f31 QtConcurrent: fix support for callables with deduced return type
Commit 6ebe3d0f0806069f906522dfe9b81baa3f3478de introduced extra
SFINAE checks on the template conditions.
However, it broke the case of using callables with deduced return
type, because SFINAE does not work for such conditions and treated
as a hard error instead.

Fix by explicitly providing all template parameters, so that compiler
could figure a better overload on its own.

Only QtConcurrent::blockingMapped() seems to be affected, but add
unit-tests to check all other methods as well.

Fixes: QTBUG-130766
Pick-to: 6.8 6.5
Change-Id: I1ddbe712d8ce04ac96ba13841cb569d728cfb943
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
(cherry picked from commit f73765682e7c8f1e0e78b7464deec57c7f2669ba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 14:03:25 +00:00
Jøger Hansegård
33f37ff637 Test that reset() and move assignment handles self-assignment
Calling reset() with the owned handle should maintain ownership and not
leak resources. Move assignment should also handle self-assignment
without leaks. The new tests verifies that this holds true.

Task-number: QTBUG-132507
Pick-to: 6.8
Change-Id: Icdfa4d67b06b71a74e810593e57449b51982c98c
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
(cherry picked from commit 03bd9491491881529ad28cd6d672edfdda9a0065)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-06 14:03:25 +00:00
Tim Blechmann
cffb015be5 gui: link with OpenGL framework
qopengl.h pulls in headers from the OpenGL framework on macos when
opengl is enabled. We should therefore also link the OpenGL framework.

fixes linker error in libqcocoa:
Undefined symbols for architecture x86_64:
  "_glGetIntegerv", referenced from:
QCocoaGLContext::updateSurfaceFormat() in
libqcocoa.a(qcocoaglcontext.mm.o)
  "_glGetString", referenced from:
QCocoaGLContext::updateSurfaceFormat() in
libqcocoa.a(qcocoaglcontext.mm.o)

Change-Id: I02d2c80e2652da0cf16eaca7ab161cf711599dc2
Pick-to: 6.8 6.5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 6f41c1652f73e1d79d6a4a91d009671a1e285b15)
2025-01-06 11:05:34 +00:00
Jøger Hansegård
8adfacca61 Add missing noexcept specifiers for QUniqueHandle handle traits
Handle traits should be simple, and not require exceptions. This patch
will allow us to improve the noexcept correctness of QUniqueHandle.

Pick-to: 6.8
Change-Id: I84d92818a2fcea5b98e09c0b7dc08b251751396c
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
(cherry picked from commit 3c57c7357422bdfda60f56901a7590b258915b6b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-05 16:32:11 +00:00
Juha Vuolle
ee432b6431 Rename Gui test utility's factor() to scaleFactor()
This makes it more clear which 'factor' the function is about.
The function internally calls a pre-existing 'factor()' function,
but since that is a static method of QHighDpiScaling, there the
meaning of 'factor' is more clear from the call context:
QHighDpiScaling::factor(window).

Resulted from API review.

Amends: 5ac4f04325a56d47812f528fe31ceb0d4932f664

Task-number: QTBUG-132090
Change-Id: I869bc05116d334b53b23a46aa2bb788432f250de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit f9376703c92e957c7334a2ff42a801237f53c8bf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-05 16:02:25 +00:00
Lars Schmertmann
850ed0222f Android: Fix freeze on start when the activity was destroyed before
This can be tested by enabling "Don't keep activities" in the developer
options. With this option Android will immediately destroy the activity
when it is moved to the background. In this case registerBackends will
be called the first time before the BackendRegister was created. Because
m_backendsRegistered was set to true even if it failed, the final call has
no effect. So we need to ensure to set m_backendsRegistered only if a
BackendRegister is available.

Fixes: QTBUG-132085
Pick-to: 6.8
Change-Id: I2ea1c0e0737c982594ceb06cbaf540399c45e3f4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 9903242ecab82c1ed72dcaf90e90a171c942a84a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-05 11:46:17 +00:00
Jøger Hansegård
b72c4988fb Implement QUniqueHandle::release() using std::exchange
This does not change the behavior of release() but gives more
compact code.

Task-number: QTBUG-132507
Pick-to: 6.8
Change-Id: I5b34c80409ca0e9e9a5e9aee9ef7bc80017610af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ec0c62385e0df00f42bc9fb5e117cb8b994cfc96)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 16:05:55 +00:00
Alexandru Croitor
cdc8811492 CMake: Error out when xcode / SDK version check fail in Qt 6.8+
Starting with Qt 6.8+ we should error out if the minimum sdk / Xcode
version requirements are not met.

An opt out is added for cmake build tests, otherwise all the tests
that use private cmake api will fail to configure when run on older
Xcode or SDK versions in the CI.
We do this by checking for a new QT_INTERNAL_IS_CMAKE_BUILD_TEST
variable.
We do the check inside
_qt_internal_check_apple_sdk_and_xcode_versions
instead of passing
a QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK variable to the test
configuration, because not all cmake build tests use private api, so
this way the list of projects that get the opt out is more
constrained.

Pick-to: 6.8
Task-number: QTBUG-119490
Change-Id: I1284616c91341848a9cf6406fbf35750707d1227
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit a13bfec63df2cf206e354ab56fc017a1f0eb8f6d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 16:05:51 +00:00
Jøger Hansegård
5653829bf8 Make QUniqueHandle::reset() default to invalid handle
Having a defaulted argument to QUniqueHandle::reset() gives a convenient
way of releasing ownership without assigning a new handle, and makes
the QUniqueHandle API more similar to std::unique_ptr.

Task-number: QTBUG-132507
Pick-to: 6.8
Change-Id: I842d4545d7cc2da8fe2df08280d0d816ed4be7fd
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 248ac4128fe86150532ff7146d0459abb5260946)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 16:05:49 +00:00
Alexey Edelev
2378455647 Unset the temporary variables in Dependencies scripts
Unset the temporary variables to avoid littering the scope.

Pick-to: 6.8
Change-Id: Ibd6b2896113a9fcd9eae7bc202dc0dc8c7a9f9bd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 96bb0db5afbab2c5cc32a6b19abc74497c839f5a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 15:59:40 +00:00
Alexey Edelev
d83081c78e Assume that the Qt Plugin package is FOUND by default
Set the <package>_FOUND variable to TRUE by default, so the follow
logic that need to change the flag only need to take care about
setting it to FALSE if something exceptional occurred.

Amends 8d0283ad2cae3d8fbd4b1b7ee5c6454f7fcc079c

Pick-to: 6.8 6.5
Change-Id: Idd4407ea77e81703b5fa8cc5efa8c52b53d401ae
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 13608241793f6671500868c9ce96468f604f651e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 15:59:38 +00:00
Alexey Edelev
b942110a4a Adopt the Qt dependencies lookup mechanism for tools dependencies
The existing lookup mechanism doesn't consider Qt path when looking for
the Qt Tool package dependencies. In good scenario this leads to the
missing Qt Tool package, in worst case scenario the Tool package could
be found by alternative search path and attempt using the invalid
tools.

Use the lookup functionality we have for Qt modules when looking for
dependencies of the Qt tools. This will look the tools in Qt search
paths first and only then attempt looking elsewhere, considering the
QT_HOST_PATH.

Pick-to: 6.8 6.5
Fixes: QTBUG-132340
Change-Id: I570c03037f2a92922d2546a4f5fde1bc17a7f812
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 035fbd068b5a3fbc18b7868ecac9a6a6a2f6602c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 15:59:34 +00:00
Alexey Edelev
ee533138d8 Use the 'call' command when generating the command scripts
cmd.exe has a huge problem when running the batch scripts locating
by paths contaning spaces and more the one set of quotes in arguments.
This can be worked around by using the 'call' command as the test
command runner.

Fixes: QTBUG-132258
Pick-to: 6.8 6.5
Change-Id: I9b6fb0f8bccf44456e4cb9b79f3c6bd3f9fe4678
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 10a3859809fc0b6e1edd6cbb93e409f0513a9bbe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 15:59:31 +00:00
Marc Mutz
c35cb5fe9a QRhiWidget: mark (Private&, parent, flags) ctor explicit
Found in API-review.

Amends 8386dfee05d35057836f93d182ef96674a6fd11e.

Change-Id: I5ad063b17356f75084655f1af353ba34a5deb4bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit be8391e56dc76f88058b432b015711cd7bce9c35)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 14:16:08 +00:00
Marc Mutz
ffb442db62 qpropertytesthelper_p.h: port from QScopedPointer to std::optional
It's more efficient (doesn't need to allocate the QSignalSpies on the
heap) and makes the header fit for the upcoming QT_NO_SCOPED_POINTER.

VxWorks seems to have a problem with its std::optional implementation,
though:

   QWARN  : tst_QAbstractAnimation::stateBinding() Trying to construct an instance of an invalid type, type id: -2125884168
   QWARN  : tst_QAbstractAnimation::stateBinding() Trying to construct an instance of an invalid type, type id: -2125884172
   QWARN  : tst_QAbstractAnimation::stateBinding() Trying to construct an instance of an invalid type, type id: -2125884024
   Received signal 11 (SIGSEGV), code 2, for address 0x0000000d

So write a small optional-like wrapper around std::unique_ptr for that
platform.

Amends 930e59b798d9e3d08e17440980d33a08fb411cbe.

Pick-to: 6.8 6.5
Task-number: QTBUG-132213
Change-Id: Icf85678d616bc96c7d74b982d0b919ea3f13265a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 7bd47fb70881e7240c027cd2844866c99f8f096d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-03 10:38:12 +00:00
Shawn Rutledge
5ead2a3d63 Fix QTransform::quadToQuad() to work with QRectF
A typical usage for mapping a 4-point polygon to a rectangle might be

  QTransform transform;
  bool ok = QTransform::quadToQuad(polygon, polygon->boundingRect(),
                                   transform);

It works because the QPolygonF(QRectF) ctor is implicitly called on
the second argument; but that ctor turns it into a 5-point polygon.
So it should be legal for QTransform functions to work with 5-point
closed paths.

Fixes: QTBUG-21329
Change-Id: Iae249012e14b8a3e8d3b0dfa35da8f9759359832
Pick-to: 6.8 6.5 5.15
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 48b1af941c50ab28cc92f9ea65a8a74a32eaf2bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 19:39:17 +00:00
Alexandru Croitor
ff596bfac8 Revert "CMake: Temporarily allow using any version in Qt's CI"
We updated the minimum CMake version used in CI for Qt 6.9+ to 3.22.
Enforce the minimum CMake version in CI to avoid regressions.

This reverts commit 5803af38aab09b7e47230a494e14654031d024e7.

Task-number: QTBUG-131169
Change-Id: Ifc91644dd26e465be44bfa7cfe6f99e295a174a9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit dcd057a31b54de637a5ca8bb8a5d46e753d3066a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 19:19:27 +00:00
Aurélien Brooke
076a818f74 rhi: vulkan: fix crash when making readbacks in consecutive frames
When requesting a readback every frame, the readback activeFrameSlot
alternates between 0 and 1. Suppose we are in currentFrame 1, and
process a list of readbacks of slots [1, 0]. First, we skip the readback
of slot 0 since it does not match the currentFrame 1. The list thus
remains [1, 0]. Then, we process the readback of slot 1, and call
activeTextureReadbacks.removeLast(). This removes the readback of slot
0, while in reality we processed the readback of slot 1. The
activeTextureReadbacks is now [1], containing a readback for which we
called vmaDestroyBuffer(), leading to a crash ("double-free" attempt) in
Vulkan on the next function call.

To fix this, remove the readback that is actually processed (index i)
instead of the last one. Since we iterate backwards, indices remain
valid.

Pick-to: 6.8
Change-Id: Idd4296de45167edd0a9da345dcc1c3b6ac71a6d6
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 73405890b8911dd1a58120665ce63a38281c6ce4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 19:19:27 +00:00
Michał Łoś
f13ef41580 VxWorks: Enable video device discovery
Video devices should be discovered by VxWorks properly.

Pick-to: 6.8
Task-number: QTBUG-115777
Change-Id: Ib6719fc9480827aed296343e0b91286ae8408c8a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit fbd7c7c45af8102090cf9e606ade565e5357a220)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 19:19:27 +00:00
Marc Mutz
7aadf25ccd QThreadStorage: replace QScoped- with std::unique_ptr
This only affects the !QT_CONFIG(thread) case and requires the rewrite
of the old-style static cleanup() deleter protocol into the modern
operator()() one.

As a drive-by, mark the deleter noexcept, like destructors are
supposed to be.

Pick-to: 6.8
Task-number: QTBUG-132213
Change-Id: I8839865880647d76b77eb9a3f2858067db86234e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6da1f72311b844b2232da3067ad6e1e24614e67c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 19:19:27 +00:00
Marc Mutz
77de3d45d3 Remove QT_NO_CAST_FROM_ASCII from QT_ENABLE_STRICT_MODE_UP_TO
QT_NO_CAST_FROM_ASCII is a policy setting, not a strictness
setting. The other components of QT_ENABLE_STRICT_MODE_UP_TO all deal
with clearly undesirable APIs, which QString(const char*) cannot be
said to be.

Keeping it in QT_ENABLE_STRICT_MODE_UP_TO would seriously impede the
use of strict mode in Qt itself (cf. QTBUG-132327).

Amends 3a6c8e02b6d1b0574da52b0087092d0c74aa92c1.

[ChangeLog][QtCore][QT_ENABLE_STRICT_MODE_UP_TO] No longer includes
QT_NO_CAST_FROM_ASCII. If you wish to continue using
QT_NO_CAST_FROM_ASCII, you need to define it in addition to
QT_ENABLE_STRICT_MODE_UP_TO. The reason for this change is that, while
everything else in strict mode should eventually become the default,
we're not proposing to remove the ability to construct a QString from
a const char*. QT_NO_CAST_FROM_BYTEARRAY and QT_NO_CAST_TO_ASCII
remain enabled in strict mode, though.

Task-number: QTBUG-132327
Pick-to: 6.8
Change-Id: I36b850833b1de79a47de975ca28d3591a0a0e089
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit f9163ae7a8167daded0798654d99a2e3a5aaa2b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 15:23:07 +00:00
Ivan Solovev
90fab1e4e9 Fix QtFuture::when{All,Any}() overload resolution
Both whenAll() and whenAny() have two overloads:
* an overload taking two input iterators, e.g.
  whenAll(IntpuIt begin, InputIt end)
* an overload taking an arbitrary number of future objects, e.g.
  whenAll(Futures &&... futures)

The public APIs are properly constrained, but internally they call
QtPrivate::when*Impl() template functions, that have the same two
overloads, but do not have any constraints.

As a result, passing exactly two QFuture<T>{} objects was leading to
the compiler picking the Impl overload that takes a pair of iterators.

Fix it by applying a subset of constraints from the public API to
the private implementation as well.

Amends 102f7d31c469a546f52c930a047bd294fb198186 which was introduced
for Qt 6.3, so picking down to Qt 6.5.

Fixes: QTBUG-131959
Pick-to: 6.8 6.5
Change-Id: Ide29ac9a494d07870e92957c40c1f614e56825f8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 8aef5b0d8fd57684abe39c88af8c14d8882ef07b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 13:58:28 +00:00
Ivan Solovev
73b8c83ec7 Do not duplicate JsonFormat enum
The enum already exists in QJsonDocument, so there is no reason to
introduce a new one in QJsonValue.

Instead, use the fact that we only need to forward-declare QJsonValue
in QJsonDocument's header, include the latter into qjsonvalue.h, and
use a type alias.

For Qt 7, pre-program moving of the enum into QJsonValue and using
an alias in QJsonDocument.

Amends ac73079dee5f0260528a5c217a82cb0beafb0a56.

Found in Qt 6.9 API review.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
QJsonDocument header no longer includes QJsonValue.
The backward-compatible fix is to include all needed headers
explicitly and to not rely on the transitive includes.

Change-Id: I7c5219a239149e4a87d4780c4277d111983ad0f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3cb87d891bb040f73fb68b6c5e7e82518f603c59)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 12:07:32 +00:00
Joerg Bornemann
523f711295 CMake: Yield error if VCPKG_ROOT variable is missing
...and vcpkg usage was requested.

The user got no further feedback why vcpkg wasn't used despite passing
the -vcpkg configure argument.

Pick-to: 6.8
Change-Id: Ib43c2045f093c3887a63406e37f37bdd681341cd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit fecae6ab1b1aa36f43b5cd87b229de4df37e44ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 10:25:22 +00:00
Marc Mutz
c806d2bbbc sqlbrowser example: use = default on empty dtors
Idiomatic C++11 code.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited the issue from older code.

Pick-to: 6.8
Change-Id: Iba1fb9874bd93b4a560c33e3ecf62ecaa96d8bda
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 19564e033cf65a0a67680285d1cbcc85c9437aaf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:54 +00:00
Marc Mutz
101fedb17f sqlbrowser example: fix ugly margin around ConnectionWidget
When a layout is used to arrange the children of a non-top-level
custom widget, the layout's contentsMargins need to be manually set to
zero to avoid extra empty space around the widgets, misaligning it
w.r.t. its siblings.

Add the necessary call.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited the missing margin adjustment from older code.

Pick-to: 6.8
Change-Id: Icd1945a4f2b1635f031e50758ec2f1ec9313ae27
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 15524d1623a1400e4de15e57408e37020d394986)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:48 +00:00
Marc Mutz
cc1af8409a sqlbrowser example: use explicit / override
Examples should show idiomatic use of Qt and C++, so mark the custom
widget constructors in this example as explicit and their destructors
are override.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited the missing explicit from older code.

Pick-to: 6.8
Change-Id: I5b5b49f69330c6f139345bed7264c85a36c36e9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit e0e9a5627376e04aba1b2ca2591554851d7de240)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:42 +00:00
Marc Mutz
88600c3096 sqlbrowser example: use unique_ptr to hold m_ui
The old code used manual memory mangement (raw new/delete) to
(de)allocate the Ui struct. This is so 80s.

Use an owning smart pointer to manage the memory. Ordinarily, this
would have been QScopedPointer, but seeing as that doesn't have a
create() method to hide the raw new, use std::unique_ptr and
std::make_unique() instead.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e.

Pick-to: 6.8
Change-Id: Icabb9154eb38630855e14094b958af0214516f6b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 0da2c2c4ef2219967db87021eece2a60b6e207af)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:35 +00:00
Marc Mutz
02f05bdb5f sqlbrowser example: use idiomatic Qt [3/3]: use form-layout
The old code used a grid layout inside the QGroupBox, but the design
with labels in the first and edit-widgets in the second column lends
itself to a QFormLayout, which adapts the alignment of the widgets to
the platform style, so use that.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited all of the above from even older code.

Pick-to: 6.8
Change-Id: I528f0ce9d8cb7a997fbfabcdca887c059f571b38
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9c099ef942216d01261c26b60e3727a2a467f12a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:29 +00:00
Marc Mutz
8dbd0828e9 sqlbrowser example: use idiomatic Qt [2/3]: use button-box / override accept()
- The old code used two QPushButtons in a QHBoxLayout to provide
  Ok/Cancel buttons. This hard-codes the positions and text (and
  icons) of these buttons, instead of adapting to the platform style.

  The new code simply uses QDialogButtonBox, which is designed for
  this purpose.

- Also, the old code connected the Ok button's clicked() signal to a
  custom slot that then called QDialog::accept(). This means that the
  code in the custom slot is not executed when the dialog is accepted
  by other means (e.g. return press in one of the line edits
  ("auto-default"), though I'm not sure here).

  The new code uses the idiomatic Qt way of overriding
  QDialog::accept() instead, and connects the button-box's accepted()
  signal to it. This is done in the .ui file, so it already works in
  Designer preview.

- Finally, the old code made a manual connection from the Cancel
  button to QDialog::reject().

  The new code uses the Qt idiom of connecting in the .ui file
  directly, using QDialogButtonBox::rejected() as the signal.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited all of the above from even older code.

Pick-to: 6.8
Change-Id: I83afd6156a0811e0c0f99f2480625ea6b69ff78b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3419c299369ac1da94ba5710aaf5f5f65c38c33c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:23 +00:00
Marc Mutz
f2b88b3225 sqlbrowser example: use idiomatic Qt [1/3]: disabling group-box
The old code connected to the wrong signal and therefore had to write
a custom slot to perform the disabling of the group-box.

The new code simply connects the QCheckBox::toggled(bool) signal to
the directly-compatible QWidget::setDisabled(bool) slot, removing the
need for a custom slot.

Also move the connection into the .ui file, so it works already when
checking the form in QtDesigner.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however, only
inherited the issues from older code.

Pick-to: 6.8
Change-Id: Ia834f92de270bb7b18981273188f6e5b6cd457a2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 53826d1cde26f825d1983476c6697f72130e351f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:17 +00:00
Thiago Macieira
381dca29ff Replace qgetenv() calls converted to QString with qEnvironmentVariable()
It's slightly more efficient.

Change-Id: Id5ac04fc27eee108c8e5fffd786c3d5f793a0a9d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit db34e27f7f6ade54bfae59e5eed14c05ac508a49)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-01 19:55:21 +00:00
Thiago Macieira
36d260014f qEnvironmentVariable: avoid a temporary QByteArray
Because we don't need one. I guess I was just lazy.

Amends b12fd1fa9d0b64e3cb66fa68c85392dbde8e175b ("Long live
qEnvironmentVariable()").

Pick-to: 6.8
Change-Id: I5b9141c5a32f9d784e0bfffdc3e4d742790aebdd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ce95c26034cc5b3ae8094c1521221e5b2f13ecfa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-01 16:46:29 +00:00
Ahmad Samir
01edc916d2 moc: fix GCC -Wextra-semi colon after member function definitions
As pointed out by Thiago the QT_DECLARE_METATYPE calls are redundant, so
remove them.

Task-number: QTBUG-132101
Pick-to: 6.8
Change-Id: I73800e70d3f270fb87941d4e053aa7ac5ed1841c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3bb4c4949fed9ccf8653151c78d5130b8db00716)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 23:59:24 +00:00
Ahmad Samir
5171b7f488 src/plugins/*: fix GCC -Wextra-semi colon after member func definition
Pick-to: 6.8
Task-number: QTBUG-132101
Change-Id: I947fdb66df9b6d86c60139046166395e4ae42127
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 997abb0520cdfbde60e0fe4fdb133e15e24ce871)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 23:09:12 +00:00
Ahmad Samir
cc369ad07f QCryptographicHash: hashInto(): check the buffer size earlier
We can use hashLengthInternal() to check if the buffer is big enough.
This matches what the QCH::hash() method does, it also has an assert
that `result.size() == ba.size()`, so we can assume this works with
OpenSSL's EVP_MD_get_size() in EVP::finalizeUnchecked().

Amends c70c81b371993ca865d523bb5f37eac4eb8a972b.

Pick-to: 6.8
Change-Id: I64935f3d590ab243b361a0b764f011c388820e32
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b83e825fab16f83f86149ead78efb6ec3d2fa16d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 23:09:11 +00:00
Marc Mutz
11f485ea68 tst_QImage: fix discarded QFile::open() results
Wrap them in QVERIFY(), as usual.

Found by QFile::open()-turned-nodiscard-come-6.10.

Amends e673e5a257569eaa816c6acd31dd754efd9f8c75 and
25c96d547b4563cbfedcec6093d68116148d8599.

Pick-to: 6.8
Change-Id: Id39e5d9e500b524af8443cb57916a12f98bd7c23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit cf6ae9a90106a3557a8df1e0d2567b02a4ef6ded)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 19:03:28 +00:00
Marc Mutz
c970909437 tst_Q(Gui)EventLoop: Unbreak UBSan build
The tests peek into QEventLoopPrivate, which means that a UBSan build
needs access to QEventLoopPrivate's type_info, for which we need to
export the class.

Amends 3af20bd8eb8c75017c5d6d138d7c42914ee5bee3, which fixed the weak
vtable that, presumably, made this test work before.

Pick-to: 6.8
Change-Id: I4104ba95093fa240c5ef7d9d5bf287c1652333f0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 8bf54385319df958ea88f9998e7690d4c35e354d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 10:13:04 +00:00
Marc Mutz
5cd16659ff Port QtCore from QScoped- to std::unique_ptr [1/2]: private uses
This patch series is in preparation of enabling QT_NO_SCOPED_POINTER
when building QtCore, a prerequisite for enabling this opt-out in leaf
modules.

This first part of the patch series ports objects whose use cannot
"leak" into other modules, e.g. because they are in .cpp files or are
private members and is thus SC (and, as demonstrated by various static
assertions we put into the source code over the years, BC).

The second patch will deal with objects in protected and public APIs,
and thus might be QUIP-6 SiC Type A.

Task-number: QTBUG-132213
Change-Id: If4967f6e563a4e7d74550fad4c6d354fad1beef5
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 63f1c6fcbab5f36809ffc96ac5ff6cb9e01e70bb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 10:12:58 +00:00
Marc Mutz
3ea877a844 QLibraryInfo: de-pessimize prefixFromAppDirHelper()
The local appDir variable was only used to hold the return value of
another function call. But hardly any compiler will be able to look
through the QString atomic ref-counting to turn the non-Darwin code
paths into the tail-calls that they ought to be.

Remove the variable and return the result immediately. This removes
the move-assignment and dtor calls in the two changed lines and lets
RVO kick in, turning these calls into tail-calls on non-Darwin
platforms.

Amends 4ac872639ed0dd3ae6627e05bdda821f7d128500.

Pick-to: 6.8 6.5
Change-Id: Ieeefbd52fc983ab7aebcff6419965b206f374935
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit e57113feac183abd1f5bfcfb633a33e1387b2d3e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 10:12:56 +00:00
Toni Saario
60a264ed50 Coin: Tweak VxWorks testrunner
Add crash handling to avoid waiting until 10min timeout on each crash.
Force restart on each crash by killing emulator.

Make health check more robust to allow it to work even when emulator is
down. This is done via wait in separate process which cannot be done
with normal timeout command, as input to pipe that is not being read
by emulator will block forever.

Change-Id: I86c3c86f936cc96d57b38983da48d1d73162399d
Reviewed-by: Simo Fält <simo.falt@qt.io>
(cherry picked from commit 918cbe7601b07fa6db7973ff9a4f76208dae8f22)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-30 11:31:47 +00:00
Samuli Piippo
884c338355 egldevice: allow DRM device path to be overridden
The backend-provided DRM device might not be the right one,
so allow kms config to override it.

Pick-to: 6.8
Task-number: QTBUG-131887
Change-Id: Ied744ae7015eae64f4556f1528e0dbe8ae69d206
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
(cherry picked from commit c3bbbb22b8bc920e4937cf640fd1d2df3b0f9205)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-30 11:31:47 +00:00
Friedemann Kleint
b06125aa51 uic: Generate fully qualified enumerations for QFormLayout
This is required for Python.

Task-number: PYSIDE-1735
Change-Id: I92108009dd23565adaa2ee77300059cb197a89c5
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit 11d6200d8ad88459a499550b30f5c22f1657719b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-30 04:04:22 +00:00
Ahmad Samir
bbf78c9636 tst_QCryptographicHash: split 4GiB tests to a separate unit test
With those tests split, tst_QCryptographicHash takes about 4ms.
When FEATURE_openssl_hash is enabled those tests take about 15s on
their own, but when openssl_hash is disabled they take about 2 minutes.
That makes running the tests locally a bit of a hassle when hacking
code ... test ... hack ... test.

This is with a debug build, GCC, `-O0 -g` flags.

Change-Id: I8b8f5d1954feb1f9eb8115e27635610a41b42f47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fff217824b532da7306af1ac755581e76e098a27)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 23:22:56 +00:00
Christian Ehrlicher
6790d8d716 QCommandLinkButton: fix drawing high-dpi icons
QCommandLinkButton was using QIcon::pixmap() without specifying the
current device pixel ratio. Switch to QIcon::paint() to not have to
fiddle around with the dpr at all here.
As a drive-by remove a useless QPainter::save/restore call.

Pick-to: 6.8
Change-Id: I7e2492a09b28cb8a4f4cc60454733e0054fe1e9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 785fb89e0aafc25a435d28ff05bf0dc05385b372)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 19:35:04 +00:00
Thiago Macieira
d39c493390 3rdparty: patch BLAKE2 sources to not export anything in static builds
This could cause conflicts with other users of these algorithms, notably
libb2 itself. Though if you're using libb2, you shouldn't be using the
un-optimized copy inside QtCore...

I've updated the SHA1 of the last commit in the repository, but there
were no changes to our sources.

[ChangeLog][Third-Party Code] Fixed a bug that caused the BLAKE2 symbols
to be visible from QtCore in a static build. If you need to use the
BLAKE2 hashing algorithm in your own code, either use QCryptographicHash
or import libb2 into your build environment. Using libb2 remains the
recommended solution for all systems, especially those for which it has
optimized (vectorized) implementations.

Fixes: QTBUG-132347
Pick-to: 6.8
Change-Id: I48003b58cef0d8bcc720fffdd89b0f151fd102e3
Reviewed-by: Linus Jahn <lnj@kaidan.im>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b884fbf10237547e809745f528978942faf0e5f6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 11:40:51 +00:00
Marc Mutz
b79b2edde8 QLibraryInfo: port from manual memory management to unique_ptr
It's safer and clearer.

Also standardize on unique_ptr instead of QScopedPointer, because the
latter is not supposed to be movable, so the assignment in
QLibrarySettings::load() would not compile.

As a drive-by, scope a variable tighter (in an if condition).

Task-number: QTBUG-132213
Pick-to: 6.8
Change-Id: Iecdd910af4d06dbd03d2daf3ccf99dd4822f04ac
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit aa1f2064801b39a26a718703817e197a3e31447e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 11:40:51 +00:00
Christian Ehrlicher
e23933e868 QStyleSheetStyle: Honor box settings for QSpinBox
The previous patch to not modify the CT_SpinBox by QStyleSheet when
nothing was added for QStylesheet also removed the additional margins &
paddings handling for the size calculation. This patch re-adds this.

This amends 96adebed606cdbc73c73778917d777dc04c6e93e.

Pick-to: 6.8
Task-number: QTBUG-130642
Fixes: QTBUG-132431
Change-Id: Iff1f0febeca90d3154e61fd80e4b359bc7766b84
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit b2cc8824ec2cdeb6e053a2ff92d7d5b71f8d0ee5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 03:54:57 +00:00
Christian Ehrlicher
314c91d94e Widgets: pass dpr to QIcon::pixmap()
Change the remaining calls to QIcon::pixmap() to pass a valid
devicePixelRatio parameter.

Change-Id: I0e71e20c8109e296446e9e13cddba31d53c05df9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit efc318e05a2288f3fe62d9d7b2b892906e9263e0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 03:54:57 +00:00
Christian Ehrlicher
fba5f806e6 QCommandLinkButton: reload icon on style change
Different styles provide different icons for SP_CommandLink so reload
the icon on every style change.

Pick-to: 6.8
Change-Id: I2d8bd706d4c1bca89b91c90f1bb90a796b38e0d3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d4c518b210ad56cb51c17e6e1b4a81b0deb7253c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 03:54:57 +00:00
Volker Hilsheimer
843e2e1309 JNI: don't pass jobject by reference
And definitely not by non-const reference.

Discovered during upcoming fixes for native function registration.

Task-number: QTBUG-132410
Pick-to: 6.8
Change-Id: I0ce8519f5a1f9f3caffefc53e6d93b52509bc439
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 1b84970b90c36771bf266f8612dba9585341795a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-28 19:19:03 +00:00
Marc Mutz
5e6fa3dbc5 QTest::toString(QCbor-type): port from const char* to unique_ptr<char[]>
This is more robust and lessens the impedance mismatch as seen by the
old code using std::unique_ptr<char[]>(expr).get().

The new code isn't impedance-mismatch-free, either
(UP{qstrdup(qba.data())}), but short of writing a small string class
whose internal buffer can be release()ed to comply with the archaic
QTest::toString() new[]'ed const char* return value, there's not much
we can do about it atm.

Also separate the internal from the "public" stuff in
QCborValueFormatter by adding private: and public: sections.

Pick-to: 6.8
Change-Id: I09a2ad1a75bb9eab3d01f2b5b60afc2d762da384
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d9264ee65d6f24e1008b08494b1472a54ac01940)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 17:23:30 +00:00
Thiago Macieira
8fdcda4dac Replace qTerminate() with std::terminate() and mark it for removal
It was used by the QT_TERMINATE_ON_EXCEPTION macro, introduced in 2012,
to support pre-C++11 noexcept semantics. That macro was removed for Qt
6.8 in commit 9b2ae564a59656d9cf49b141e70f5958b4fb79a4. This commit
amends that removing the definition of qTerminate() immediately in Qt
6.9 (it was an \internal function).

Change-Id: I9682121c04fafb3676b0fffd9f5ac999e7603c84
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit b8f84fd1e2af38ece89d60619bf93e7af34433ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 17:23:30 +00:00
Thiago Macieira
09d44fdef3 QSaveFile: make it so flush() errors imply commit() failed
QSaveFile records past write errors in writeData(), but often the
QFileDevice::writeData() calls it places will succeed because the data
is only being buffered. Instead, the failures are noticed only by
flush(), whose actions do not affect QSaveFilePrivate::writeError.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true and overwrite its intended target file even though it failed
to flush buffered data to the storage, which could cause data loss. This
issue can be worked around by calling flush() first and only calling
commit() if that returns success.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true even after a cancelWriting() call had been placed, if
writing directly to the target file (that is, only with
setDirectWriteFallback() set to true). Note that the state of the file
does not change under those conditions, only the value returned by the
function.

Drive-by clarify a comment from 6bf1674f1e51fd8b08783035cda7493ecd63b44
(Qt 4.6 "Don't drop errors from flush on QFile::close") which had me
chasing the wrong lead.

Fixes: QTBUG-132332
Pick-to: 6.8 6.5 5.15
Change-Id: I427df6fd02132d02be91fffd175579c35b9c06cc
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
(cherry picked from commit 92373d353cf090faa03cbc8aca505d1784b10b54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 17:23:29 +00:00
Lars Schmertmann
e6434a71eb Avoid unused variable warning in qfilesystemmodel.cpp
2135:5: warning: unused variable 'q' [-Wunused-variable]
    2135 |     Q_Q(QFileSystemModel);
         |     ^~~~~~~~~~~~~~~~~~~~~

The variable is only required for the feature filesystemwatcher.

Pick-to: 6.8
Change-Id: I5da48f94118179ec20fec7da7169b7f22cec17fe
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 46dddcb213eb5080b8f759633a1b025d86f55e36)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 16:35:11 +00:00
Marc Mutz
353d22756f Fix a performance regression in QDataStream
Commit e176dd78fd2f253eb2625585b2bd90b5713e5984 replaced a `new
char[n]` with a std::make_unique<char[]>(n), probably on this author's
insistence.

But the two are not equivalent: make_unique() value-initializes, even
arrays, even of built-in type, which means that each buffer resize
writes each byte twice: first nulling out the whole buffer as part of
value-initialization, then in the memcpy() and any following read()s.

For buffers of several MiB, or even GiB in size, this is very costly.

Fix by adding and using a backport of C++20
make_unique_for_overwrite(), which performs the equivalent of the old
code (ie. default-, not value-initialization).

Also add q20::is_(un)bounded_array, which are needed for the
implementation of q20::make_unique_for_overwrite().

Amends e176dd78fd2f253eb2625585b2bd90b5713e5984.

Pick-to: 6.8 6.5
Change-Id: I8865c7369e522ec475df122e3d00d6aba3b24561
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 1a9f8cc0df33195df959cee2e355dde4cbacd754)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-24 23:42:09 +00:00
Marc Mutz
aff082764a tst_QSpan: check QList<int> -> QSpan<const int> doesn't detach the former
It does.

While std::span, does, too, and so users should be using
std::as_const(), it's quite simple to avoid for QSpan, so we'll fix it
in QSpan. This patch adds the reproducer.

Task-number: QTBUG-132133
Pick-to: 6.8
Change-Id: I2e416fb7344830cd5e0d945cce61491cd6f4a7a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 05b9a4b2deefd586356e1f36d84372b06e74cfe3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-24 22:24:05 +00:00
Mike Chen
b6108318c2 QFactoryLoader: load extraSearchPath first
Since `QT_QPA_PLATFORM_PLUGIN_PATH` or `-platformpluginpath`
 specifies the path to platform plugins, `extraSearchPath`
 should be loaded first.

Pick-to: 6.8
Change-Id: I2e62fbf2021250ca864c669a7bbd7d56acd67d1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 457580936ddebc73e8a24fc8af0d342084b3a0b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-23 04:08:12 +00:00
Marc Mutz
7b5dbe165d QDecompressHelper: fix compilation with GCC 9
GCC 9 doesn't accept [[unlikely]] between the (condition) and the
compound-statement of an if, in both C++17 and C++20 modes:

  qdecompresshelper.cpp: In member function ‘qsizetype QDecompressHelper::readZLib(char*, qsizetype)’:
  qcompilerdetection.h:1048:31: error: attributes at the beginning of statement are ignored [-Werror=attributes]
   1048 | #    define Q_UNLIKELY_BRANCH [[unlikely]]
        |                               ^~~~~~~~~~~~
  qdecompresshelper.cpp:597:54: note: in expansion of macro ‘Q_UNLIKELY_BRANCH’
    597 |         if (ret == Z_DATA_ERROR && !triedRawDeflate) Q_UNLIKELY_BRANCH {
        |                                                      ^~~~~~~~~~~~~~~~~

See also https://stackoverflow.com/questions/51797959/how-to-use-c20s-likely-unlikely-attribute-in-if-else-statement

Put it into the compound-statement instead, then GCC 9 accepts it. The
two are equivalent, because [[likely]] marks a path, and there is no
selection statement between the two positions.

Amends 5ae84d0afbd3690a2c003d06d920566a5d56dc8c.

Change-Id: Iac1970219c98a1c26e450dfe6bad6583e4d32c29
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7a7804d4b454021d68d1d5138d134ef62abfcdb3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 16:28:52 +00:00
Marc Mutz
fc29f57a17 q23type_traits.h: use is_scoped_enum_v from std
We don't like surprises in qNN, so use the real is_scoped_enum_v from
std instead of adding the _v version outselves, even in C++20.

Amends 03a7be37806a32e9a8ac963b309812d6b8f125f6 and
63a8f657c2236829f16016602d9c0098b089d35e.

Change-Id: I7f9149678b95f7a59643152abf5a627e226cc058
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 40501ffbb441ce48733b3733b7ab781c7db8cca8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 13:50:51 +00:00
Christian Ehrlicher
4354d7797e QDrawUtil: use QPainterStateGuard
Replace the internal PainterStateGuard class with the now public
QPainterStateGuard.

Change-Id: I9c072ce6e45ddfe2d0a8aba789311193788dee5a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 204df603ef43be921e0eecae4d4af0ae6026787f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:05 +00:00
Christian Ehrlicher
6f7b8ada85 QCommonStyle: use QPainterStateGuard
Replace the internal QPainterStateSaver class with the now public
QPainterStateGuard.

Change-Id: I56285cb469cec43071320e87ac378674fd99c06b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7690b6260eac12958c97d642421e27680ca57496)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:04 +00:00
Wladimir Leuschner
4eaaf89db5 QWindows11Style: Adjust Subline for QLineEdit to fit rounded corners
Reduce the size of the subline for QLineEdit to fit the begin and end of
the rounded frame corner.

Task-number: QTBUG-132261
Pick-to: 6.8
Change-Id: I879f30c2bdc6601fef4738aeec71d7ab7bcee22c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 5e656b9ea3c192f389b7e4f7aa2ae6b010cec306)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:03 +00:00
Wladimir Leuschner
4c2f439001 QWindows11Style: Align QSpinBox rect to match QLineEdits rect
The content rects for QSpinBoxes were smaller than QLineEdits rects for
UI elements that should have the same size. This patch increases the
content rect for QSpinBoxes.

Task-number: QTBUG-132261
Pick-to: 6.8
Change-Id: I59e752b719399c5845ab3ef81c6e271deda16273
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit a53e095882551caf3684a1f6a205b6c7d76a8913)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:02 +00:00
Alexey Edelev
8f1438b1a8 Avoid creating Plugin targets if the dependencies are missing
The plugin lookup mechanism doesn't handle the situation, when the
plugin is available but it's private dependency(static plugin case)
is missing. In this case we currently silently bypass the dependency
lookup and create targets. So users see the confusing message about
missing linked target, like:

   Qt6QSQLiteDriverPluginTargets.cmake:61 (set_target_properties):
   The link interface of target "Qt6::QSQLiteDriverPlugin" contains:
     SQLite::SQLite3
   but the target was not found.  Possible reasons include:
     * There is a typo in the target name.
     * A find_package call is missing for an IMPORTED target.
     * An ALIAS target is missing.

This indeed should be handled properly and we should omit creating
targets especially if users don't really use the plugin directly.

Also if dependencies are not satisfied it looks logically to set
the <plugin>_FOUND to false as this will be yet another indicator
for user that the plugin is not found.

Task-number: QTBUG-132244
Pick-to: 6.8 6.5
Change-Id: I8685163df0dee3a728c724901f69780569ffcad5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 8d0283ad2cae3d8fbd4b1b7ee5c6454f7fcc079c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-21 04:51:58 +00:00
Eskil Abrahamsen Blomfeldt
610ee0c504 Don't include bearing of mid-string characters in max width
When calculating the maximum width of a text layout, we
would add the text width of each substring *after* we had
added the negative right bearing of the last character to it.
But the bearing of the last character in a wrapped substring
does not actually add to the maximum width unless it is the
last character of the *whole* string.

Prior to 250117086ff15bba79df8f0e15ee66192edc9ea9 this was
not noticed, because the last glyph in the substring would
typically be a space and the space does not have any
bearings (when doing wrapping on individual characters it
could still happen). After the change, the previous glyph
for which we get the right bearing will be the last
non-whitespace glyph. If this happened to have a negative
right bearing, we would add this to the max width and
end up with a larger max width than we should.

This caused a test failure in tst_qquicktext.

This test prefers the text width without the bearing (i.e.
the *advance* of the substring) unless the line is manually
wrapped or it is the last line of the layout.

Pick-to: 6.8
Change-Id: Iba1a5ad48d575683672400f0572dfa683a0f2d9c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit c08a92307d6d9fa9d9d9a1f301e3f2a65374e99a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-21 04:51:43 +00:00
Tor Arne Vestbø
e266949979 Apple: Use automatic rendering mode for icon engine
When requesting symbol icons the OS automatically chooses a rendering
mode per icon. Most icons use the monochrome rendering mode by default,
but some of them use the hierarchical.

We don't want to override this choice by always using hierarchical,
as that doesn't match the look of most icons in the system and may
be surprising to the user.

We still want to support tinted icons, based on the QPalette. For
iOS this is easy via [UIImage withTintColor:] but for macOS we
have to do an extra render pass. Unfortunately we can't use
configurationWithPaletteColors with a single color, as for the
hierarchical icons this will produce a different looking icon
than if we tint the entire icon.

[ChangeLog][macOS/iOS] The Apple icon engine, used for theme
icons on macOS and iOS, will now use the default rendering
mode for icons, typically monochrome, instead of always
using hierarchical icons.

Pick-to: 6.8
Change-Id: I9e66d848222e8ed0f7f20897454f27446bf0fd81
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9f392c09a1d30e48494b4df0e2f5f531c7e4ec4b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:18 +00:00
Mårten Nordheim
b91edac40d tst_QHttp2Connection: make settings exchange wait for acknowledgement
Is needed when sending more SETTINGS frames during the test later

Task-number: QTBUG-132277
Pick-to: 6.8
Change-Id: I24b2a5d1b2e7aecd8687db5b24f37233df3b91dd
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 6e7a15f5c50a94216bcf35241ec008e6c419ba18)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:18 +00:00
Toni Saario
7ce68e59fd Increase VxWorks stack size
Increases to around 16MB with the format change.
Required by some tests.

Change-Id: Ia41436b4269220f84271b614ea6f2b96ca605c32
Reviewed-by: Simo Fält <simo.falt@qt.io>
(cherry picked from commit 75d87caef70ff79b4db04834d28daa1905f0d5a0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:18 +00:00
Juha Vuolle
651b515074 Change QImage::mirrored() deprecation from Qt 6.10 to Qt 6.13
The deprecations aren't urgent, and allowing more time for users to
adapt is appropriate. In addition, also suppress the deprecation
warnings when compiling the related autotest.

Resulted from API-review.

Amends: 577946c1f05aaaa2a3f9682001aeb4144386b26b

Task-number: QTBUG-132090
Change-Id: Ia0c07ab510a9a9c8722892fcd94f58f6ec287059
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 0aa07ce77237dacc58de5939d5a239fb8997da7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Christian Ehrlicher
1319dcf472 QWindows11Style: Adjust position of MDI subwindow icon
The y position for the MDI subwindow icon was not calculated correctly
so the icon was not painted vertically centered.

Pick-to: 6.8
Task-number: QTBUG-130673
Change-Id: I5f9023820a4e4b4288017869ac4088fe2669ce50
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6e29a94b547fbafa69e97ac02aeb33edad63f2ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Marc Mutz
9cd2e3ffef qtesttostring.h: standardize on unique_ptr<[]>
... instead of QScopedArrayPointer.

Less Qt code (which we're supposed to test with this library) and more
consistent with the tuple implementation.

Also makes the header clean w.r.t. upcoming QT_NO_SCOPED_POINTER.

Pick-to: 6.8
Task-number: QTBUG-132213
Change-Id: I3705b8db89e909e3f1e37ad6a31aaba6f9af899a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f405925829ca37af47ecbb291bdb8a95a606e024)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Christian Ehrlicher
ecc31955f1 QWindows11Style: adjust text rect for CC_TitleBar
The adjustment for the textrect was wrong - the bottomRight point must
be moved by -1/-1, not 1/1.

Pick-to: 6.8
Task-number: QTBUG-130673
Change-Id: I6c099fdd9a03188e7a5c7852b1912ed9b2801f7a
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 2c85e5d22215f24bd46d07a1183393e52702493f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Christian Ehrlicher
f349040b39 QDrawUtil: Cleanup qDrawPlainRoundedRect/qDrawPlainRect
Fix the style and use PainterStateGuard instead own save/restore
functionality because PainterStateGuard is already available and used in
those functions.

Pick-to: 6.8
Task-number: QTBUG-132187
Change-Id: Ie454b6cffe03444d88f13d15adb19a7e7783a493
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1fb86f1f84bb56dab60bc15604c09a14157d6f10)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Volker Hilsheimer
319b31a5a2 QTestLib: Remove logging category declaration from public header
The lcQtGuiTest category is only used in qtestsupport_gui.cpp, so
declare it there as a static logging category.

Addresses header-review comment, amends
5ac4f04325a56d47812f528fe31ceb0d4932f664.

Task-number: QTBUG-132090
Change-Id: I5b2a93822a698f55c52c1be87ebf8a689f49e2a3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit b957dfc6e06deed64e20e8eee5d2164250b28b95)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:16 +00:00
Thiago Macieira
1596b5855c QDebug: constrain the new Standard Library op<<
So they be SFINAE-ruled out when either the key or (for associative
containers) value types don't provide their debug-streaming operators
either.

Amends 850d4895be565931d18c92e5e2f9a33b7f26de6d,
0c96528e8d43ad4309bdca14b179a5045984655a,
a9fe57fefaac0cb047e4c02e0b8c8f8327e0a58c.

Fixes: QTBUG-132104
Task-number: QTBUG-130290
Change-Id: I1d6703b1fdf6cfd03799fffd33191d8028ecc123
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 8f958a6e2dcff5bb9b01442a19f5605f357c6e7e)
2024-12-20 08:17:40 -03:00
Christian Ehrlicher
7ab2885594 QSqlQueryModel: add new function to refresh the model data
This function re-executes the query used by QSqlQueryModel and refreshes
the data from the database. The query must not use bound values as these
values are not preserved.

[ChangeLog][QtSql][QSqlQueryModel] Added refresh() to refresh the model
data from the database.

Task-number: QTBUG-123603
Change-Id: I3f1d779e07b88565abe825c31cfc4d7d1b2312c4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1bd883dbc15c4016f78d421afac2ac9f31ec4874)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 11:17:40 +00:00
Christian Ehrlicher
fc29afbe1a QSqlDriver: return the connection name of the assoicated QSqlDatabase
A QSqlDriver instance is directly bound to a QSqlDatabase object. But
there was no way to get the QSqlDatabase out of a QSqlQuery/QSqlDriver.
Fix it by storing the connection name also in the driver during
creation and add a getter for it.

[ChangeLog][QtSql][QSqlDriver] Added connectionName() which returns the
connection name of the associated QSqlDatabase instance.

Task-number: QTBUG-123603
Change-Id: If78b85413cf6ca965ff6bf9f3600cb54169b5569
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5b07e3de3fe5335d9338c65ca40cfe656a389167)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 11:17:39 +00:00
Eskil Abrahamsen Blomfeldt
ed1032975e Include right bearing in width of layouts wrapping on spaces
When we're calculating the width of the layout, we include the
right bearing of the last character in the text line if it is
negative (i.e. it exceeds the advance width). We do this by
storing the last glyph that has been verified to fit in the
line, so that we can retrieve its right bearing when we find
a break.

However, when we were wrapping on spaces this previous glyph
would always be a space, and the right bearing would
subsequently be 0. But then the trailing spaces would be
trimmed and the right bearing of the actual last glyph
would not be recorded and never added to the text width.

This caused a failure in tst_qquicktext on Windows with both
DirectWrite and Freetype: This was purely unlucky, because
the metrics of the Tahoma font happened to be such that the
right bearing on the 'k' was enough to cause a line to
overflow. Since we didn't account for it when setting the
width, we ended up with unexpected line breaks, causing the
test to fail.

This did not happen with GDI, since it rounded the right
bearing of the character down to 0 (which was actually
visible in the layout, in that the k was painted a fraction
of a pixel outside the text layout's width).

In addition, QTBUG-130313 was causing us to pick a different
font when resolving the non-existent font requested by the test,
so therefore the bug was not found immediately when moving to
DirectWrite as the default but only when QTBUG-130313 was fixed.

We fix this by
  1. When adding a chunk of whitespace, we record the previous
     non-whitespace glyph that has been verified to fit.
  2. When adding a chunk of non-whitespace, we only record the
     previous glyph verified to fit *if* it is not whitespace.
	 Otherwise we keep whatever we recorded before adding the
	 spaces.

Pick-to: 6.8
Fixes: QTBUG-132075
Change-Id: I8d9a2f3197068f5f93520d217a6bb89633644e95
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 250117086ff15bba79df8f0e15ee66192edc9ea9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:24:35 +00:00
Eskil Abrahamsen Blomfeldt
51ed0b024b doc: Clarify usage of QFontMetricsF instead of QFontMetrics
A common source of issues is that people do not consider that
fonts can have fractional metrics and use QFontMetrics for UI
purposes, causing bounds and eliding to be inaccurate.

This is not very surprising, since the class name sounds very
much like what you should prefer by default and the docs
didn't even contain links to the QFontMetricsF class.

It might make sense to deprecate the class, since it really
does not serve any useful purpose, but for now we at least
document the issue up-front so that users can easily find
the alternative.

Pick-to: 6.8 6.5
Task-number: QTBUG-132102
Change-Id: I69756c561e5dee448a9d0a7d85af1a9b15ff1ae3
Reviewed-by: Nodir Temirkhodjaev <nodir.temir@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9a6036dea2cfe0cec555a503445aed93fed3d985)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:24:18 +00:00
Yuhang Zhao
d1c0eb2291 Windows theme: don't refresh anything unless theme really changed
Refreshing the global theme may be expensive for large scale applications, and even if Windows sent corresponding message,
it may be triggered by many reasons, not just the system theme,
so no matter what we'd better add an extra check.

Change-Id: I70847aa54fb4af37c81855a62330a4bce31ff104
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 9b924a4907a4a2b27ee52e807fd419caf219f655)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:24:11 +00:00
Ivan Solovev
b2bb9ef0f1 Refactor hasCompareThreeWay check
Use structs derived from std::false_type and std::true_type instead
of boolean constants. This allows us to make use of std::conjunction_v
and std::disjunciton_v in the conditions, thus making use of
short-circuit evaluation and saving unnecessary template
instantiations.

Still keep the constexpr bool *_v constant for the cases when we need
a signle check only.

Amends 678e9f614bc5a05d2ff16cf916397998e7cdfca1.

Pick-to: 6.8
Change-Id: If2ab48ef910e97f241f5922d4108a271bc532f3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8784ea16a6bc66ac481d5cbf2dd1ece2d57a836b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:23:29 +00:00
Tim Blechmann
9e22277d28 Cocoa: emit config error when using 15.0 as deployment target
QCocoaScreen uses removed APIs, which cause the code no fail compilation
with CMAKE_OSX_DEPLOYMENT_TARGET=15.0.
Adding a compile-time check to detect this early.

Task-number: QTBUG-128900
Pick-to: 6.8 6.5
Change-Id: I7eeb60f5769af6b1622efd1e0637e85a038b7930
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit b6f3695a80f5abfbcfb0ebb5b03358b8e7bbbaf9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:23:12 +00:00
Topi Reinio
3b4a7d4881 Doc: Set trademarks page in global configuration
The new \tm command appends a trademark symbol and links to the
trademark documentation page if `navigation.trademarkspage` variable
is set. As we have such a page in qtdoc repository, set the variable
in the global configuration. This works as all Qt module docs have a
dependency to the `qtdoc` documentation set.

Pick-to: 6.8
Task-number: QTBUG-124393
Change-Id: Iabc6e7e5afe5114eac79947f0feb512458f1c4da
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
(cherry picked from commit 429f565017f7213a91eb0cf43966b2148e0bb651)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:23:04 +00:00
Volker Hilsheimer
43ab4d5c7b QPainterStateGuard: make movable, add test coverage
There's no real reason not to be able to move a state guard.

Since a moved-from QPainterStateGuard must not have a restore-
level count, we have to implement the move-constructor explicily.
Add a test case, which verifies that we don't end up with an
un-balanced save/restore count, and that verifies that we would
trigger the Q_ASSERT if we do.

Address comment from header review,
amends 9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Task-number: QTBUG-132090
Change-Id: I1db135bf48c0fa0a7bac4fdae7b7263c356b5eb6
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit ec3a5f4994a2bafc65fa8e01fb0861219580f622)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 22:31:05 +00:00
Thiago Macieira
55a46ec005 QCommandLineParser: include the positional arguments' sizes in --help
We were mostly ignoring them because it looks like most people's options
were longer than their positional arguments. The rest must have just
accepted the enforced wrapping.

But if you have very short options like single-letter only ones or none
at all, the positional argument wrapping is unnecessarily short.

[ChangeLog][QtCore][QCommandLineParser] Made it so the positional
argument descriptions are taken into account in the aligning of text for
helpText().

Pick-to: 6.8
Fixes: QTBUG-131716
Change-Id: Ib1eee62c7cf4462f6a26fffdec233ba849ebf158
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 8928b0fbb9ca4caf9b63a32b3d2a73a6da096755)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 20:42:53 +00:00
Assam Boudjelthia
f10b13e469 Android: document androidtestrunner tool
Add documentation and usage of androidtestrunner tool.

Pick-to: 6.8
Fixes: QTBUG-84330
Change-Id: I03aa67ebf0ba807f20595547f2598d905080a878
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
(cherry picked from commit 5735d7ac861fe99a71d8044977e5f487c401ca12)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 20:10:38 +00:00
Tor Arne Vestbø
5051e2b97b Extend blacklisting of tst_QWidget::showMinimizedKeepsFocus to macOS 15
It's flaky on all version.

Pick-to: 6.8
Change-Id: I01b2f0877efc100578c55d69e9f9ed65c02b2aab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1ce019815ba62245fd8ae6e8fb5e47f77621c3be)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 20:10:38 +00:00
Ahmad Samir
d5cff9be0e QDecompressHelper: add comment for translators in readBrotli()
Spotted by Friedemann Kleint in code review.

Amends 763c47e055376bf6dbd4cd8fe1603b88aa3b72f0.

Change-Id: I3092c51964c167da30b6d1400ab2ba1e2f4df829
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit d983a402a5c7106935439c95d08eaadbf0b26b60)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 20:10:38 +00:00
Eirik Aavitsland
a994bc80fe Update bundled libjpeg-turbo to version 3.1.0
[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 3.1.0

Pick-to: 6.8 6.5 5.15
Change-Id: I321ae095b4ed826ceb940cbf13a63ec1a836acb3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 1a5afe625be1ed936d2fc4da98ed1c8fa574ee7b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 20:10:37 +00:00
Joerg Bornemann
8c3e5bcd21 Rename qscopedpointer.cpp -> qscopedpointer.qdoc
It only contains qdoc blocks and wasn't even listed in SOURCES.

Also changed the license to be in line with QUIP-18.

Pick-to: 6.8 6.5
Change-Id: I2c90300ddfd47c3f693dc84cb86f326fa185dd84
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
(cherry picked from commit 1cdf813e221b5aa133bc85cb928e329ef1dea896)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 12:54:39 +00:00
Joerg Bornemann
9834571282 CMake: Split off private module config packages
[ChangeLog][CMake] Private Qt modules have been split off into separate
Qt6FooPrivate CMake config packages. A call to find_package(Qt6Foo) will
now implicitly find_package(Qt6FooPrivate). It's not an error if
Qt6FooPrivate isn't available as it may be the case on certain Linux
distros that split their Qt module packages into private and public
parts.

For every public module Qt6Foo that has an associated Qt6FooPrivate
module, create a separate Qt6FooPrivate CMake config package.

Let Qt6FooPrivate find Qt6Foo. This is a required dependency.

Let Qt6Foo find Qt6FooPrivate if it's available. A message of log level
VERBOSE is issued if Qt6FooPrivate is not found.

Implementation notes: In QtModuleConfig.cmake.in, we pull in the private
module. This is not part of the *Dependencies.cmake file, because

1. The Qt6FooPrivate package references the Qt6::Foo target, therefore
it must be available. And Qt6FooDependencies.cmake is loaded before
creating targets.

2. The dependency needs to be optional, and we don't have facilities for
optional dependencies in Qt6FooDependencies yet.

3. We'd have to avoid recursion, because of the Qt6FooPrivate -> Qt6Foo
dependency.

Fixes: QTBUG-87776
Change-Id: I8f23f07da7ca76486f87b759e197174c11e13534
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 11:11:45 +00:00
Marc Mutz
072f2a2241 QXmlStreamReader: use QOffsetStringArray::viewAt()
This auto-computes the string's length without a NUL-byte scan, and
also fixes a GCC 14 unity-build C++23 warning:

  In function ‘constexpr qsizetype QtPrivate::lengthHelperPointer(const Char*) [with Char = char]’,
    inlined from ‘constexpr qsizetype QtPrivate::lengthHelperPointer(const Char*) [with Char = char]’ at qbytearrayview.h:69:28,
    inlined from ‘constexpr QLatin1String::QLatin1String(const char*)’ at qlatin1stringview.h:52:62,
    inlined from ‘constexpr QLatin1StringView contextString(QXmlStreamReaderPrivate::XmlContext)’ at qxmlstream.cpp:814:90,
    inlined from ‘void QXmlStreamReaderPrivate::checkToken()’ at qxmlstream.cpp:4018:85:
  qbytearrayview.h:77:16: warning: ‘strlen’ argument missing terminating nul [-Wstringop-overread]
     77 |     while (data[i] != Char(0))
        |            ~~~~^
  In file included from unity_0_cxx.cxx:412:
  qxmlstream.cpp: In member function ‘void QXmlStreamReaderPrivate::checkToken()’:
  qxmlstream.cpp:769:23: note: referenced argument declared here
    769 | static constexpr auto QXmlStreamReader_XmlContextString = qOffsetStringArray(
        |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Amends c4301be7d5f94852e1b17f2c2989d5ca807855d4, which was picked to
5.15, but didn't use QOffsetStringArray there (and unity-builds exist
only since 6.5), so only picking to 6.5.

Pick-to: 6.8 6.5
Change-Id: Ib50369aed6e8248fb88f43c7569c8a435c2b152e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 44366d07dca047f096d1366c43ba549c97150074)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 11:11:43 +00:00
Marc Mutz
da9ff584d1 Protect QT_ENABLE_STRICT_MODE_UP_TO against predefined individual opt-outs [6.9]
Since some of the Qt opt-outs are defined project-wide by the
buildsystem these days (e.g. QT_NO_QSNPRINF, ...), a module that
attempts to use QT_ENABLE_STRICT_MODE_UP_TO will hit warnings
regarding re-definition of these macros (definition on the compiler
command line, redefinition by qtconfigmacros.h).

To fix, guard the #define QT_NO_FOO's with #ifndef QT_NO_FOO.

Amends bd7d54249e3f2b6a9dd6b759c892d7c97d26c0aa (which was also picked
to 6.8).

Pick-to: 6.8
Change-Id: I88276c9ed01edde1495105cf5bd1e07b1fd244f4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 752de4a0aabc305af16251a55edf247e043b1b18)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 10:44:24 +00:00
Marc Mutz
d328e8eaaf Protect QT_ENABLE_STRICT_MODE_UP_TO against predefined individual opt-outs [6.8]
Since some of the Qt opt-outs are defined project-wide by the
buildsystem these days (e.g. QT_NO_FOREACH, QT_NO_JAVA_STYLE_ITERATOR,
...), a module that attempts to use QT_ENABLE_STRICT_MODE_UP_TO will
hit warnings regarding re-definition of these macros (definition on
the compiler command line, redefinition by qtconfigmacros.h).

To fix, guard the #define QT_NO_FOO's with #ifndef QT_NO_FOO.

Amends 3a6c8e02b6d1b0574da52b0087092d0c74aa92c1.

Pick-to: 6.8
Change-Id: I457457d1e60dbd9362b987157ba089adc67d1d6b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 0f416cbaaba46ddb039bbf33e1d70dbe80821d57)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 10:44:17 +00:00
Marc Mutz
6eb41440cd QTextStream: port from QScopedPointer to unique_ptr
In preparation of adding QT_NO_SCOPED_PONTER, which would be rather
pointless for users if public headers continued to mention the type.

Pick-to: 6.8
Task-number: QTBUG-132213
Change-Id: I6539e83158ab34e4fa4bd22b6d0ac5629a3b6db9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit b815c6f7fd71086c97fe6e9aa9472154be5fcc57)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 10:44:15 +00:00
Robert Löhning
e63884c593 QRadialGradient: Fix crash on huge x values
Credit to OSS-Fuzz

Fixes: QTBUG-130992
Pick-to: 6.8
Change-Id: Iefaa6964966f6828bc23a603f085d283189f1a3b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 42bd879e2bc6e0d8370d320cca17df36ea68d570)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-18 22:08:02 +01:00
Christian Ehrlicher
3c0f08ab70 QBoxLayout: don't crash on passing invalid index
Passing an invalid index gives an assertion in debug mode and crashes in
release mode due to an out-of-bounds access. Fix it by appending the
given widget (same as passing a negative index which is documented).

Pick-to: 6.8 6.5 6.2
Fixes: QTBUG-130275
Change-Id: Id0c245e185acc36e5d07cea1d22619bb0e9eee07
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 0f9062ec71021c256dba7ee8498f036d7aac0821)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 20:17:36 +00:00
Christian Ehrlicher
72f48d0840 Windows11Style: Fix horizontal scrollbar arrows in rtl mode
The arrows for horizontal scrollbars must be swapped in rtl mode.

Pick-to: 6.8
Change-Id: I517fcea19837a6438edc261e066930218b71ce28
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 02920ef05a980d9bb670e1f8a4b84e0b6cef13c1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 20:17:36 +00:00
Mårten Nordheim
ab667d881d Schannel: chop off garbage bytes if encryption fails
Because they would break communication (or loop infinitely) otherwise
since we use the presence of bytes in the returned buffer to know if
there is still something we need to transmit.

Amends 4e60a6b556d91ab797aebb7422666a685a726755

Change-Id: If72c1a142d4567f69d78177250b0218c5ca999fd
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 1efcc0df6adab11e7239f5f12a13766a58e2c1ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 20:17:36 +00:00
Topi Reinio
5fa520a77c Doc: Fix usage instructions for the \youtube macro
The example configuration included a space character that caused a
syntax error parsing the .qdocconf.

Replace the hardcoded qhp `QtDoc` project name with a placeholder.

Pick-to: 6.8
Change-Id: Iadf3a50e030f02182016ed9832f4f59d29f82c57
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
(cherry picked from commit 4051ec3356bded10cd7ac66dc1149259bc48d36b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 20:17:36 +00:00
Shawn Rutledge
019feea9b1 Always send QContextMenuEvent after the contextMenuEventType event
Both widgets and Qt Quick Controls are unable to avoid accepting the
right-click events (press and/or release) in at least some cases.
In the Windows UI pattern of allowing the user to select something by
pressing (and maybe dragging) with the right button and then getting
a QContextMenuEvent afterwards, it's sensible for the code that does
the selection to accept the mouse events, because that code is only
concerned with selection, not the context menu. And in Controls,
Pane is accepting all mouse events just to prevent propagation to
other controls underneath. (That might not be so great, but we don't
have a better way yet.) In legacy Qt Quick, accepting the event results
in an exclusive grab; so in fact, Pane gets the grab, so we can't use
that either, as a way to distinguish "stop propagation" from "this item
is handling it completely, nothing more needs to be done". So it
doesn't make sense for QWindowPrivate::maybeSynthesizeContextMenuEvent
to check the grabber either.

Amends 357c64a99607456133bfabf86d6b67162717cb29 and
84a5f50c7766c99f62b22bb4388137e0aa8dd13d

Task-number: QTBUG-67331
Task-number: QTBUG-93486
Task-number: QTBUG-132066
Fixes: QTBUG-132073
Change-Id: I822cada05cfef27afe6a44faf170585f027061f7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 70c61b12efe9d1faf24063b63cf5a69414d45cea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 20:17:35 +00:00
Lars Schmertmann
835475873b Avoid linter warning "AndroidGradlePluginVersion"
This is a Qt dependency that the user cannot influence.
We did this in  cfefce57a4ff446305cd1f839e7c5203bac7a6c5
with "GradleDependency"  before. It is a Qt dependency
that the user cannot influence.

Pick-to: 6.8 6.5
Change-Id: I01ef84eab7ab743d5ea9eb15208ef9c567dd2a43
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit ab2a0438ef8b6cc2c73ab0f33d353d00c6599cd9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 15:40:50 +00:00
Alexey Edelev
abfaf5189c Remove _qt_internal_find_dependencies
Clean up the dead code according to TODO statement.

Pick-to: 6.8
Change-Id: I9bdf10067d3a1324d584cebc51cf4555f00f717a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 64435289027d53c9dace16eaa38087369fee6c4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 14:13:05 +00:00
Mårten Nordheim
2aaaf7cf12 QThread: Link to QThreadPool::(set)serviceLevel
QThreadPool's functions already links to the QThread ones, but they didn't
link back.

From the API review.

Change-Id: I02853d8110806f735b748d022a1cfaea5a72d603
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit bbcf47a07d3ec138016d4f997c9b4849598c2f10)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 14:13:03 +00:00
Mårten Nordheim
0a4ff045f1 Http2: Ignore RST frames on already-closed streams
Some http servers like to send RST frames whenever they send their response.
The stream is already closed at that point so it's a little weird, but the
RFC doesn't disallow it, so we'll just ignore the frames.

Fixes: QTBUG-132124
Change-Id: Ic26e249437b739830935e2f3feec572687579b21
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 2c71fdf043ca94d1c567f169d51245e2702bec19)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 14:13:01 +00:00
Marc Mutz
aac98b795d QDebug: make std::optional stream operator SCARY
Piggy-back on the recently-added, type-erased, std::tuple stream
operator to handle std::optional the same way.

While std::optional doesn't support the Tuple Protocol, and we
therefore can't use putTuple() directly, we can still use
putTupleImplImpl() if we set up its arguments manually.

[ChangeLog][Potentially Source-Incompatible Changes][QDebug] The
std::optional streaming operator is now a member of QDebug, not a free
function. This breaks users that rely on the exact definition of the
operator (e.g. `operator<<(d, opt)`). A backwards-compatible fix is to
call the operator with infix notation (d << opt) only, and to avoid
const QDebug objects.

Change-Id: Ib040d65953ca9d3892aee5bdb597d6d30a9694b1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 08320bfe2b7387d6f488d405dddf9d3aba6434ec)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-18 10:05:26 +00:00
Marc Mutz
94928669c1 QByteArrayView: add a ctor for arrays of unknown bounds
This appears to not have worked, ever, so add it as a new feature, for
view API symmetry, not as a bug-fix.

The new constructor is available for all compatible byte types,
because it is more like the (ptr) constructor (which is available for
all compatible byte types) than the known-size-array constructor
(which is only available for char).

This does not affect QB/QBV overload sets, since they could exist
ambiguity-free only if one of them is a Q_WEAK_OVERLOAD.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the fromArrayWithUnknownSize test.

[ChangeLog][QtCore][QByteArrayView] Made construction from arrays of
unknown size compile. Such arrays will use the const Byte*
constructor, determining the size of the array at runtime.

Task-number: QTBUG-112746
Change-Id: I201033656f123b09644e5de447cd5d7b038e5154
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 54d47f8390cb85c5b0f0ac050b5aa5a934d798b0)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-18 08:07:37 +01:00
Friedemann Kleint
6cd5ea15ef Use QPainterStateGuard in examples
Complements 9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Change-Id: I65456f8fd34bf9d316b72c4286e1b15789309f7c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 1dc15c11db88f96a916258acea80a86bfa7c87cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 21:18:54 +00:00
Volker Hilsheimer
3339990b4b QPainterStateGuard: make InitialState enum scoped
Address comment from header review,
amends 9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Task-number: QTBUG-132090
Change-Id: Idddca104b93ee23f4bac8621f1087a0ae7a1fe24
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit ec011141b8d17a2edc58e0d5b6ebb0f1632fff90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 21:18:54 +00:00
Christian Ehrlicher
0dd2561d54 QStyleSheetStyle: Fix resetting fonts for subwidgets
When a compound widget is styled with a font through a property and the
default styling has no font settings, the font was not reset to the
parent font but left it the styled state.
Fix it by not resolving the current font when the style rule has no font
settings - use the parent font directly instead.

Fixes: QTBUG-131685
Pick-to: 6.8
Change-Id: I8e79423cfeff24143cd051b282503c4565125b4d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5731fe051e48e7a256ef31ae93cfb89ce8d871cc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 21:18:54 +00:00
Volker Hilsheimer
a8b8a6fd6d QPainterStateGuard: document that restore() asserts when already at 0
Address comment from header review, amends
9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Task-number: QTBUG-132090
Change-Id: Ie6eed6f83fcdde0f90514b6016a65905505073e0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 8ae4e3efdf80b658f8de19b13bfbea68e1dbd875)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 18:20:00 +00:00
Wladimir Leuschner
ad16cd816a WindowsQPA: Draw custom titlebar with QPainter
- Draw custom titlebars that are requested by setting the
  Qt::ExpandedClientAreaHint with QPainter instead of GdiPlus.
- Draw the application icon, in case it was set, for the custom titlebar
- Add DPI awareness to the custom titlebar

Change-Id: I276e7d8948e5a436f1835d96b59756b7237f63d2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 438aa1524ee99fd636dc02a7181857ade71bb101)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 15:14:12 +00:00
Timur Pocheptsov
c39a944e74 Revert "qnsview_drag: only ignore key modifier while dragging 'within the application'"
This reverts commit 4332cb313469de1525afe3cddd792d7bc7e08a14.
The original idea of distinguishing between context (outside/within application)
is not working anymore - it's always outside (except the moment when
a mouse pressed inside the window, which is immediately followed by
'outside application' context). So in fact we never ignore key
modifiers.

Fixes: QTBUG-132091
Pick-to: 6.8
Change-Id: I560a48ccf8f8ee1a55f812be6af18b1dd7e25c78
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 7740ac36d27740ff9204cc2626f58620b7e214cb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:23 +00:00
Ivan Solovev
cc2213ab27 Change QCommandLineParser::showMessageAndExit() argument order
Looking at other similar Qt APIs, the type argument usually comes first.
The typical related examples can be QMessageBox() constructor taking
QIcon as a first parameter, and qFormatLogMessage() function, taking
message type as a first parameter.

This patch changes the order of arguments, so that MessageType enum
comes as a first argument.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Found in Qt 6.9 API review.

Change-Id: Ibbdef755a8676a2c556fe7f1c95009ad51320b98
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 56114f4d1ed6ec26ff59a596caf09f5b4e0f5d68)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:23 +00:00
Ivan Solovev
e69e53de8e Add docs to the new QCommandLineParser::MessageType enum
As a drive-by: move the \since command in the showMessageAndExit() docs
to the right place.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Change-Id: I4e6e6d63929029879867624e4007941edfca9cd9
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 6692beace9bb5f461d71935e500e1c6ccfa97fd1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:23 +00:00
Bartlomiej Moskal
6e3d2ad44f Android: Fix for multi-ABI build in androiddeployqt
7499fd0229d63f969bf6ca58d3b764b96395bed2 commit cleans up the localLibs
to not add dependencies to the libs.xml file as they will not be
satisfied.

Mentioned change created a regression with multi-ABI build. It happens
because in qtDependencies[ARCH] container, some libs just have different
atchitecture prefix.

This commit remove architecture prefix when checking libs in
qtDependencies container.

Fixes: QTBUG-131707
Pick-to: 6.8
Change-Id: Iae54779bfa4bd143ec35353604724d8ec4e35ef2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit e59308c5119caac5d4f1024c7d8147e9887cb246)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:23 +00:00
Ivan Solovev
7c332839e0 Specify an underlying type for QCommandLineParser::MessageType
And also add a trailing comma to the last element of the enum to
minimize future diffs.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Found in Qt 6.9 API review.

Change-Id: I1a30c344967005c9abc73e59980e56626e09cd7c
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 14cc2591ac06dbcee01c2b110e014db2993d7a1e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:23 +00:00
Tor Arne Vestbø
9610a7cbdc QCocoaDrag: Only update m_lastView when it actually changes
The underlying QObjCWeakPointer used to track the view requires
a bit of bookkeeping, so avoid updating its value unless the
view actually changes.

Pick-to: 6.8
Change-Id: I6a1aeaf0e6e0eb221d55de00c8f30259832e58fa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 2e80e74f37980f62bb915983e61d6734fb416bcd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:23 +00:00
Tor Arne Vestbø
c8ae8244b4 QObjCWeakPointer: Clear existing associated object on assignment
If the existing m_object is the same as the incoming object the
call to objc_setAssociatedObject in trackObjectLifetime will
release the existing WeakPointerLifetimeTracker after assigning
a new one, which means we'd clear the QObjCWeakPointer's object.

We now reset the state up front.

Fixes: QTBUG-132256
Pick-to: 6.8
Change-Id: If2c08840d465ae6d190c87a4720a537fe9caa8dc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 92012333d112dbdf2926117ec3bb123bd30ed9fc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:22 +00:00
Christian Ehrlicher
9b2e444811 QAbstractItemView: use 'int' as datatype for updateThreshold
... to sync it with the rest of the api.
This amends ff339819925ab550c48b53d9baaba43e5adebfaa.

Task-number: QTBUG-124173
Change-Id: I0ed4681bf7d3717f84a7e888affb0c8cae877c35
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 15a1ae90f5b6da3ffd50acda63ddd33ca14227f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 10:52:59 +00:00
Marc Mutz
ee69826054 qthreadstorage.h: fix position of namespace macros
The file contains two implementations of the class template, one for
QT_CONFIG(thread) and one for without. Both are in the QT_NAMESPACE,
but each provided their own QT_{BEGIN,END}_NAMESPACE macro pair.

This is unneeded and may throw off scripts which use the macros as
insertion positions (like includemocs, which, however, operates on
.cpp files, not headers).

To fix, move the namespace macro pair to be around the #if
QT_CONFIG(thread) block.

Pick-to: 6.8 6.5
Change-Id: I56c1f9a4ef7df0fba54c72d8a213fa92573b826c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8553ffd8d147ecf6a713d12a360027b477dd59c8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 10:08:46 +00:00
Yuhang Zhao
3c0986a34c Windows: Fix title bar size calculation
The title bar calculation is terribly wrong and was
missed during review.

Change-Id: I0c7a860e747465e6a5e4d8aa5415a9701cf170fd
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit f6af3a581642170f0f4fe0d0563851715e045391)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 07:58:48 +00:00
Marc Mutz
9e86f73f82 QStringView: refuse construction from QStringRef
When QStringRef was moved out of QtCore, it was also incorrectly
removed from the if_compatible_container constraint, causing
QStringView{sr} to still match the general container QStringView ctor
overload, which doesn't preserve null'ness if data() doesn't return
null. By refusing to provide a constructor from QStringRef, we force
the compiler to use QStringRef's implicit conversion operators
instead.

This transitively affects QAnyStringView in the same way.

The tests can, naturally, only be in qt5compat, so define a macro to
communicate to tst_QStringRef whether it compiles against a fixed
QtCore or not.

Fixes: QTBUG-122797
Fixes: QTBUG-122798
Pick-to: 6.8 6.5
Change-Id: I64b75a8e421d2b6185615e3288ce3ad7fd8f15f9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit a0e65398483729259cf58781949133c6055fdc7c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:44:29 +00:00
Volker Hilsheimer
cdfd686714 QSqlQueryModel test: don't copy a QSqlQuery
Move the query into the model, and use a local scope to make sure that
we don't use the moved-from query later.

Change-Id: I9d216e770733af8b0771280276dba0775209a802
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Dheerendra Purohit <dheerendra@pthinks.com>
(cherry picked from commit af760da54190d96b315ea8edeec00c86871af0d8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:18:13 +00:00
Tor Arne Vestbø
78051d03ca Document that QPlatformTheme::standardPixmap should always be a 1x pixmap
This reverts 59bbfb17db563d7e62b9f3158dab3cc6e7e68acd and
c853054910552f5fef04797222dde0d29a0c340d, as that approach
was causing issues for QCommonStyle::iconFromWindowsTheme,
for example in situations where the system has a 1x and 2.5x
screen, and the user requests a 16x16 pixmap or icon via
QStyle::standardPixmap or QStyle::standardIcon. In that
situation our smallest pixmap is 40x40, and we need to
downscale, causing blurred results on a 1x screen.

Change-Id: Ifa6e15d37d15954df689253c32eaa779885c567b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d884abaf8bdc1be74ee52306948c0be1986d738d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:13:30 +00:00
Christian Ehrlicher
eab71ff6b0 Windows11Style: adjust subline color in editable widgets in dark mode
The color of the subline in editable widgets was black in light and dark
mode. Fix it to use white in dark mode to make it visible. Move it out
into own helper function since it's used in at least three places.

Pick-to: 6.8
Task-nubmer: QTBUG-131585
Fixes: QTBUG-131586
Change-Id: Icca2b142a1ce0c3d7f722baa6d3635bae5950e1c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 66d42b62b6f01205cf1db72e56ecb5166554e373)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:13:28 +00:00
Christian Ehrlicher
07ad8c8444 QStyleOptionViewItem: document 'widget' and 'locale' member
These two members were added during Qt4 times but never documented.

Pick-to: 6.8 6.5
Change-Id: Ife4abfc6d8883f4c26ce5b95d5c0cfd3adcbd6bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
(cherry picked from commit a90d9f4823bd6baf4cb660a942c2b1695441dbbd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 19:37:58 +00:00
Eskil Abrahamsen Blomfeldt
501f78855e Fix DirectWrite subpixel antialiasing on BGR screens
On monitors where the subpixel arrangement is blue, green, red,
our DirectWrite rendering would give the wrong subppixel
antialiasing, causing color fringes on text.

Like we do with Freetype, we determine subpixel arrangement of the
primary screen and use this as the default.

Pick-to: 6.8
Change-Id: I9ce7025449106a2376bd0ed02ce07b59c79438bd
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit d5cef74d8d71458500f979c0d31a7241b3fef9db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 19:37:56 +00:00
Eskil Abrahamsen Blomfeldt
bfb80b7b45 Support variation selector when emoji segmenter is disabled
This amends cb2633468413d8c2a9e28d4c4a10b25e90dd3116.

The patch excluded the ad hoc parsing of variation selector
except when Qt was built without the emoji segmenter. The
reasoning being that the emoji parsing handles this correctly
now.

However, when setting the QT_DISABLE_EMOJI_SEGMENTER variable
in the environment, this is supposed to work as a fail safe
which gives you the original behavior, in case there are
regressions. Therefore, the variation selector handling needs
to be run also when this environment variable is set.

Change-Id: I2669d29016a552775461aad13e50459baecdc26f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit aaf7437db3a520ab14220a46cf9427cb9a8d915c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 19:37:55 +00:00
Eskil Abrahamsen Blomfeldt
f5e2166bbd DirectWrite: Remove ad hoc font resolution through GDI
In b8612eaa2a17e12e31ee28141cff1fb43e54c00e, we added a fail safe
where failure to find the font name through DirectWrite would
try loading it through GDI instead and if that was successful we
would register the family with the database after all.

However, the code assumed that CreateFontIndirect() would return
NULL if the font did not exist. It does not do this, but instead
selecting the HFONT on the HDC will give us a suitable alternative
instead. The result would be that any missing font family would
be registered with the font database through this mechanism, even
if it really didn't exist.

This code was added in an early version of the patch, however,
and it should not actually be needed anymore, since we in later
versions of the same patch also added logic to populate the
GDI-compatible family names
(DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES etc.). This should
take care of backwards compatibility with the GDI names for fonts.

Since the code has been reported to cause problems on some systems,
it's safest to just remove this hack.

Pick-to: 6.8
Task-number: QTBUG-130313
Change-Id: I7eca893d17796d9cac07391b7b947d28dd7cd920
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 355f54f7d5dd300c73bf203f12e24305d0e227c1)
2024-12-16 15:24:24 +01:00
Andy Shaw
9988cd2469 SQLite: Fix attrition file to have right version number
Pick-to: 6.8 6.5 5.15
Change-Id: I9fea5c8d19209c44b16916645e600735de929d80
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 311ac55f118dc88add297853318cd0cfd7c1c0d5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 07:13:13 +00:00
Assam Boudjelthia
440dcaca27 Android: handle quotes in hard-coded namespace in build.gradle
Remove quotes from the namespace values if they're set
directly to build.gradle.

Fixes: QTBUG-132150
Pick-to: 6.8
Change-Id: I7f5e132c2600bf5079850c99dc500b1dff7e6a96
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 60f78212379ba2b4a7a9bfadc5088a60309e923c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 18:29:03 +00:00
Magdalena Stojek
7ab145a9ef Output both global and local data tags in benchmark result header
Modified QPlainTestLogger::printBenchmarkResultsHeader() to
concatenate and display both global and local data tags, in
the benchmark result header, in the format `global:local`.
If only one tag is available, it is printed alone.

Pick-to: 6.8 6.5
Fixes: QTBUG-127522
Change-Id: Ic9f3c712ef3f6858aad2546b80d8867ce860b644
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
(cherry picked from commit 95f02adf756d1ae485f39a060c6f23a5af3f64ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 18:04:39 +00:00
Michael Weghorn
b5ba125fa0 QMenu: Accept accelerators typed on keypad
Add Qt::KeypadModifier (and the combination with Qt::AltModifier) to the
modifiers that may be set in a key event in order to trigger a menu
action via its accelerator.

Otherwise, an action that has a number set as the accelerator (e.g.
using text "&1 Exit"), cannot be triggered by typing the corresponding
number on the keypad.

Fixes: QTBUG-73390
Pick-to: 6.8
Change-Id: I0fa63b0c5f23823c61e159fcc72f7245215f8aae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit ca4334bc966c7e5f9997f98b83afe37eb8b1d3ba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 17:20:11 +00:00
Christian Ehrlicher
c437c6a4f6 Style: pass widget to styleHint() where appropriate
QStyle::styleHint() take the QWidget as optional third parameter. Add
this to calls to styleHint() where appropriate.

Fixes: QTBUG-2501
Pick-to: 6.8
Change-Id: Id4e4158cc889236064f2f618495608736607d457
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit aa341ecca816e3503a834ffde0ec6cb817139427)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:46:27 +00:00
Thiago Macieira
ff303c5cd9 QMutex/FreeBSD: mark the functions as noexcept as it always has futex
See qfutex_freebsd_p.h.

Pick-to: 6.8
Change-Id: I7e7bbb8387ae2e7b0c39fffd65c7b03e3a65a853
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit c1bc98da02f0f9335e10f45cc5df4c7e3afcee31)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:35 +00:00
Fabian Kosmale
510f8005bc moc: Always indentify as moc
External tools might rely on the output of "moc --version" to identify
moc, and, depending on how robust their parsing is, could break if the
reported name does not equal "moc".

Explicitly set the application name to moc, so that even if the moc
binary gets renamed and invoked via a symlink, it will still correctly
identify itself.

This might help with both binaries from the Qt Company's installer, as
well as with distros which rename moc to moc6.

Pick-to: 6.8 6.5
Task-number: QLS-1605
Change-Id: Id85e2ffa17d445213da0b37e7bd038d7b68e2c2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 47be32b761ea6e1f2c1bfa9dd9eb38846ce2fd45)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:35 +00:00
Thiago Macieira
e9509291ae QSharedMemorySystemV: fix shm vs sem typo
Fixes: QTBUG-132053
Pick-to: 6.8
Change-Id: Ia4f2bdc8edff91020f13fffd79261a9feaf2f496
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 902058e750e67bbfb166db576c538b7add9be08f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:35 +00:00
Thiago Macieira
7664b826db QMetaType: remove the temporary QMetaTypeTypeFlags compatibility
Amends 44876fb45e702c2554fca98ed19af57feb1c0511.

Change-Id: I5ea354bcb6847e996081fffd012130562999d5c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e48fe10e541c6dec9db4226f8ad02728de7b0e02)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Ivan Solovev
8bd0625f54 [docs] Add QSpan details to overview of C++20 features
Document that QSpan exists because we cannot use std::span, and
explicitly point to the differences between QSpan and std::span.

Task-number: QTBUG-128837
Pick-to: 6.8
Change-Id: I54f406e3306ee1da136107323887f0c87f94ff9b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 083ebfa1a5cb16b0b62ae5b5855a602b2f9ba818)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Eirik Aavitsland
4d009678ce Fix in-place conversion of certain QImage formats
In the copying/transcription of the generic converter to the generic
in-place converter, a test for Format_RGB32 destination format was
mistakenly replaced with test of source format. The result was that a
suboptimal pixel store function was selected, and the resulting image
data could end up with non-0xff in the unused alpha field.

Task-number: QTBUG-132051
Pick-to: 6.8
Change-Id: If3ebf5fdd7ab6e377c8ad479ea38ce665f922b7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 0ace5ba0357b1614b47cb38a16f4afb2fe8e62db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Edward Welbourne
e2a0ef30da Fix assertion failure on parsing Feb 29 in a non-leap year
If there's no way to resolve an actual date with the data parsed, then
the date-text given is invalid, so don't try to fix it up.

Pick-to: 6.8 6.5
Fixes: QTBUG-132115
Change-Id: Ic6821bd01394d4dba1be1d25806c372800f8176b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 72519aeb237a4085aeb6290b0b4088c690fad106)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Mårten Nordheim
d53feb3da2 QHash: fix small performance regression when detaching with resize
There are two QHashPrivate::Data constructors (and two overloads of
::detached()). Initially the Data ctor that takes a new size always
assumed a resize was happening, and any place where there _may_ be a
resize we would usually detach then rehash.

In an effort to avoid the detach+rehash and instead call detach(d, size)
without the performance overhead of rehashing the call to
reallocationHelper() in this overload of the ctor was changed to verify
that a rehash was actually needed. This had the unfortunate side-effect
of making the compiler no longer inline the reallocationHelper()
function, and it no longer expanded the if-expression with the constant
so it was doing a tight copy-loop with a potential branch in the middle.

In this patch we revert that and make the bool a template argument to
highlight that it should be a constant for better performance (but also
leaving a comment.) Also mark it Q_ALWAYS_INLINE, it has two uses and
they both take advantage of the inlining + expanding the expression.

In theory this might have had an impact on QHash::reserve() calls,
though this code is only relevant when reserve() would cause growth so
the performance regression would hopefully be small compared to all the
other work that would also be needed.

Reverts 45c137d797a85c694897e8b1c5099abacc16e2f5

Pick-to: 6.8
Change-Id: I0d2076a9ded8ca816c54d6ce42d472a23bcbc9fd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6c8b6acc894e47a37c4fb443316d9c40d35a144c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:33 +00:00
Edward Welbourne
7baf9d06b5 Fix typos in qstring.cpp (noticed while reviewing other changes)
Pick-to: 6.8
Change-Id: Ief8a9c429b5cdf424e0c3a57d15b1fcb4fdc963c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 5d5c8d277af77cba069b805074551254c0f0d9c7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:33 +00:00
Mårten Nordheim
9d7fabb6c2 QHash: call the different detached() overloads depending on resize
Instead of using just the detached() overload taking a new size, call
the two un-sized one when not resizing. The unsized overload is faster
because it is inlining the reallocationHelper() function and expanding
a branch by way of a constant.

And drop the call to rehash in the !isDetached case, if we enter this
branch we willfully 'attach' the detach guard to keep the key and values
alive.

Follow-up change will fix the sized detach() to use a constant again.

Amends d9ad2251d9fff85a18ce5afc62bcb1230cd2820d

Change-Id: Ia1640766b898610d12b5df20d83cefe5ca2d4c36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ac2b0b958e97c41b38c42c0789d91de724d567ce)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:33 +00:00
Marc Mutz
51bfc9da41 Q{Any,Utf8}StringView: fix construction from arrays of unknown size
Like QStringView's, these classes' documentation promised
is_constructible<View,Char[]>, but failed to deliver, because neither
the (const Pointer&) nor the (const Container &) compile for arrays of
unkonwn bounds, and the (const Char*) one is just a QDoc fake.

Apply the same fix as for QStringView: Add a ctor specifically for
arrays of unknown bound, delegating to the (ptr) overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QUtf8StringView/QAnyStringView] Made construction
from arrays of unknown size compile. Such arrays will use the const
Char* constructor, determining the size of the array at runtime.

Pick-to: 6.8 6.5
Fixes: QTBUG-112746
Change-Id: I7acdcae3c5bdf80a0bed673e621d53ef34a92a1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 734bd05d0a6d37d6488cf8d1b2b9f79b9329d966)
2024-12-13 14:31:08 +01:00
Marc Mutz
1f0dc7635e QLatin1StringView: put qstringfwd.h in control of Q_L1S_VIEW_IS_PRIMARY
Less duplication, matches what we do for q_no_char8_t namespaces, too.

Amends 94addad4dd1c89df9c6820d34b9a90424456c492.

Pick-to: 6.8 6.5
Change-Id: I5d98babcb66d1196d3aed31c33289a1b11212a3d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 2d2ee569421338dbc07a479a7df2531bd37f0ebe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:53 +00:00
Marc Mutz
137da0326a QStringView: use qstringfwd.h
... instead of fwd-declaring a bunch of stuff manually.

Also move the fake QDoc decalaration of a "class QUtf8StringView"
over.

Pick-to: 6.8 6.5
Change-Id: I80bc3240d69f69602c127fc0e8fe694dd46765f1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 8404c21152ed3e28f8e00d683a494a8e1e25a69a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:47 +00:00
Ulf Hermann
60d28c8c7c Android: Fix some warnings
Use a static logging category where possible, and check the return value
of QFile::open.

Change-Id: Ieda9f7874d1b88d9bfeb593243eb867d0c274e9f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e0ef713a2c6a74fe574481e98f0a582819418ed0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:42 +00:00
Marc Mutz
e076767bfd qstringfwd.h: don't include qglobal.h
qstringfwd.h is supposed to be a lean header, dragging in all of
qglobal.h perverts the purpose.

This also helps with certain circular-dependency issues that
appeared when attempting to use this header in other low-level
headers.

Amends abe3b4c9b947de5e55085b37840e0d1d6f3aae42.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore] The
qstringfwd.h header no longer includes qglobal.h. A
backwards-compatible fix is to include qglobal.h yourself instead of
relying on the transitive include.

Pick-to: 6.8 6.5
Change-Id: I1726fccfd13b3a058abaf800c1bbf02c320143a4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 5def8ff180c67f288bdc6e3c05b96940aeae37c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:41 +00:00
Kai Köhne
c76b845d90 Doc: Fix links to QIODeviceBase:: flags
Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: Iee545986d4fb4765086fecce6532092d4b691ae8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d3dad28a51743bb408dee1cf997646a89eb6693b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:52 +00:00
Kai Köhne
604dcc714a Doc: Improve QTemporaryFile::open() descriptions
Explain the behavior of open() in detail, including the edge
cases (reopening a file). Fix links to QIODeviceBase::OpenMode
flags. Use explicit links to make linking more robust. Use
the same parameter name 'mode' as in the base class.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I5d01b3bb48a7a439b93c144e6d38482607de8d33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit adaf1fb107ceb7003313ceb67605f986b74763b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:46 +00:00
Kai Köhne
b70e61788f Doc: Improve QProcess setStandardOutputFile description
Fix links to OpenMode flags. While at it, make links explicit so
that future changes breaking implicit linking will cause errors.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I20b80014eadcbcba6ebebab1ff4db4c345dd434a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4e85a4f401118f2f7330b673e45b4a0399825ef3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:39 +00:00
Kai Köhne
5d2f40a14b Doc: Improve QBuffer::open description
Explain the method, instead of just linking to the base method.

Call the argument 'mode' instead of 'flags', like it is done in
the base class.

Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form
for the rest to improve readability.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I8e9668ffc095ec261e2be54a2dcf16a32e4cb441
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 334460407b7cde1cdab5cfe5abe00175893749c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:33 +00:00
Kai Köhne
eb44663eaa Doc: Improve QFile::open description
Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form for
the rest to improve readability.

Mark true and false to be written in code style.

Task-number: QTBUG-131484
Pick-to: 6.8
Change-Id: Iebb0f9c6df382327bc5980e9e06c11deb6658291
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 647bee67150dedbd2a9fd2ddcd265d535e8fd8cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:27 +00:00
Marc Mutz
83e18b6540 qstringfwd.h: add missing QString fwd decl
qstringfwd.h should probably fwd declare QString, too :o

Amends abe3b4c9b947de5e55085b37840e0d1d6f3aae42.

Pick-to: 6.8 6.5
Change-Id: I80558c92d1144ead0aade410a8b1810713fed701
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit bc4105c843f666eaeaaa44b5a1f897ffa5824ec7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:10:54 +00:00
Marc Mutz
df2f31b9bf qsocketnotifier.cpp: un-break -unity-build
qsocketnotifier.cpp is using a #define to activate a second overload
of QSocketNotifier's activated() signal.

In unity-builds, this overload becomes visible to other TUs and breaks
new-style connect()s¹. In PCH builds, the define comes too late (the
qsocketnotifier.h header was already included by the pch header,
without the define).

Fix by adding qsocketnotifier.cpp to NO_PCH_SOURCES (thereby to
NO_UNITY_BUILD_SOURCES, too).

¹ and the signal's use of QPrivateSignal makes disambiguation by
  qOverload(), or assignment to a function pointer, impossible.

Amends 487dd80bce9c6006f349ccb09222e1c308200f0a(!).

Pick-to: 6.8 6.5 5.15
Change-Id: I40ca3b90f7ecc3116ae78dc952583efa299bcedb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit a38cebfe23674bb459eed6bbbcac965ebf2b6075)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:29 +00:00
Marc Mutz
e8605372ba qsettings.cpp: really un-break -unity-build
The use of Space was still ambiguous. Says GCC 14:

  qsettings.cpp: In static member function ‘static bool QConfFileSettingsPrivate::readIniLine(QByteArrayView, qsizetype&, qsizetype&, qsizetype&, qsizetype&)’:
  qsettings.cpp:1564:82: error: reference to ‘Space’ is ambiguous
   1564 |     while (lineStart < dataLen && (charTraits[uint(uchar(data.at(lineStart)))] & Space))
        |                                                                                  ^~~~~
  In file included from unity_0_cxx.cxx:277:
  qjsonparser.cpp:217:5: note: candidates are: ‘<unnamed enum> Space’
    217 |     Space = 0x20,
        |     ^~~~~
  qsettings.cpp:1523:8: note:                 ‘SettingsImpl::<unnamed enum> SettingsImpl::Space’
   1523 | enum { Space = 0x1, Special = 0x2 };
        |        ^~~~~
  qsettings.cpp:1605:71: error: reference to ‘Space’ is ambiguous
   1605 |                 while (i < dataLen && charTraits[uchar(data.at(i))] & Space)
        |                                                                       ^~~~~
  qjsonparser.cpp:217:5: note: candidates are: ‘<unnamed enum> Space’
    217 |     Space = 0x20,
        |     ^~~~~
  qsettings.cpp:1523:8: note:                 ‘SettingsImpl::<unnamed enum> SettingsImpl::Space’
   1523 | enum { Space = 0x1, Special = 0x2 };
        |        ^~~~~

Fix by making Space and Special local aliases (contexpr variables)
instead of importing the whole SettingsImpl namespace.

Amends 4ff65f0e5615b1132ec13c6eeba3647162d8dd0f.

Pick-to: 6.8 6.5
Change-Id: I9e8f2422885121fb02938261fbae6231e62ae46d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 057defe283f1db5fa9dfb1d8183b94d441c3707b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:22 +00:00
Marc Mutz
00f6df326f qresource.cpp: fix -unity-build
GCC 14 complains:

  In file included from unity_0_cxx.cxx:121:
  qresource.cpp:283:7: error: ‘QResourcePrivate’ has a field ‘QList<{anonymous}::QResourceRoot*> QResourcePrivate::related’ whose type has internal linkage [-Werror=subobject-linkage]
    283 | class QResourcePrivate {
        |       ^~~~~~~~~~~~~~~~

(Hot-)fix by adding qresource.cpp to NO_UNITY_BUILD_SOURCES.

Amends fe6dda9bb9310878b408b2421f60acb7135bd8ba.

Pick-to: 6.8
Task-number: QTBUG-132114
Change-Id: Ic414d1cf9e4dad94d4263b3657d31df896c4e417
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 57fab6a1c2df8f52b25f6db4017bb3acfa8e0526)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:16 +00:00
Marc Mutz
06a209384a tst_QString: extend arg() tests with enums w/o explicit underlying_type
The QtDeclarative code causing QTBUG-131906 hits UB, because it tries
to store -666 in an enum {A, B}, which has a valid range of [0,1],
therefore its underlying_type is uint, yet, as per [conv.prom]/3¹,
integer-promotes to _int_ instead, so in Qt 6.8 would cause the
arg(int) overload to be called, outputting -666, while in Qt 6.9, it's
treated (correctly) as an unsigned value, outputting -666's two's
complement, a positive value.

Add a version of the scenario that does not cause UB.

¹ Thanks to Ahmad Samir for digging up the pertinent legalese.

Task-number: QTBUG-131906
Pick-to: 6.8 6.5
Change-Id: Iba1a04de523a0b4cd1c87deea40c643cf16df14f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e64fd05fecae291c9d7358d2e47d7170995af256)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:12 +00:00
Thiago Macieira
b143215c54 QString: update docs to prefer "UTF-32" over "UCS-4"
They are now the same, but the name UTF-32 is preferred over UCS-4.

The original ISO-10646 UCS-4 encoding was allowed to use all 31-bit code
units, from 0 to 0x7FFFFFFF[1] including those above 0x10FFFF, which
correspond to UTF-8's five- and six-byte sequences. Unicode doesn't
allow that and restricts the UTF to the range possible in UTF-16.

Renaming the functions is left as an exercise for the reader.

[1] https://en.wikipedia.org/wiki/UTF-32#History

Pick-to: 6.8
Change-Id: I2f29db62b974cb689585fffd9a6434ae252a7651
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 973d0c4c5160200c188f81da5df064510315f22d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:25 +00:00
Marc Mutz
31e3012296 tst_QStringView: verify that char16_t[] args aren't ambiguous for QS/QSV overloads
They are not.

Pick-to: 6.8
Task-number: QTBUG-112746
Change-Id: I2a20d68543f5914690acbcb4f214b1d98681de6a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 67990c16a6b631c1d809d1ad656fc941293b3f83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:23 +00:00
Thiago Macieira
bb91219b26 QString::fromUcs4: use std::char_traits or wcslen() to find the size
... when the user passes size = -1. std::char_traits<char32_t>::length()
doesn't appear to be an any better implementation than our simple loop,
but maybe some compiler will optimize it.

wcslen() is usually optimized in the C libraries, even for Unix
platforms that hardly ever use it (it's used as a fallback in qustrlen()
for non-x86 Windows systems).

Pick-to: 6.8
Change-Id: Ia143270869a3a7cf5754fffdc17e500fc454397b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit b98cf4fc4afaf55145c34ba06d61fec38fadc25d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:19 +00:00
Marc Mutz
2dfc0cb6f6 QStringView: fix construction from arrays of unknown size
The original idea (8b5aa7b6c40d70a7ec15b3ea485f28a142fb247c) of the
separation of array and pointer ctors was to determine string literal
sizes at compile-time in C++11's limited constexpr semantics.

But when the scanning for NUL characters was added to the array ctor
in 107ff4c1d6b5da2cb11c65b2bd9106817f7fdb02, the distinction between
the two ctors became meaningless, because we were able to assume
post-C++11 constexpr to make the Char(0) scan a compile-time action.

Finally, 9e1dc1e8a9fda1a7576cc6377c8a36decff631eb removed the array
ctor in favor of the generic Container ctor. I didn't check whether
the old code handled arrays of unknown size, as in

    extern const char16_t str[];
    QStringView sv = str;
    ~~~
    const char16_t str[] = "str";

but std::size() (and therefore if_compatible_container) surely bails
on such arrays, and if_compatible_pointer also SFINAEs out. As a
consequence, such arrays cannot be used to construct QStringViews atm.

Fix by adding a new constructor for arrays of unknown size, delegating
to the existing pointer overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QStringView] Made construction from arrays of
unknown size compile. Such arrays will use the const Char*
constructor, determining the size of the array at runtime.

Pick-to: 6.8 6.5
Task-number: QTBUG-112746
Change-Id: Ifdb217350d93d38f081c99f14661975491d32076
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 56faffd92bf0ac459a921ec043a6f3b3dba51acc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:16 +00:00
Ulf Hermann
2a512fd901 Use inline namespaces rather than "using" for logging categories
Amends commit fa4bd30caa079a3b1e5eac1bb4f17365f456b8f9.

Fixes: QTBUG-132111
Change-Id: Iad7969a1841b8cea162e4b0e6624d02313618ef1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 529ebb31702e8465a9ba42f4c56c749cb7bf7b75)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:16 +00:00
Marc Mutz
443bdb9620 tst_QAnyStringView: complete Char[] CanConvert sets
Other view tests test Char[N] and const Char[N] separately. Do the
same here.

For many Char types, the array CanConvert test was missing
completely. Add them.

Pick-to: 6.8 6.5
Change-Id: I1d0b6de394d548554a547f190e74cb8cead6ecd4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 0bbbbfc78beb2393ceea0de0fa85942f71d0a2ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:54 +00:00
Ahmad Samir
149150ab47 QtSql: fix GCC -Wextra-semi warnings after member function definitions
Pick-to: 6.8
Change-Id: I5b65f543d7a36386181e493d8b9ce0267132d686
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 291c762802a2f5e1edb6bd9a842663ca5689323a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:51 +00:00
Marc Mutz
29e2695676 tst_QStringApiSymmetry: test QByteArray(weak)/QByteArrayView overloading
Adding it here since this test case already has all the infrastructure
for the overload test.

Pick-to: 6.8 6.5
Change-Id: I2d7fff9d2d82fed3db2446690a354f939c9a37fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 140dac92f2a8ee1f54843f69be4026900a049ee7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:48 +00:00
Ahmad Samir
dbaef86144 Fix GCC -Wextra-semi warnings with Q* macros
Namely, Q_ENUM, Q_DECLAR_FLAGS, Q_FLAG, Q_DECLARE_EQUALITY_COMPARABLE.

The sanitize-commit (from qtrepotools repo) git hook already warns about
these.

Pick-to: 6.8
Change-Id: If53f446c7c19856c4a5be1e0b0156e1892871dae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 8d3601dfe8e6a89cbf0ab0ff8089e232f52c21d2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:44 +00:00
Marc Mutz
9bcbeea2ad tst_QByteArrayView: check conversion from various QSpans
This is supposed to work, so check it.

Pick-to: 6.8
Change-Id: I201033656f123b09644e5de447cd5d7b038e5155
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 8a3ffe7044249bcfb5185bd87a9713685d48de7b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:41 +00:00
Ivan Solovev
7044c32963 Fix docs for QSet (in)equality operators
The missing '&' prevented qdoc from generating the docs.

Amends f9f3bf79dccbfcabbd5c59c39f9f018d71b7549f.

Change-Id: I1d8d7a4e2f4c46c4c365cb5a5e38877837881c45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 03389d47902347e858bbafc990de3ab988c07acf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:39 +00:00
Ahmad Samir
8472fc2573 Fix GCC -Wextra-semi after member function definitions
Fixes: QTBUG-132101
Pick-to: 6.8
Change-Id: Ia2e13bdaf11c639c5590639717b5d31140352c44
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6b951f6c0c09b7d7b473a3951e7b6cec41dbec73)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:37 +00:00
Volker Hilsheimer
3de6c570fb QFontIconEngine: if we can't find the named glyph, try ligatures
Use QTextLayout to layout and shape the text, which will respect
ligatures. Many icon fonts might not name their icons, but have a
replacement ligature for the actual icon name replacing the text with
the respective glyph.

So if for the name of the icon we get a single glyph run with a single
glyph in it, use that to render the icon.

Change-Id: If0e5c528c3ac4cccdbb7df5fb7fd32ca232f2a66
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit d10e9174fecb91b5c366d57aeb19e6410522a807)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 14:28:37 +00:00
Volker Hilsheimer
8b4a8b1e10 QFontIconEngine: always initialize with a non-merging font
The icon engine needs to be able to rely on glyph indices belonging to
the correct font, and we generally don't want the overhead of iterating
through potential fallbacks if a named glyph or unicode code point
wasn't found in the font.

Assert in the QFontIconEngine constructor that the font we get has the
NoFontMerging strategy bit set.

Amends 2af58490b3d33aab8d08610939fe2b7cab4c469c.

Change-Id: Ib38324aebbeda956c8dd053969d6cf08f7ef3c35
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 9d47233d2cbbae1aa32240688fcc7a8c08c585d3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 14:28:34 +00:00
Tatiana Borisova
609d34d702 [QDomNodePrivate] delete unnecessary pointer check from the statement
- prev pointer never can be null here, so the check can be deleted.

Ammends 948599e7b71f59fd9c9c0f7f3d1987ec93a23490

Pick-to: 6.8
Change-Id: Ie194f5f0432f6da5f6471328193112c970f623b6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit d991572a45b2bbdcd43e59586f88487837a2927c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 14:27:27 +00:00
Eirik Aavitsland
49cf61f641 QWidget::mapTo()/mapFrom(): Do not crash if parent argument is invalid
These functions iterate through the parent hierarchy until the widget
given as argument is found. If never found, the code would assert (in
debug mode) or just silently crash (in release mode).

No need to bring down the entire application just because some widget
coordinate calculation is off. Instead, just emit a qWarning and
return cleanly.

Task-number: QTBUG-132072
Pick-to: 6.8
Change-Id: I4d13f46037cdcf855f76e040f941a8a7050ab12b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 73221d263823d50e525858d613ce93769698454a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 14:27:25 +00:00
Piotr Wierciński
80e581d91b wasm: Link with FETCH library only for MAIN_MODULE
For dynamic linking only the main module should
link with libraries like "FETCH".
When side modules are linking to libraries as well,
it leads to linking errors.

Change-Id: I83e37add867f1ce2cbcab4801f49266a288a9ceb
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit b7419557b1b0cc1a87aa91131329b65aee44ec34)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 13:17:02 +00:00
Tor Arne Vestbø
b3c60bd11f iOS: Iterate accessible interface to find window
Many subclasses of QAccessibleInterface implement window(), but
some don't, and the documentation states that the backend (us)
will traverse ancestors until it finds one with a window.

We were not doing that for iOS, which caused a crash for
QAccessibleTabButton, which doesn't have a window.

In case we ever hit the code path where we can't find a
window we also skip adding the nil element to the array
in createAccessibleElement, as that causes an exception.

Amends 7a512d1267442e646bb7942291197b2b03f4d1cd

Pick-to: 6.8 6.5
Change-Id: I9b758423956e845a01b014022f4d3ab6306be94e
Reviewed-by: Doris Verria <doris.verria@qt.io>
(cherry picked from commit 6689921b9da3780676a416324eafcac98ab211a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-11 10:49:23 +00:00
Shawn Rutledge
8a7ee8d522 Widgets: ignore unhandled right mouse button presses
In many places this was already done; but there was some old code
remaining where mousePressEvent() simply returned without ignoring the
unhandled event.

Task-number: QTBUG-93486
Task-number: QTBUG-132066
Change-Id: I4a876980b7ef88ee478fa8cfd9f68b5be5b217a2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit a1175255150d27d50f9690d5f8685b31269d9fa1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-11 09:33:35 +00:00
Ivan Solovev
d0a3db5d93 [doc] Clean-up QSpan docs
QSpan docs use \target commands together with the section headers, to
simplify linking to certain parts of the docs. This approach has its
own drawbacks, though, because the \target link is rendered as-is.
This patch improves usage of the \target commands, making the links
look better.
It does the following changes:
* Moves the \target commands before the related \section2 commands, so
  that the section header is visible when following the \target's link.
* Replaces the \target links with the actual section names in the \sa
  and other places of the docs where the links do not have the custom
  text, because otherwise the target names are actually visible in the
  docs instead of the section headers.

Amends 03e78e5d624d9752d76c7448d58c9d9d15a4dc18,
70dc8d3103fade380caec96f7531432cd8e8adb6, and
ef5ac956c755daa9ea84dabfa1314d104e5c62e4.

Pick-to: 6.8
Change-Id: I045824683f342079e33e89e3ee6f8e2e27a0acf5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 10c844f0533daf657a1cbbbb96651e20e5d603ec)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-11 00:51:17 +00:00
Marc Mutz
67adc2227d tst_QStringView: add missing CanConvert from char16_t/wchar_t arrays
QChar[N] and ushort[N] are being checked, it's unclear why char16_t[N]
and wchar_t[N] were missing.

Add them.

Pick-to: 6.8 6.5 5.15
Change-Id: I9a2df2a75886b950e8c2bdec843e3e693e536f86
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 89401858696d63b8a13c945d5db63856a3b6f5ba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-11 00:06:27 +00:00
Marc Mutz
0c054f6844 Confirm QLatin1StringView can be constructed over arrays of unknown bounds
It can (unlike the other views).

Pick-to: 6.8 6.5 5.15
Task-number: QTBUG-112746
Change-Id: Id976429611c53f1c707de1d989c454507b8f4773
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 01f0305dc6f751d3eb4d1681a2f8f9f3165b547c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-11 00:06:21 +00:00
Shawn Rutledge
f329dd4e16 QWidgetWindow: send QContextMenuEvent even after accepted mouse press
It would be more consistent if we could rely on the accepted state of
the original QMouseEvent to decide whether to follow up with a
QContextMenuEvent; but not all Qt widgets call ignore() on unhandled
mouse events, both in Qt and in external libraries and applications
(including some from KDE). So we should at least wait until Qt 7 to
make this a requirement. It seems sensible to move the check into
QWindow::event() rather than trying to distinguish the window type in
maybeSynthesizeContextMenuEvent(). We merely output a categorized log
message to indicate when the legacy behavior is in effect.

Amends 84a5f50c7766c99f62b22bb4388137e0aa8dd13d

[ChangeLog][QtWidgets] If your QWidget subclass depends on receiving
QContextMenuEvent, and also handles mouse events directly, we
recommend that you call ignore() on unhandled mouse events (such as
right-button events). In Qt 7, we plan to stop sending
QContextMenuEvent if the triggering mouse event is accepted.

Fixes: QTBUG-132066
Change-Id: I454813dab4c387112f161fc28a0ee94570013afa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 357c64a99607456133bfabf86d6b67162717cb29)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 23:51:13 +00:00
Christian Ehrlicher
75cb14deb8 SQLite: Update SQLite to v3.47.2
[ChangeLog][Third-Party Code] Updated SQLite to v3.47.2

Pick-to: 6.8 6.5 5.15
Change-Id: I3f40198db02c7f9599189ec2a0001f1c294616c8
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
(cherry picked from commit f3d5bdf4bcfe26a17b1b3de07a345586c37263c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 19:58:41 +00:00
Dheerendra Purohit
a77b11c548 QToolBar: Update implicit icon size if style changes
Add logic in QToolBar::changeEvent() to update icon size set via
stylesheet.

Fixes: QTBUG-45949
Pick-to: 6.8
Change-Id: I7fce830a969af8774116f0229153668252b55598
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 18733355689fc3ea336631b9c5ff17e3e983fb28)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 17:26:03 +00:00
Lars Schmertmann
43f4706ee8 Android: Fix typo in the documentation of the default log pattern
Pick-to: 6.8 6.5
Task-number: QTBUG-94708
Change-Id: I845f193f1b98219be205b8615f817f3315f4d149
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 3bec93738ea88b6f2f50f1b5eeb2237f6f43c0b6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 17:26:03 +00:00
Marc Mutz
5c3fd55beb QSpan: document slice() and chop()
Needed to use a weird combination of \c and \a here, as qdoc on
one hand insists that all parameters be documented, and OTOH doesn't
support \a within \c.

Writing anything else than the equivalent code in \c to appease qdoc
would be childish. Equivalent code is the best-possible documentation,
as it leaves no question unanswered.

Task-number: QTBUG-131672
Change-Id: I512872360b7eb212001723f2ba12d4c6eac0b6b0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 0afe31fa51a26d12be21c1b9c6e886abb9775441)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 17:26:02 +00:00
Edward Welbourne
66da88f428 Fix typo in QTZ constructor docs
There is no fromSecondsAfterUtc(), I was thinking of
fromSecondsAheadOfUtc().

Pick-to: 6.8 6.5
Fixes: QTBUG-131913
Change-Id: I6a89a27d678d23043819b93d5e4120d01002da4a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 2bdce97480ed66f0e8e9528fbc8f4f9c3d8487bf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 17:26:02 +00:00
Yuhang Zhao
7c3723b2a9 Minor improvements of windows style
1. Make some global constants constexpr.
2. Make some file-scope global constants static.
3. Use QStringLiteral instead of plain const char*
4. Add "u" to QStringLiteral's content.

Pick-to: 6.8
Change-Id: Icbc105366ba40e970b256fe3da41231a6fb5064b
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit ad06099b93d79a954d133d6822517d4d0a10adbc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-10 08:26:00 +00:00
Wladimir Leuschner
1a737083f1 QWindows11Style: Override alternate base color in darkmode
The alternate base color in darkmode was wrongly set to the accent color
instead of a lighter color. This patch overrides the alternate base
color for the QWindows11Style.

Fixes: QTBUG-131976
Pick-to: 6.8
Change-Id: Ie8f50b0042ca7bf746224275abc0cd255df7a4ad
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 79aa4269bcbbedef8206d79318c199df7c8a3c9f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-09 21:54:52 +00:00
Allan Sandfeld Jensen
901731ad78 Add primary RGB color points getter
[ChangeLog][QtGui][QColorSpace] Added primary points getter and setter

Change-Id: Ia4e412b3e63584cf88fa632e5c1d47618d07ebf1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit bde2292247bf4849852355c0dcc71f97c9daace9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-09 19:46:45 +00:00
472 changed files with 195980 additions and 178648 deletions

View File

@ -24,7 +24,7 @@ SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GPL-3.0-only"
path = ["bin/*", "coin/**","libexec/*","**_clang-format", "**.cmake", "**.conf", "**.cmake.in",
"**.prf", "libexec/qt-internal-configure-*", "config.tests/.qmake.conf",
"**.pro", "**.pri", "**.yaml", "cmake/**.in", "cmake/ios/LaunchScreen.storyboard",
"cmake/**md", "**.yml", "**.dynlist",
"cmake/**md", "**.yml", "**.dynlist", "cmake/**.plist",
"src/corelib/global/qconfig.cpp.in", "src/corelib/Qt6CoreConfigureFileTemplate.in",
"**.cfg"]
precedence = "closest"

View File

@ -152,7 +152,12 @@ function(qt_auto_detect_android)
endfunction()
function(qt_auto_detect_vcpkg)
if(QT_USE_VCPKG AND DEFINED ENV{VCPKG_ROOT})
if(QT_USE_VCPKG)
if(NOT DEFINED ENV{VCPKG_ROOT})
message(FATAL_ERROR
"Usage of vcpkg was requested but the environment variable VCPKG_ROOT is not set."
)
endif()
set(vcpkg_toolchain_file "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
get_filename_component(vcpkg_toolchain_file "${vcpkg_toolchain_file}" ABSOLUTE)

View File

@ -366,7 +366,15 @@ if(APPLE)
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
if(IOS)
if(MACOS)
# Test entitlements
qt_copy_or_install(FILES "cmake/${platform_shortname}/test.entitlements.plist"
DESTINATION "${__GlobalConfig_install_dir}/${platform_shortname}"
)
file(COPY "cmake/${platform_shortname}/test.entitlements.plist"
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
elseif(IOS)
qt_copy_or_install(FILES "cmake/ios/LaunchScreen.storyboard"
DESTINATION "${__GlobalConfig_install_dir}/ios"
)

View File

@ -246,6 +246,7 @@ function(qt_internal_get_qt_build_private_files_to_install out_var)
QtGenerateLibPri.cmake
QtGenerateVersionScript.cmake
QtModuleConfig.cmake.in
QtModuleConfigPrivate.cmake.in
QtModuleDependencies.cmake.in
QtModuleHeadersCheck.cmake
QtModuleToolsConfig.cmake.in
@ -292,8 +293,17 @@ function(qt_internal_get_qt_build_public_helpers out_var)
QtPublicGitHelpers
QtPublicPluginHelpers
QtPublicPluginHelpers_v2
QtPublicSbomAttributionHelpers
QtPublicSbomCpeHelpers
QtPublicSbomDepHelpers
QtPublicSbomFileHelpers
QtPublicSbomGenerationHelpers
QtPublicSbomHelpers
QtPublicSbomLicenseHelpers
QtPublicSbomOpsHelpers
QtPublicSbomPurlHelpers
QtPublicSbomPythonHelpers
QtPublicSbomSystemDepHelpers
QtPublicTargetHelpers
QtPublicTestHelpers
QtPublicToolHelpers

View File

@ -169,9 +169,8 @@ function(qt_internal_force_allow_unsuitable_cmake_version_for_building_qt out_va
# Temporarily allow any version when building in Qt's CI, so we can decouple the provisioning
# of the minimum CMake version from the bump of the minimum CMake version.
# The COIN_UNIQUE_JOB_ID env var is set in Qt's CI for both build and test work items.
# Current state is that this check is enabled.
# TODO: Disable it once provisioning is merged.
set(allow_any_version_in_ci TRUE)
# Current state is that this check is disabled.
set(allow_any_version_in_ci FALSE)
if(allow_any_version_in_ci AND DEFINED ENV{COIN_UNIQUE_JOB_ID})
set(allow_any_version TRUE)

View File

@ -38,6 +38,7 @@ macro(qt_find_apple_system_frameworks)
qt_internal_find_apple_system_framework(FWEventKit EventKit)
qt_internal_find_apple_system_framework(FWHealthKit HealthKit)
qt_internal_find_apple_system_framework(FWUniformTypeIdentifiers UniformTypeIdentifiers)
qt_internal_find_apple_system_framework(FWOpenGL OpenGL)
endif()
endmacro()

View File

@ -10,7 +10,8 @@ function(qt_get_library_name_without_prefix_and_suffix out_var file_path)
if(NOT file_path MATCHES "^-") # not a linker flag
get_filename_component(basename "${file_path}" NAME_WE)
get_filename_component(ext "${file_path}" EXT)
if(NOT ext) # seems like a library name without prefix and suffix
if(NOT ext AND NOT IS_ABSOLUTE "${file_path}")
# seems like a library name without prefix and suffix
set(${out_var} "${file_path}" PARENT_SCOPE)
return()
endif()

View File

@ -32,7 +32,47 @@ if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@ExtraProperties.cmake"
OPTIONAL)
endif()
# Find the private module counterpart.
if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND AND NOT @arg_NO_PRIVATE_MODULE@)
if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
if("${_qt_cmake_dir}" STREQUAL "")
set(_qt_cmake_dir "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
endif()
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
set(__qt_use_no_default_path_for_qt_packages "")
endif()
find_package(@INSTALL_CMAKE_NAMESPACE@@target_private@ "@PROJECT_VERSION@" EXACT
QUIET
CONFIG
PATHS
${QT_BUILD_CMAKE_PREFIX_PATH}
"${CMAKE_CURRENT_LIST_DIR}/.."
"${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
${__qt_use_no_default_path_for_qt_packages}
)
endif()
if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
get_property(@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown GLOBAL PROPERTY
@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown
)
if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown)
message(VERBOSE
"The private module package '@INSTALL_CMAKE_NAMESPACE@@target_private@' "
"could not be found. It possibly needs to be installed separately with your "
"package manager."
)
set_property(GLOBAL PROPERTY
@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown ON
)
endif()
endif()
endif()
if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
# DEPRECATED
# Provide old style variables for includes, compile definitions, etc.
# These variables are deprecated and only provided on a best-effort basis to facilitate porting.

View File

@ -0,0 +1,51 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
@PACKAGE_INIT@
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
include(CMakeFindDependencyMacro)
# Find required dependencies, if any.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Dependencies.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Dependencies.cmake")
_qt_internal_suggest_dependency_debugging(@target_private@
__qt_@target_private@_pkg ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
endif()
# If *ConfigDependencies.cmake exists, the variable value will be defined there.
# Don't override it in that case.
if(NOT DEFINED "@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND")
set("@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND" TRUE)
endif()
if(NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@AdditionalTargetInfo.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@ExtraProperties.cmake"
OPTIONAL)
endif()
if(TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target_private@)
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@VersionlessTargets.cmake")
else()
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@VersionlessAliasTargets.cmake")
endif()
endif()
else()
set(@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND FALSE)
if(NOT DEFINED @INSTALL_CMAKE_NAMESPACE@@target_private@_NOT_FOUND_MESSAGE)
set(@INSTALL_CMAKE_NAMESPACE@@target_private@_NOT_FOUND_MESSAGE
"Target \"@QT_CMAKE_EXPORT_NAMESPACE@::@target_private@\" was not found.")
if(QT_NO_CREATE_TARGETS)
string(APPEND @INSTALL_CMAKE_NAMESPACE@@target_private@_NOT_FOUND_MESSAGE
"Possibly due to QT_NO_CREATE_TARGETS being set to TRUE and thus "
"${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Targets.cmake was not "
"included to define the target.")
endif()
endif()
endif()

View File

@ -32,16 +32,20 @@ endif()
set(__qt_@target@_third_party_deps "@third_party_deps@")
@third_party_deps_extra_info@
_qt_internal_find_third_party_dependencies("@target@" __qt_@target@_third_party_deps)
unset(__qt_@target@_third_party_deps)
# Find Qt tool package.
set(__qt_@target@_tool_deps "@main_module_tool_deps@")
_qt_internal_find_tool_dependencies("@target@" __qt_@target@_tool_deps)
unset(__qt_@target@_tool_deps)
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(__qt_@target@_target_deps "@target_deps@")
set(__qt_@target@_find_dependency_paths "${CMAKE_CURRENT_LIST_DIR}/.." "${_qt_cmake_dir}")
_qt_internal_find_qt_dependencies("@target@" __qt_@target@_target_deps
__qt_@target@_find_dependency_paths)
unset(__qt_@target@_target_deps)
unset(__qt_@target@_find_dependency_paths)
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES "@qt_module_dependencies@")
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE)

View File

@ -340,6 +340,9 @@ function(qt_internal_add_module target)
)
set_property(TARGET "${target_private}" APPEND PROPERTY
EXPORT_PROPERTIES "${export_properties}")
# Let find_package(Qt6FooPrivate) also find_package(Qt6Foo).
qt_register_target_dependencies("${target_private}" "Qt::${target}" "")
endif()
# FIXME: This workaround is needed because the deployment logic
@ -691,6 +694,12 @@ function(qt_internal_add_module target)
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
if(NOT arg_NO_PRIVATE_MODULE)
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target_private}")
qt_path_join(private_config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
qt_path_join(private_config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
endif()
unset(path_suffix)
set(extra_cmake_files)
set(extra_cmake_includes)
@ -781,10 +790,9 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
qt_internal_get_min_new_policy_cmake_version(min_new_policy_version)
qt_internal_get_max_new_policy_cmake_version(max_new_policy_version)
configure_package_config_file(
"${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
INSTALL_DESTINATION "${config_install_dir}"
qt_internal_write_basic_module_package("${target}" "${target_private}"
CONFIG_BUILD_DIR ${config_build_dir}
CONFIG_INSTALL_DIR ${config_install_dir}
)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake")
@ -794,38 +802,44 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
list(APPEND extra_cmake_files "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake")
endif()
write_basic_package_version_file(
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${INSTALL_CMAKE_NAMESPACE}${target}"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
)
qt_install(FILES
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersionImpl.cmake"
${extra_cmake_files}
DESTINATION "${config_install_dir}"
COMPONENT Devel
)
file(COPY ${extra_cmake_files} DESTINATION "${config_build_dir}")
set(exported_targets ${target})
if(NOT ${arg_NO_PRIVATE_MODULE})
list(APPEND exported_targets ${target_private})
if(NOT arg_NO_PRIVATE_MODULE)
qt_internal_write_basic_module_package(${target} ${target_private}
PRIVATE
CONFIG_BUILD_DIR ${private_config_build_dir}
CONFIG_INSTALL_DIR ${private_config_install_dir}
)
endif()
set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
qt_install(TARGETS ${exported_targets}
EXPORT ${export_name}
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${INSTALL_LIBDIR}
file(COPY ${extra_cmake_files} DESTINATION "${config_build_dir}")
set(targets_to_export ${target})
if(NOT ${arg_NO_PRIVATE_MODULE})
list(APPEND targets_to_export ${target_private})
endif()
_qt_internal_forward_function_args(
FORWARD_PREFIX arg
FORWARD_OUT_VAR export_module_args
FORWARD_OPTIONS NO_ADDITIONAL_TARGET_INFO
)
qt_internal_export_module(${target}
${export_module_args}
CONFIG_BUILD_DIR ${config_build_dir}
CONFIG_INSTALL_DIR ${config_install_dir}
)
if(NOT arg_NO_PRIVATE_MODULE)
qt_internal_export_module(${target_private}
${export_module_args}
CONFIG_BUILD_DIR ${private_config_build_dir}
CONFIG_INSTALL_DIR ${private_config_install_dir}
)
endif()
if(BUILD_SHARED_LIBS)
qt_apply_rpaths(TARGET "${target}" INSTALL_PATH "${INSTALL_LIBDIR}" RELATIVE_RPATH)
@ -839,29 +853,6 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
QT_ANDROID_MODULE_INSTALL_DIR ${INSTALL_LIBDIR})
endif()
qt_install(EXPORT ${export_name}
NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
DESTINATION ${config_install_dir})
if(NOT arg_NO_ADDITIONAL_TARGET_INFO)
qt_internal_export_additional_targets_file(
TARGETS ${exported_targets}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}")
endif()
qt_internal_export_modern_cmake_config_targets_file(
TARGETS ${exported_targets}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_BUILD_DIR "${config_build_dir}"
CONFIG_INSTALL_DIR "${config_install_dir}"
)
qt_internal_export_genex_properties(TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}"
)
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
if(NOT arg_HEADER_MODULE)
@ -986,6 +977,104 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
qt_add_list_file_finalizer(qt_finalize_module ${target} ${arg_INTERNAL_MODULE} ${arg_NO_PRIVATE_MODULE})
endfunction()
# Write and install the basic Qt6Foo and Qt6FooPrivate packages.
#
# If PRIVATE is specified, write Qt6FooPrivate.
# Otherwise write its public counterpart.
#
# Note that this function is supposed to be called from qt_internal_add_module, and depends on
# variables set in the scope of that function, e.g. target and target_private.
function(qt_internal_write_basic_module_package)
set(no_value_options
PRIVATE
)
set(single_value_options
CONFIG_BUILD_DIR
CONFIG_INSTALL_DIR
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
if(arg_PRIVATE)
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target_private}")
set(module_config_input_file "QtModuleConfigPrivate.cmake.in")
else()
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target}")
set(module_config_input_file "QtModuleConfig.cmake.in")
endif()
configure_package_config_file(
"${QT_CMAKE_DIR}/${module_config_input_file}"
"${arg_CONFIG_BUILD_DIR}/${package_name}Config.cmake"
INSTALL_DESTINATION "${arg_CONFIG_INSTALL_DIR}"
)
write_basic_package_version_file(
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${package_name}"
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersion.cmake"
)
qt_install(FILES
"${arg_CONFIG_BUILD_DIR}/${package_name}Config.cmake"
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersion.cmake"
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersionImpl.cmake"
DESTINATION "${arg_CONFIG_INSTALL_DIR}"
COMPONENT Devel
)
endfunction()
function(qt_internal_export_module target)
set(no_value_options
NO_ADDITIONAL_TARGET_INFO
)
set(single_value_options
CONFIG_BUILD_DIR
CONFIG_INSTALL_DIR
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
qt_install(TARGETS ${target}
EXPORT ${export_name}
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${INSTALL_LIBDIR}
)
qt_install(EXPORT ${export_name}
NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
DESTINATION ${arg_CONFIG_INSTALL_DIR})
if(NOT arg_NO_ADDITIONAL_TARGET_INFO)
qt_internal_export_additional_targets_file(
TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${arg_CONFIG_INSTALL_DIR}")
endif()
qt_internal_export_modern_cmake_config_targets_file(
TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_BUILD_DIR "${arg_CONFIG_BUILD_DIR}"
CONFIG_INSTALL_DIR "${arg_CONFIG_INSTALL_DIR}"
)
qt_internal_export_genex_properties(TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${arg_CONFIG_INSTALL_DIR}"
)
endfunction()
function(qt_internal_apply_apple_privacy_manifest target)
# Avoid "INTERFACE_LIBRARY targets may only have whitelisted properties" error on CMake < 3.17.
get_target_property(target_type ${target} TYPE)

View File

@ -2,15 +2,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Find "ModuleTools" dependencies, which are other ModuleTools packages.
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
set(__qt_@target@_tool_deps "@package_deps@")
foreach(__qt_@target@_target_dep ${__qt_@target@_tool_deps})
list(GET __qt_@target@_target_dep 0 __qt_@target@_pkg)
list(GET __qt_@target@_target_dep 1 __qt_@target@_version)
if (NOT ${__qt_@target@_pkg}_FOUND)
find_dependency(${__qt_@target@_pkg} ${__qt_@target@_version})
endif()
endforeach()
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE)
set(__qt_@target@_tool_third_party_deps "@third_party_deps@")
_qt_internal_find_third_party_dependencies("@target@" __qt_@target@_tool_third_party_deps)
set(__qt_@target@_tool_deps "@package_deps@")
_qt_internal_find_tool_dependencies("@target@" __qt_@target@_tool_deps)

View File

@ -29,8 +29,12 @@ if (NOT QT_NO_CREATE_TARGETS)
# Find required dependencies, if any.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
else()
set(@target@_FOUND TRUE)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
if(@target@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
endif()
endif()

View File

@ -1,11 +1,12 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
set(@target@_FOUND FALSE)
set(@target@_FOUND TRUE)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_@target@_third_party_deps "@third_party_deps@")
_qt_internal_find_third_party_dependencies("@target@" __qt_@target@_third_party_deps)
unset(__qt_@target@_third_party_deps)
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
@ -17,5 +18,9 @@ set(__qt_@target@_target_deps "@target_deps@")
set(__qt_@target@_find_dependency_paths "@find_dependency_paths@")
_qt_internal_find_qt_dependencies("@target@" __qt_@target@_target_deps
__qt_@target@_find_dependency_paths)
unset(__qt_@target@_target_deps)
unset(__qt_@target@_find_dependency_paths)
set(@target@_FOUND TRUE)
if(__qt_${target}_missing_deps)
set(@target@_FOUND FALSE)
endif()

View File

@ -29,7 +29,7 @@ macro(qt_collect_third_party_deps target)
endif()
unset(_target_is_static)
foreach(dep ${${depends_var}} ${optional_public_depends} ${extra_third_party_deps})
foreach(dep ${${depends_var}} ${extra_third_party_deps})
# Gather third party packages that should be found when using the Qt module.
# Also handle nolink target dependencies.
string(REGEX REPLACE "_nolink$" "" base_dep "${dep}")
@ -48,9 +48,6 @@ macro(qt_collect_third_party_deps target)
if(dep_seen EQUAL -1 AND package_name)
list(APPEND third_party_deps_seen ${dep})
get_target_property(package_is_optional ${dep} INTERFACE_QT_PACKAGE_IS_OPTIONAL)
if(NOT package_is_optional AND dep IN_LIST optional_public_depends)
set(package_is_optional TRUE)
endif()
get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
if(NOT package_version)
set(package_version "")
@ -143,6 +140,13 @@ function(qt_internal_remove_qt_dependency_duplicates out_deps deps)
endfunction()
function(qt_internal_create_module_depends_file target)
set(no_value_options "")
set(single_value_options "")
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
get_target_property(target_type "${target}" TYPE)
set(is_interface_lib FALSE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
@ -156,11 +160,6 @@ function(qt_internal_create_module_depends_file target)
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
unset(optional_public_depends)
if(TARGET "${target}Private")
get_target_property(optional_public_depends "${target}Private" INTERFACE_LINK_LIBRARIES)
endif()
# Used for collecting Qt module dependencies that should be find_package()'d in
# ModuleDependencies.cmake.
get_target_property(target_deps "${target}" _qt_target_deps)
@ -337,7 +336,6 @@ function(qt_internal_create_plugin_depends_file target)
get_target_property(depends "${target}" LINK_LIBRARIES)
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
get_target_property(target_deps "${target}" _qt_target_deps)
unset(optional_public_depends)
set(target_deps_seen "")
@ -398,7 +396,6 @@ function(qt_internal_create_qt6_dependencies_file)
set(actual_target Platform)
get_target_property(public_depends "${actual_target}" INTERFACE_LINK_LIBRARIES)
unset(depends)
unset(optional_public_depends)
set(third_party_deps "")
set(third_party_deps_seen "")
@ -467,6 +464,9 @@ function(qt_internal_create_depends_files)
foreach (target ${repo_known_modules})
qt_internal_create_module_depends_file(${target})
if(TARGET "${target}Private")
qt_internal_create_module_depends_file(${target}Private)
endif()
endforeach()
foreach (target ${QT_KNOWN_PLUGINS})

View File

@ -844,9 +844,9 @@ function(_qt_internal_get_cached_xcode_version out_var)
set(${out_var} "${xcode_version}" PARENT_SCOPE)
endfunction()
# Warn when the platform SDK or Xcode version are not supported.
# Warn or error out when the platform SDK or Xcode version are not supported.
#
# The warnings are currently only shown when building Qt, not when building user projects
# The messages are currently only shown when building Qt, not when building user projects
# with CMake.
# The warnings ARE shown for qmake user projects.
#
@ -891,11 +891,14 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
endif()
# The default differs in different branches.
set(failed_check_should_error FALSE)
set(failed_check_should_error TRUE)
if(failed_check_should_error)
# Allow downgrading the error into a warning.
if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK)
#
# Our cmake build tests might be executed on older not officially supported Xcode or SDK
# versions in the CI. Downgrade the error in this case as well.
if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK OR QT_INTERNAL_IS_CMAKE_BUILD_TEST)
set(message_type WARNING)
set(extra_message " Due to QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK being ON "
"the build will continue, but it will likely fail. Use at your own risk.")

View File

@ -55,9 +55,8 @@ function(__qt_internal_force_allow_unsuitable_cmake_version_for_using_qt out_var
# Temporarily allow any version when using Qt in Qt's CI, so we can decouple the provisioning
# of the minimum CMake version from the bump of the minimum CMake version.
# The COIN_UNIQUE_JOB_ID env var is set in Qt's CI for both build and test work items.
# Current state is that this check is enabled.
# TODO: Disable it once provisioning is merged.
set(allow_any_version_in_ci TRUE)
# Current state is that this check is disabled.
set(allow_any_version_in_ci FALSE)
if(allow_any_version_in_ci AND DEFINED ENV{COIN_UNIQUE_JOB_ID})
set(allow_any_version TRUE)

View File

@ -34,6 +34,9 @@ macro(_qt_internal_find_third_party_dependencies target target_dep_list)
find_package(${__qt_${target}_find_package_args})
else()
find_dependency(${__qt_${target}_find_package_args})
if(NOT ${__qt_${target}_pkg}_FOUND)
list(APPEND __qt_${target}_missing_deps "${__qt_${target}_pkg}")
endif()
endif()
_qt_internal_get_package_components_id(
@ -129,7 +132,6 @@ macro(_qt_internal_find_qt_dependencies target target_dep_list find_dependency_p
list(GET __qt_${target}_target_dep 1 __qt_${target}_version)
if (NOT ${__qt_${target}_pkg}_FOUND)
# TODO: Remove Private handling once sufficient time has passed, aka all developers
# updated their builds not to contain stale FooDependencies.cmake files without the
# _qt_package_name property.
@ -149,19 +151,13 @@ macro(_qt_internal_find_qt_dependencies target target_dep_list find_dependency_p
${_qt_additional_packages_prefix_paths}
${__qt_use_no_default_path_for_qt_packages}
)
if(NOT ${__qt_${target}_pkg}_FOUND)
list(APPEND __qt_${target}_missing_deps "${__qt_${target}_pkg}")
endif()
endif()
endforeach()
endmacro()
# TODO: Remove once a dependency update completes and most developers have the Dependencies.cmake
# files updated in their builds.
# The name is too generic, it doesn't look for any kind of dependencies but only Qt package
# dependencies.
macro(_qt_internal_find_dependencies target_dep_list find_dependency_path_list)
_qt_internal_find_qt_dependencies("none" "${target_dep_list}" "${find_dependency_path_list}")
endmacro()
# If a dependency package was not found, provide some hints in the error message on how to debug
# the issue.
#

View File

@ -0,0 +1,516 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Handles attribution information for a target.
#
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is set, a separate sbom target is created for each parsed
# attribution entry, and the new targets are added as dependencies to the parent target.
#
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is not set, the information read from the first attribution
# entry is added directly to the parent target, aka the the values are propagated to the outer
# function scope to be read.. The rest of the attribution entries are created as separate targets
# and added as dependencies, as if the option was passed.
#
# Handles multiple attribution files and entries within a file.
# Attribution files can be specified either via directories and direct file paths.
# If ATTRIBUTION_ENTRY_INDEX is set, only that specific attribution entry will be processed
# from the given attribution file.
function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
if(NOT QT_GENERATE_SBOM)
return()
endif()
if(CMAKE_VERSION LESS_EQUAL "3.19")
message(DEBUG "CMake version is too low, can't parse attribution.json file.")
return()
endif()
set(opt_args
CREATE_SBOM_FOR_EACH_ATTRIBUTION
)
set(single_args
PARENT_TARGET
)
set(multi_args "")
_qt_internal_get_sbom_specific_options(sbom_opt_args sbom_single_args sbom_multi_args)
list(APPEND opt_args ${sbom_opt_args})
list(APPEND single_args ${sbom_single_args})
list(APPEND multi_args ${sbom_multi_args})
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(attribution_files "")
set(attribution_file_count 0)
foreach(attribution_file_path IN LISTS arg_ATTRIBUTION_FILE_PATHS)
get_filename_component(real_path "${attribution_file_path}" REALPATH)
list(APPEND attribution_files "${real_path}")
math(EXPR attribution_file_count "${attribution_file_count} + 1")
endforeach()
foreach(attribution_file_dir_path IN LISTS arg_ATTRIBUTION_FILE_DIR_PATHS)
get_filename_component(real_path
"${attribution_file_dir_path}/qt_attribution.json" REALPATH)
list(APPEND attribution_files "${real_path}")
math(EXPR attribution_file_count "${attribution_file_count} + 1")
endforeach()
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is set, that means the parent target was a qt entity,
# and not a 3rd party library.
# In which case we don't want to proagate options like CPE to the child attribution targets,
# because the CPE is meant for the parent target.
set(propagate_sbom_options_to_new_attribution_targets TRUE)
if(arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION)
set(propagate_sbom_options_to_new_attribution_targets FALSE)
if(NOT arg_PARENT_TARGET)
message(FATAL_ERROR "PARENT_TARGET must be set")
endif()
endif()
if(arg_ATTRIBUTION_ENTRY_INDEX AND attribution_file_count GREATER 1)
message(FATAL_ERROR
"ATTRIBUTION_ENTRY_INDEX should only be set if a single attribution "
"file is specified."
)
endif()
set(file_index 0)
set(first_attribution_processed FALSE)
foreach(attribution_file_path IN LISTS attribution_files)
# Collect all processed attribution files to later create a configure-time dependency on
# them so that the SBOM is regenerated (and CMake is re-ran) if they are modified.
set_property(GLOBAL APPEND PROPERTY _qt_internal_project_attribution_files
"${attribution_file_path}")
# Set a unique out_prefix that will not overlap when multiple entries are processed.
set(out_prefix_file "${out_prefix_outer}_${file_index}")
# Get the number of entries in the attribution file.
_qt_internal_sbom_read_qt_attribution(${out_prefix_file}
GET_ATTRIBUTION_ENTRY_COUNT
OUT_VAR_VALUE attribution_entry_count
FILE_PATH "${attribution_file_path}"
)
# If a specific entry was specified, we will only process it from the file.
if(NOT "${arg_ATTRIBUTION_ENTRY_INDEX}" STREQUAL "")
set(entry_index ${arg_ATTRIBUTION_ENTRY_INDEX})
else()
set(entry_index 0)
endif()
# Go through each entry in the attribution file.
while("${entry_index}" LESS "${${out_prefix_file}_attribution_entry_count}")
# If this is the first entry to be processed, or if CREATE_SBOM_FOR_EACH_ATTRIBUTION
# is not set, we read the attribution file entry directly, and propagate the values
# to the parent scope.
if(NOT first_attribution_processed AND NOT arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION)
# Set a prefix without indices, so that the parent scope add_sbom call can
# refer to the values directly with the outer prefix, without any index infix.
set(out_prefix "${out_prefix_outer}")
_qt_internal_sbom_read_qt_attribution(${out_prefix}
GET_DEFAULT_KEYS
ENTRY_INDEX "${entry_index}"
OUT_VAR_ASSIGNED_VARIABLE_NAMES variable_names
FILE_PATH "${attribution_file_path}"
)
# Propagate the values to the outer scope.
foreach(variable_name IN LISTS variable_names)
set(${out_prefix}_${variable_name} "${${out_prefix}_${variable_name}}"
PARENT_SCOPE)
endforeach()
get_filename_component(relative_attribution_file_path
"${attribution_file_path}" REALPATH)
set(${out_prefix}_chosen_attribution_file_path "${relative_attribution_file_path}"
PARENT_SCOPE)
set(${out_prefix}_chosen_attribution_entry_index "${entry_index}"
PARENT_SCOPE)
set(first_attribution_processed TRUE)
if(NOT "${arg_ATTRIBUTION_ENTRY_INDEX}" STREQUAL "")
# We had a specific index to process, so break right after processing it.
break()
endif()
else()
# We are processing the second or later entry, or CREATE_SBOM_FOR_EACH_ATTRIBUTION
# was set. Instead of directly reading all the keys from the attribution file,
# we get the Id, and create a new sbom target for the entry.
# That will recursively call this function with a specific attribution file path
# and index, to process the specific entry.
set(out_prefix "${out_prefix_outer}_${file_index}_${entry_index}")
# Get the attribution id.
_qt_internal_sbom_read_qt_attribution(${out_prefix}
GET_KEY
KEY Id
OUT_VAR_VALUE attribution_id
ENTRY_INDEX "${entry_index}"
FILE_PATH "${attribution_file_path}"
)
# If no Id was retrieved, just add a numeric one, to make the sbom target
# unique.
set(attribution_target "${arg_PARENT_TARGET}_Attribution_")
if(NOT ${out_prefix}_attribution_id)
string(APPEND attribution_target "${file_index}_${entry_index}")
else()
string(APPEND attribution_target "${${out_prefix}_attribution_id}")
endif()
set(sbom_args "")
if(propagate_sbom_options_to_new_attribution_targets)
# Filter out the attributtion options, they will be passed mnaually
# depending on which file and index is currently being processed.
_qt_internal_get_sbom_specific_options(
sbom_opt_args sbom_single_args sbom_multi_args)
list(REMOVE_ITEM sbom_opt_args NO_CURRENT_DIR_ATTRIBUTION)
list(REMOVE_ITEM sbom_single_args ATTRIBUTION_ENTRY_INDEX)
list(REMOVE_ITEM sbom_multi_args
ATTRIBUTION_FILE_PATHS
ATTRIBUTION_FILE_DIR_PATHS
)
# Also filter out the FRIENDLY_PACKAGE_NAME option, otherwise we'd try to
# file(GENERATE) multiple times with the same file name, but different content.
list(REMOVE_ITEM sbom_single_args FRIENDLY_PACKAGE_NAME)
_qt_internal_forward_function_args(
FORWARD_APPEND
FORWARD_PREFIX arg
FORWARD_OUT_VAR sbom_args
FORWARD_OPTIONS
${sbom_opt_args}
FORWARD_SINGLE
${sbom_single_args}
FORWARD_MULTI
${sbom_multi_args}
)
endif()
# Create another sbom target with the id as a hint for the target name,
# the attribution file passed, and make the new target a dependency of the
# parent one.
_qt_internal_add_sbom("${attribution_target}"
IMMEDIATE_FINALIZATION
TYPE QT_THIRD_PARTY_SOURCES
ATTRIBUTION_FILE_PATHS "${attribution_file_path}"
ATTRIBUTION_ENTRY_INDEX "${entry_index}"
NO_CURRENT_DIR_ATTRIBUTION
${sbom_args}
)
_qt_internal_extend_sbom_dependencies(${arg_PARENT_TARGET}
SBOM_DEPENDENCIES ${attribution_target}
)
endif()
math(EXPR entry_index "${entry_index} + 1")
endwhile()
math(EXPR file_index "${file_index} + 1")
endforeach()
endfunction()
# Helper to parse a qt_attribution.json file and do various operations:
# - GET_DEFAULT_KEYS extracts the license id, copyrights, version, etc.
# - GET_KEY extracts a single given json key's value, as specified with KEY and saved into
# OUT_VAR_VALUE
# - GET_ATTRIBUTION_ENTRY_COUNT returns the number of entries in the json file, set in
# OUT_VAR_VALUE
#
# ENTRY_INDEX can be used to specify the array index to select a specific entry in the json file.
#
# Any retrieved value is set in the outer scope.
# The variables are prefixed with ${out_prefix}.
# OUT_VAR_ASSIGNED_VARIABLE_NAMES contains the list of variables set in the parent scope, the
# variables names in this list are not prefixed with ${out_prefix}.
#
# Requires cmake 3.19 for json parsing.
function(_qt_internal_sbom_read_qt_attribution out_prefix)
if(NOT QT_GENERATE_SBOM)
return()
endif()
if(CMAKE_VERSION LESS_EQUAL "3.19")
message(DEBUG "CMake version is too low, can't parse attribution.json file.")
return()
endif()
set(opt_args
GET_DEFAULT_KEYS
GET_KEY
GET_ATTRIBUTION_ENTRY_COUNT
)
set(single_args
FILE_PATH
KEY
ENTRY_INDEX
OUT_VAR_VALUE
OUT_VAR_ASSIGNED_VARIABLE_NAMES
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(file_path "${arg_FILE_PATH}")
if(NOT file_path)
message(FATAL_ERROR "qt attribution file path not given")
endif()
file(READ "${file_path}" contents)
if(NOT contents)
message(FATAL_ERROR "qt attribution file is empty: ${file_path}")
endif()
if(NOT arg_GET_DEFAULT_KEYS AND NOT arg_GET_KEY AND NOT arg_GET_ATTRIBUTION_ENTRY_COUNT)
message(FATAL_ERROR
"No valid operation specified to _qt_internal_sbom_read_qt_attribution call.")
endif()
if(arg_GET_KEY)
if(NOT arg_KEY)
message(FATAL_ERROR "KEY must be set")
endif()
if(NOT arg_OUT_VAR_VALUE)
message(FATAL_ERROR "OUT_VAR_VALUE must be set")
endif()
endif()
get_filename_component(attribution_file_dir "${file_path}" DIRECTORY)
# Parse the json file.
# The first element might be an array, or an object. We need to detect which one.
# Do that by trying to query index 0 of the potential root array.
# If the index is found, that means the root is an array, and elem_error is set to NOTFOUND,
# because there was no error.
# Otherwise elem_error will be something like 'member '0' not found', and we can assume the
# root is an object.
string(JSON first_elem_type ERROR_VARIABLE elem_error TYPE "${contents}" 0)
if(elem_error STREQUAL "NOTFOUND")
# Root is an array. The attribution file might contain multiple entries.
# Pick the first one if no specific index was specified, otherwise use the given index.
if(NOT "${arg_ENTRY_INDEX}" STREQUAL "")
set(indices "${arg_ENTRY_INDEX}")
else()
set(indices "0")
endif()
set(is_array TRUE)
else()
# Root is an object, not an array, which means the file has a single entry.
set(indices "")
set(is_array FALSE)
endif()
set(variable_names "")
if(arg_GET_KEY)
_qt_internal_sbom_get_attribution_key(${arg_KEY} ${arg_OUT_VAR_VALUE} ${out_prefix})
endif()
if(arg_GET_ATTRIBUTION_ENTRY_COUNT)
if(NOT arg_OUT_VAR_VALUE)
message(FATAL_ERROR "OUT_VAR_VALUE must be set")
endif()
if(is_array)
string(JSON attribution_entry_count ERROR_VARIABLE elem_error LENGTH "${contents}")
# There was an error getting the length of the array, so we assume it's empty.
if(NOT elem_error STREQUAL "NOTFOUND")
set(attribution_entry_count 0)
endif()
else()
set(attribution_entry_count 1)
endif()
set(${out_prefix}_${arg_OUT_VAR_VALUE} "${attribution_entry_count}" PARENT_SCOPE)
endif()
if(arg_GET_DEFAULT_KEYS)
# Some calls are currently commented out, to save on json parsing time because we don't have
# a usage for them yet.
# _qt_internal_sbom_get_attribution_key(License license)
_qt_internal_sbom_get_attribution_key(LicenseId license_id "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Version version "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Homepage homepage "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Name attribution_name "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Description description "${out_prefix}")
_qt_internal_sbom_get_attribution_key(QtUsage qt_usage "${out_prefix}")
_qt_internal_sbom_get_attribution_key(DownloadLocation download_location "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Copyright copyrights "${out_prefix}" IS_MULTI_VALUE)
_qt_internal_sbom_get_attribution_key(CopyrightFile copyright_file "${out_prefix}")
_qt_internal_sbom_get_attribution_key(PURL purls "${out_prefix}" IS_MULTI_VALUE)
_qt_internal_sbom_get_attribution_key(CPE cpes "${out_prefix}" IS_MULTI_VALUE)
# Some attribution files contain a copyright file that contains the actual list of
# copyrights. Read it and use it.
set(copyright_file_path "${attribution_file_dir}/${copyright_file}")
get_filename_component(copyright_file_path "${copyright_file_path}" REALPATH)
if(NOT copyrights AND copyright_file AND EXISTS "${copyright_file_path}")
file(READ "${copyright_file_path}" copyright_contents)
if(copyright_contents)
set(copyright_contents "${copyright_contents}")
set(copyrights "${copyright_contents}")
set(${out_prefix}_copyrights "${copyright_contents}" PARENT_SCOPE)
list(APPEND variable_names "copyrights")
endif()
endif()
endif()
if(arg_OUT_VAR_ASSIGNED_VARIABLE_NAMES)
set(${arg_OUT_VAR_ASSIGNED_VARIABLE_NAMES} "${variable_names}" PARENT_SCOPE)
endif()
endfunction()
# Extracts a string or an array of strings from a json index path, depending on the extracted value
# type.
#
# Given the 'contents' of the whole json document and the EXTRACTED_VALUE of a json key specified
# by the INDICES path, it tries to determine whether the value is an array, in which case the array
# is converted to a cmake list and assigned to ${out_var} in the parent scope.
# Otherwise the function assumes the EXTRACTED_VALUE was not an array, and just assigns the value
# of EXTRACTED_VALUE to ${out_var}
function(_qt_internal_sbom_handle_attribution_json_array contents)
set(opt_args "")
set(single_args
EXTRACTED_VALUE
OUT_VAR
)
set(multi_args
INDICES
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
# Write the original value to the parent scope, in case it was not an array.
set(${arg_OUT_VAR} "${arg_EXTRACTED_VALUE}" PARENT_SCOPE)
if(NOT arg_EXTRACTED_VALUE)
return()
endif()
string(JSON element_type TYPE "${contents}" ${arg_INDICES})
if(NOT element_type STREQUAL "ARRAY")
return()
endif()
set(json_array "${arg_EXTRACTED_VALUE}")
string(JSON array_len LENGTH "${json_array}")
set(value_list "")
math(EXPR array_len "${array_len} - 1")
foreach(index RANGE 0 "${array_len}")
string(JSON value GET "${json_array}" ${index})
if(value)
list(APPEND value_list "${value}")
endif()
endforeach()
if(value_list)
set(${arg_OUT_VAR} "${value_list}" PARENT_SCOPE)
endif()
endfunction()
# Escapes various characters in json content, so that the generate cmake code to append the content
# to the spdx document is syntactically valid.
function(_qt_internal_sbom_escape_json_content content out_var)
# Escape backslashes
string(REPLACE "\\" "\\\\" escaped_content "${content}")
# Escape quotes
string(REPLACE "\"" "\\\"" escaped_content "${escaped_content}")
set(${out_var} "${escaped_content}" PARENT_SCOPE)
endfunction()
# This macro reads a json key from a qt_attribution.json file, and assigns the escaped value to
# out_var.
# Also appends the name of the out_var to the parent scope 'variable_names' var.
#
# Expects 'contents' and 'indices' to already be set in the calling scope.
#
# If IS_MULTI_VALUE is set, handles the key as if it contained an array of
# values, by converting the array of json values to a cmake list.
macro(_qt_internal_sbom_get_attribution_key json_key out_var out_prefix)
cmake_parse_arguments(arg "IS_MULTI_VALUE" "" "" ${ARGN})
string(JSON "${out_var}" ERROR_VARIABLE get_error GET "${contents}" ${indices} "${json_key}")
if(NOT "${${out_var}}" STREQUAL "" AND NOT get_error)
set(extracted_value "${${out_var}}")
if(arg_IS_MULTI_VALUE)
_qt_internal_sbom_handle_attribution_json_array("${contents}"
EXTRACTED_VALUE "${extracted_value}"
INDICES ${indices} ${json_key}
OUT_VAR value_list
)
if(value_list)
set(extracted_value "${value_list}")
endif()
endif()
_qt_internal_sbom_escape_json_content("${extracted_value}" escaped_content)
set(${out_prefix}_${out_var} "${escaped_content}" PARENT_SCOPE)
list(APPEND variable_names "${out_var}")
unset(extracted_value)
unset(escaped_content)
unset(value_list)
endif()
endmacro()
# Replaces placeholders in CPE and PURL strings read from qt_attribution.json files.
#
# VALUES - list of CPE or PURL strings
# OUT_VAR - variable to store the replaced values
# VERSION - version to replace in the placeholders
# Known placeholders:
# $<VERSION> - Replaces occurrences of the placeholder with the value passed to the VERSION option.
# $<VERSION_DASHED> - Replaces occurrences of the placeholder with the value passed to the VERSION
# option, but with dots replaced by dashes.
function(_qt_internal_sbom_replace_qa_placeholders)
set(opt_args "")
set(single_args
OUT_VAR
VERSION
)
set(multi_args
VALUES
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
set(result "")
if(arg_VERSION)
string(REPLACE "." "-" dashed_version "${arg_VERSION}")
endif()
foreach(value IN LISTS arg_VALUES)
if(arg_VERSION)
string(REPLACE "$<VERSION>" "${arg_VERSION}" value "${value}")
string(REPLACE "$<VERSION_DASHED>" "${dashed_version}" value "${value}")
endif()
list(APPEND result "${value}")
endforeach()
set(${arg_OUT_VAR} "${result}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,90 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Computes a security CPE for a given set of attributes.
#
# When a part is not specified, a wildcard is added.
#
# References:
# https://spdx.github.io/spdx-spec/v2.3/external-repository-identifiers/#f22-cpe23type
# https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf
# https://nvd.nist.gov/products/cpe
#
# Each attribute means:
# 1. part
# 2. vendor
# 3. product
# 4. version
# 5. update
# 6. edition
# 7. language
# 8. sw_edition
# 9. target_sw
# 10. target_hw
# 11. other
function(_qt_internal_sbom_compute_security_cpe out_cpe)
set(opt_args "")
set(single_args
PART
VENDOR
PRODUCT
VERSION
UPDATE
EDITION
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(cpe_template "cpe:2.3:PART:VENDOR:PRODUCT:VERSION:UPDATE:EDITION:*:*:*:*:*")
set(cpe "${cpe_template}")
foreach(attribute_name IN LISTS single_args)
if(arg_${attribute_name})
set(${attribute_name}_value "${arg_${attribute_name}}")
else()
if(attribute_name STREQUAL "PART")
set(${attribute_name}_value "a")
else()
set(${attribute_name}_value "*")
endif()
endif()
string(REPLACE "${attribute_name}" "${${attribute_name}_value}" cpe "${cpe}")
endforeach()
set(${out_cpe} "${cpe}" PARENT_SCOPE)
endfunction()
# Computes the default security CPE for the Qt framework.
function(_qt_internal_sbom_get_cpe_qt out_var)
_qt_internal_sbom_get_root_project_name_lower_case(repo_project_name_lowercase)
_qt_internal_sbom_compute_security_cpe(repo_cpe
VENDOR "qt"
PRODUCT "${repo_project_name_lowercase}"
VERSION "${QT_REPO_MODULE_VERSION}"
)
set(${out_var} "${repo_cpe}" PARENT_SCOPE)
endfunction()
# Computes the default security CPE for a given qt repository.
function(_qt_internal_sbom_get_cpe_qt_repo out_var)
_qt_internal_sbom_compute_security_cpe(qt_cpe
VENDOR "qt"
PRODUCT "qt"
VERSION "${QT_REPO_MODULE_VERSION}"
)
set(${out_var} "${qt_cpe}" PARENT_SCOPE)
endfunction()
# Computes the list of security CPEs for Qt, including both the repo-specific one and generic one.
function(_qt_internal_sbom_compute_security_cpe_for_qt out_cpe_list)
set(cpe_list "")
_qt_internal_sbom_get_cpe_qt(repo_cpe)
list(APPEND cpe_list "${repo_cpe}")
_qt_internal_sbom_get_cpe_qt_repo(qt_cpe)
list(APPEND cpe_list "${qt_cpe}")
set(${out_cpe_list} "${cpe_list}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,327 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Walks a target's direct dependencies and assembles a list of relationships between the packages
# of the target dependencies.
# Currently handles various Qt targets and system libraries.
function(_qt_internal_sbom_handle_target_dependencies target)
set(opt_args "")
set(single_args
SPDX_ID
OUT_RELATIONSHIPS
)
set(multi_args
LIBRARIES
PUBLIC_LIBRARIES
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_SPDX_ID)
message(FATAL_ERROR "SPDX_ID must be set")
endif()
set(package_spdx_id "${arg_SPDX_ID}")
set(libraries "")
if(arg_LIBRARIES)
list(APPEND libraries "${arg_LIBRARIES}")
endif()
get_target_property(extend_libraries "${target}" _qt_extend_target_libraries)
if(extend_libraries)
list(APPEND libraries ${extend_libraries})
endif()
get_target_property(target_type ${target} TYPE)
set(valid_target_types
EXECUTABLE
SHARED_LIBRARY
MODULE_LIBRARY
STATIC_LIBRARY
OBJECT_LIBRARY
)
if(target_type IN_LIST valid_target_types)
get_target_property(link_libraries "${target}" LINK_LIBRARIES)
if(link_libraries)
list(APPEND libraries ${link_libraries})
endif()
endif()
set(public_libraries "")
if(arg_PUBLIC_LIBRARIES)
list(APPEND public_libraries "${arg_PUBLIC_LIBRARIES}")
endif()
get_target_property(extend_public_libraries "${target}" _qt_extend_target_public_libraries)
if(extend_public_libraries)
list(APPEND public_libraries ${extend_public_libraries})
endif()
set(sbom_dependencies "")
if(arg_SBOM_DEPENDENCIES)
list(APPEND sbom_dependencies "${arg_SBOM_DEPENDENCIES}")
endif()
get_target_property(extend_sbom_dependencies "${target}" _qt_extend_target_sbom_dependencies)
if(extend_sbom_dependencies)
list(APPEND sbom_dependencies ${extend_sbom_dependencies})
endif()
list(REMOVE_DUPLICATES libraries)
list(REMOVE_DUPLICATES public_libraries)
list(REMOVE_DUPLICATES sbom_dependencies)
set(all_direct_libraries ${libraries} ${public_libraries} ${sbom_dependencies})
list(REMOVE_DUPLICATES all_direct_libraries)
set(spdx_dependencies "")
set(relationships "")
# Go through each direct linked lib.
foreach(direct_lib IN LISTS all_direct_libraries)
if(NOT TARGET "${direct_lib}")
continue()
endif()
# Some targets are Qt modules, even though they are not prefixed with Qt::, targets
# like Bootstrap and QtLibraryInfo. We use the property to differentiate them.
get_target_property(is_marked_as_qt_module "${direct_lib}" _qt_sbom_is_qt_module)
# Custom sbom targets created by _qt_internal_create_sbom_target are always imported, so we
# need to differentiate them via this property.
get_target_property(is_custom_sbom_target "${direct_lib}" _qt_sbom_is_custom_sbom_target)
if("${direct_lib}" MATCHES "^(Qt::.*)|(${QT_CMAKE_EXPORT_NAMESPACE}::.*)")
set(is_qt_prefixed TRUE)
else()
set(is_qt_prefixed FALSE)
endif()
# is_qt_dependency is not strictly only a qt dependency, it applies to custom sbom
# targets as well. But I'm having a hard time to come up with a better name.
if(is_marked_as_qt_module OR is_custom_sbom_target OR is_qt_prefixed)
set(is_qt_dependency TRUE)
else()
set(is_qt_dependency FALSE)
endif()
# Regular Qt dependency, depend on the relevant package, either within the current
# document or via an external document.
if(is_qt_dependency)
_qt_internal_sbom_is_external_target_dependency("${direct_lib}"
OUT_VAR is_dependency_in_external_document
)
if(is_dependency_in_external_document)
# External document case.
_qt_internal_sbom_add_external_target_dependency(
"${package_spdx_id}" "${direct_lib}"
extra_spdx_dependencies
extra_spdx_relationships
)
if(extra_spdx_dependencies)
list(APPEND spdx_dependencies "${extra_spdx_dependencies}")
endif()
if(extra_spdx_relationships)
list(APPEND relationships "${extra_spdx_relationships}")
endif()
else()
# Dependency is part of current repo build.
_qt_internal_sbom_get_spdx_id_for_target("${direct_lib}" dep_spdx_id)
if(dep_spdx_id)
list(APPEND spdx_dependencies "${dep_spdx_id}")
else()
message(DEBUG "Could not add target dependency on ${direct_lib} "
"because no spdx id could be found")
endif()
endif()
else()
# If it's not a Qt dependency, then it's most likely a 3rd party dependency.
# If we are looking at a FindWrap dependency, we need to depend on either
# the system or vendored lib, whichever one the FindWrap script points to.
# If we are looking at a non-Wrap dependency, it's 99% a system lib.
__qt_internal_walk_libs(
"${direct_lib}"
lib_walked_targets
_discarded_out_var
"sbom_targets"
"collect_targets")
# Detect if we are dealing with a vendored / bundled lib.
set(bundled_targets_found FALSE)
if(lib_walked_targets)
foreach(lib_walked_target IN LISTS lib_walked_targets)
get_target_property(is_3rdparty_bundled_lib
"${lib_walked_target}" _qt_module_is_3rdparty_library)
_qt_internal_sbom_get_spdx_id_for_target("${lib_walked_target}" lib_spdx_id)
# Add a dependency on the vendored lib instead of the Wrap target.
if(is_3rdparty_bundled_lib AND lib_spdx_id)
list(APPEND spdx_dependencies "${lib_spdx_id}")
set(bundled_targets_found TRUE)
endif()
endforeach()
endif()
# If no bundled libs were found as a result of walking the Wrap lib, we consider this
# a system lib, and add a dependency on it directly.
if(NOT bundled_targets_found)
_qt_internal_sbom_get_spdx_id_for_target("${direct_lib}" lib_spdx_id)
_qt_internal_sbom_is_external_target_dependency("${direct_lib}"
SYSTEM_LIBRARY
OUT_VAR is_dependency_in_external_document
)
if(lib_spdx_id)
if(NOT is_dependency_in_external_document)
list(APPEND spdx_dependencies "${lib_spdx_id}")
# Mark the system library is used, so that we later generate an sbom for it.
_qt_internal_append_to_cmake_property_without_duplicates(
_qt_internal_sbom_consumed_system_library_targets
"${direct_lib}"
)
else()
# Refer to the package in the external document. This can be the case
# in a top-level build, where a system library is reused across repos.
_qt_internal_sbom_add_external_target_dependency(
"${package_spdx_id}" "${direct_lib}"
extra_spdx_dependencies
extra_spdx_relationships
)
if(extra_spdx_dependencies)
list(APPEND spdx_dependencies "${extra_spdx_dependencies}")
endif()
if(extra_spdx_relationships)
list(APPEND relationships "${extra_spdx_relationships}")
endif()
endif()
else()
message(DEBUG "Could not add target dependency on system library ${direct_lib} "
"because no spdx id could be found")
endif()
endif()
endif()
endforeach()
foreach(dep_spdx_id IN LISTS spdx_dependencies)
set(relationship
"${package_spdx_id} DEPENDS_ON ${dep_spdx_id}"
)
list(APPEND relationships "${relationship}")
endforeach()
set(${arg_OUT_RELATIONSHIPS} "${relationships}" PARENT_SCOPE)
endfunction()
# Checks whether the current target will have its sbom generated into the current repo sbom
# document, or whether it is present in an external sbom document.
function(_qt_internal_sbom_is_external_target_dependency target)
set(opt_args
SYSTEM_LIBRARY
)
set(single_args
OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
get_target_property(is_imported "${target}" IMPORTED)
get_target_property(is_custom_sbom_target "${target}" _qt_sbom_is_custom_sbom_target)
_qt_internal_sbom_get_root_project_name_lower_case(current_repo_project_name)
get_property(target_repo_project_name TARGET ${target}
PROPERTY _qt_sbom_spdx_repo_project_name_lowercase)
if(NOT "${target_repo_project_name}" STREQUAL ""
AND NOT "${target_repo_project_name}" STREQUAL "${current_repo_project_name}")
set(part_of_other_repo TRUE)
else()
set(part_of_other_repo FALSE)
endif()
# A target is in an external document if
# 1) it is imported, and not a custom sbom target, and not a system library
# 2) it was created as part of another repo in a top-level build
if((is_imported AND NOT is_custom_sbom_target AND NOT arg_SYSTEM_LIBRARY)
OR part_of_other_repo)
set(is_dependency_in_external_document TRUE)
else()
set(is_dependency_in_external_document FALSE)
endif()
set(${arg_OUT_VAR} "${is_dependency_in_external_document}" PARENT_SCOPE)
endfunction()
# Handles generating an external document reference SDPX element for each target package that is
# located in a different spdx document.
function(_qt_internal_sbom_add_external_target_dependency
current_package_spdx_id
target_dep
out_spdx_dependencies
out_spdx_relationships
)
set(target "${target_dep}")
_qt_internal_sbom_get_spdx_id_for_target("${target}" dep_spdx_id)
if(NOT dep_spdx_id)
message(DEBUG "Could not add external target dependency on ${target} "
"because no spdx id could be found")
set(${out_spdx_dependencies} "" PARENT_SCOPE)
set(${out_spdx_relationships} "" PARENT_SCOPE)
return()
endif()
set(spdx_dependencies "")
set(spdx_relationships "")
# Get the external document path and the repo it belongs to for the given target.
get_property(relative_installed_repo_document_path TARGET ${target}
PROPERTY _qt_sbom_spdx_relative_installed_repo_document_path)
get_property(project_name_lowercase TARGET ${target}
PROPERTY _qt_sbom_spdx_repo_project_name_lowercase)
if(relative_installed_repo_document_path AND project_name_lowercase)
_qt_internal_sbom_get_external_document_ref_spdx_id(
"${project_name_lowercase}" external_document_ref)
get_cmake_property(known_external_document
_qt_known_external_documents_${external_document_ref})
set(relationship
"${current_package_spdx_id} DEPENDS_ON ${external_document_ref}:${dep_spdx_id}")
list(APPEND spdx_relationships "${relationship}")
# Only add a reference to the external document package, if we haven't done so already.
if(NOT known_external_document)
set(install_prefixes "")
get_cmake_property(install_prefix _qt_internal_sbom_install_prefix)
list(APPEND install_prefixes "${install_prefix}")
set(external_document "${relative_installed_repo_document_path}")
_qt_internal_sbom_generate_add_external_reference(
EXTERNAL_DOCUMENT_FILE_PATH "${external_document}"
EXTERNAL_DOCUMENT_INSTALL_PREFIXES ${install_prefixes}
EXTERNAL_DOCUMENT_SPDX_ID "${external_document_ref}"
)
set_property(GLOBAL PROPERTY
_qt_known_external_documents_${external_document_ref} TRUE)
set_property(GLOBAL APPEND PROPERTY
_qt_known_external_documents "${external_document_ref}")
endif()
else()
message(WARNING "Missing spdx document path for external ref: "
"package_name_for_spdx_id ${package_name_for_spdx_id} direct_lib ${direct_lib}")
endif()
set(${out_spdx_dependencies} "${spdx_dependencies}" PARENT_SCOPE)
set(${out_spdx_relationships} "${spdx_relationships}" PARENT_SCOPE)
endfunction()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,108 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Adds a license id and its text to the sbom.
function(_qt_internal_sbom_add_license)
if(NOT QT_GENERATE_SBOM)
return()
endif()
set(opt_args
NO_LICENSE_REF_PREFIX
)
set(single_args
LICENSE_ID
LICENSE_PATH
EXTRACTED_TEXT
)
set(multi_args
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_LICENSE_ID)
message(FATAL_ERROR "LICENSE_ID must be set")
endif()
if(NOT arg_TEXT AND NOT arg_LICENSE_PATH)
message(FATAL_ERROR "Either TEXT or LICENSE_PATH must be set")
endif()
# Sanitize the content a bit.
if(arg_TEXT)
set(text "${arg_TEXT}")
string(REPLACE ";" "$<SEMICOLON>" text "${text}")
string(REPLACE "\"" "\\\"" text "${text}")
else()
file(READ "${arg_LICENSE_PATH}" text)
string(REPLACE ";" "$<SEMICOLON>" text "${text}")
string(REPLACE "\"" "\\\"" text "${text}")
endif()
set(license_id "${arg_LICENSE_ID}")
if(NOT arg_NO_LICENSE_REF_PREFIX)
set(license_id "LicenseRef-${license_id}")
endif()
_qt_internal_sbom_generate_add_license(
LICENSE_ID "${license_id}"
EXTRACTED_TEXT "<text>${text}</text>"
)
endfunction()
# Get a qt spdx license expression given the id.
function(_qt_internal_sbom_get_spdx_license_expression id out_var)
set(license "")
# The default for modules / plugins
if(id STREQUAL "QT_DEFAULT" OR id STREQUAL "QT_COMMERCIAL_OR_LGPL3")
set(license "LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only")
# For commercial only entities
elseif(id STREQUAL "QT_COMMERCIAL")
set(license "LicenseRef-Qt-Commercial")
# For GPL3 only modules
elseif(id STREQUAL "QT_COMMERCIAL_OR_GPL3")
set(license "LicenseRef-Qt-Commercial OR GPL-3.0-only")
# For tools and apps
elseif(id STREQUAL "QT_COMMERCIAL_OR_GPL3_WITH_EXCEPTION")
set(license "LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0")
# For things like the qtmain library
elseif(id STREQUAL "QT_COMMERCIAL_OR_BSD3")
set(license "LicenseRef-Qt-Commercial OR BSD-3-Clause")
# For documentation
elseif(id STREQUAL "QT_COMMERCIAL_OR_GFDL1_3")
set(license "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only")
# For examples and the like
elseif(id STREQUAL "BSD3")
set(license "BSD-3-Clause")
endif()
if(NOT license)
message(FATAL_ERROR "No SPDX license expression found for id: ${id}")
endif()
set(${out_var} "${license}" PARENT_SCOPE)
endfunction()
# Joins two license IDs with the given ${op}, avoiding parenthesis when possible.
function(_qt_internal_sbom_join_two_license_ids_with_op left_id op right_id out_var)
if(NOT left_id)
set(${out_var} "${right_id}" PARENT_SCOPE)
return()
endif()
if(NOT right_id)
set(${out_var} "${left_id}" PARENT_SCOPE)
return()
endif()
set(value "(${left_id}) ${op} (${right_id})")
set(${out_var} "${value}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,579 @@
# Copyright (C) 2024 The Qt Company Ltd.
# Copyright (C) 2023-2024 Jochem Rutgers
# SPDX-License-Identifier: MIT AND BSD-3-Clause
# Handles the look up of Python, Python spdx dependencies and other various post-installation steps
# like NTIA validation, auditing, json generation, etc.
function(_qt_internal_sbom_setup_project_ops_generation)
set(opt_args
GENERATE_JSON
GENERATE_JSON_REQUIRED
GENERATE_SOURCE_SBOM
VERIFY_SBOM
VERIFY_SBOM_REQUIRED
VERIFY_NTIA_COMPLIANT
LINT_SOURCE_SBOM
LINT_SOURCE_SBOM_NO_ERROR
SHOW_TABLE
AUDIT
AUDIT_NO_ERROR
)
set(single_args "")
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(arg_GENERATE_JSON AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(op_args
OP_KEY "GENERATE_JSON"
OUT_VAR_DEPS_FOUND deps_found
)
if(arg_GENERATE_JSON_REQUIRED)
list(APPEND op_args REQUIRED)
endif()
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(${op_args})
if(deps_found)
_qt_internal_sbom_generate_json()
endif()
endif()
if(arg_VERIFY_SBOM AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(op_args
OP_KEY "VERIFY_SBOM"
OUT_VAR_DEPS_FOUND deps_found
)
if(arg_VERIFY_SBOM_REQUIRED)
list(APPEND op_args REQUIRED)
endif()
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(${op_args})
if(deps_found)
_qt_internal_sbom_verify_valid()
endif()
endif()
if(arg_VERIFY_NTIA_COMPLIANT AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(REQUIRED OP_KEY "RUN_NTIA")
_qt_internal_sbom_verify_ntia_compliant()
endif()
if(arg_SHOW_TABLE AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
_qt_internal_sbom_find_python_dependency_program(NAME sbom2doc REQUIRED)
_qt_internal_sbom_show_table()
endif()
if(arg_AUDIT AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(audit_no_error_option "")
if(arg_AUDIT_NO_ERROR)
set(audit_no_error_option NO_ERROR)
endif()
_qt_internal_sbom_find_python_dependency_program(NAME sbomaudit REQUIRED)
_qt_internal_sbom_audit(${audit_no_error_option})
endif()
if(arg_GENERATE_SOURCE_SBOM AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
_qt_internal_sbom_find_python_dependency_program(NAME reuse REQUIRED)
_qt_internal_sbom_generate_reuse_source_sbom()
endif()
if(arg_LINT_SOURCE_SBOM AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(lint_no_error_option "")
if(arg_LINT_SOURCE_SBOM_NO_ERROR)
set(lint_no_error_option NO_ERROR)
endif()
_qt_internal_sbom_find_python_dependency_program(NAME reuse REQUIRED)
_qt_internal_sbom_run_reuse_lint(
${lint_no_error_option}
BUILD_TIME_SCRIPT_PATH_OUT_VAR reuse_lint_script
)
endif()
endfunction()
# Helper to find a python interpreter and a specific python dependency, e.g. to be able to generate
# a SPDX JSON SBOM, or run post-installation steps like NTIA verification.
# The exact dependency should be specified as the OP_KEY.
#
# Caches the found python executable in a separate cache var QT_INTERNAL_SBOM_PYTHON_EXECUTABLE, to
# avoid conflicts with any other found python interpreter.
function(_qt_internal_sbom_find_and_handle_sbom_op_dependencies)
set(opt_args
REQUIRED
)
set(single_args
OP_KEY
OUT_VAR_DEPS_FOUND
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OP_KEY)
message(FATAL_ERROR "OP_KEY is required")
endif()
set(supported_ops "GENERATE_JSON" "VERIFY_SBOM" "RUN_NTIA")
if(arg_OP_KEY STREQUAL "GENERATE_JSON" OR arg_OP_KEY STREQUAL "VERIFY_SBOM")
set(import_statement "import spdx_tools.spdx.clitools.pyspdxtools")
elseif(arg_OP_KEY STREQUAL "RUN_NTIA")
set(import_statement "import ntia_conformance_checker.main")
else()
message(FATAL_ERROR "OP_KEY must be one of ${supported_ops}")
endif()
# Return early if we found the dependencies.
if(QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${arg_OP_KEY})
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} TRUE PARENT_SCOPE)
endif()
return()
endif()
# NTIA-compliance checker requires Python 3.9 or later, so we use it as the minimum for all
# SBOM OPs.
set(required_version "3.9")
set(python_common_args
VERSION "${required_version}"
)
set(everything_found FALSE)
# On macOS FindPython prefers looking in the system framework location, but that usually would
# not have the required dependencies. So we first look in it, and then fallback to any other
# non-framework python found.
if(CMAKE_HOST_APPLE)
set(extra_python_args SEARCH_IN_FRAMEWORKS QUIET)
_qt_internal_sbom_find_python_and_dependency_helper_lambda()
endif()
if(NOT everything_found)
set(extra_python_args QUIET)
_qt_internal_sbom_find_python_and_dependency_helper_lambda()
endif()
if(NOT everything_found)
if(arg_REQUIRED)
set(message_type "FATAL_ERROR")
else()
set(message_type "DEBUG")
endif()
if(NOT python_found)
# Look for python one more time, this time without QUIET, to show an error why it
# wasn't found.
if(arg_REQUIRED)
_qt_internal_sbom_find_python_helper(${python_common_args}
OUT_VAR_PYTHON_PATH unused_python
OUT_VAR_PYTHON_FOUND unused_found
)
endif()
message(${message_type} "Python ${required_version} for running SBOM ops not found.")
elseif(NOT dep_found)
message(${message_type} "Python dependency for running SBOM op ${arg_OP_KEY} "
"not found:\n Python: ${python_path} \n Output: \n${dep_find_output}")
endif()
else()
message(DEBUG "Using Python ${python_path} for running SBOM ops.")
if(NOT QT_INTERNAL_SBOM_PYTHON_EXECUTABLE)
set(QT_INTERNAL_SBOM_PYTHON_EXECUTABLE "${python_path}" CACHE INTERNAL
"Python interpeter used for SBOM generation.")
endif()
set(QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${arg_OP_KEY} "TRUE" CACHE INTERNAL
"All dependencies found to run SBOM OP ${arg_OP_KEY}")
endif()
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} "${QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${arg_OP_KEY}}"
PARENT_SCOPE)
endif()
endfunction()
# Helper to generate a SPDX JSON file from a tag/value format file.
# This also implies some additional validity checks, useful to ensure a proper sbom file.
function(_qt_internal_sbom_generate_json)
if(NOT QT_INTERNAL_SBOM_PYTHON_EXECUTABLE)
message(FATAL_ERROR "Python interpreter not found for generating SBOM json file.")
endif()
if(NOT QT_INTERNAL_SBOM_DEPS_FOUND_FOR_GENERATE_JSON)
message(FATAL_ERROR "Python dependencies not found for generating SBOM json file.")
endif()
set(content "
message(STATUS \"Generating JSON: \${QT_SBOM_OUTPUT_PATH}.json\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m spdx_tools.spdx.clitools.pyspdxtools
-i \"\${QT_SBOM_OUTPUT_PATH}\" -o \"\${QT_SBOM_OUTPUT_PATH}.json\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM conversion to JSON failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/convert_to_json.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to generate a tag/value SPDX file from a SPDX JSON format file.
#
# Will be used by WebEngine to convert the Chromium JSON file to a tag/value SPDX file.
#
# This conversion needs to happen before the document is referenced in the SBOM generation process,
# so that the file already exists when it is parsed for its unique id and namespace.
# It also needs to happen before verification codes are computed for the current document
# that will depend on the target one, to ensure the the file exists and its checksum can be
# computed.
#
# OPERATION_ID - a unique id for the operation, used to generate a unique cmake file name for
# the SBOM generation process.
#
# INPUT_JSON_PATH - the absolute path to the input JSON file.
#
# OUTPUT_FILE_PATH - the absolute path where to create the output tag/value SPDX file.
# Note that if the output file path is set, it is up to the caller to also copy / install the file
# into the build and install directories where the build system expects to find all external
# document references.
#
# OUTPUT_FILE_NAME - when OUTPUT_FILE_PATH is not specified, the output directory is automatically
# set to the SBOM output directory. In this case OUTPUT_FILE_NAME can be used to override the
# outout file name. If not specified, it will be derived from the input file name.
#
# OUT_VAR_OUTPUT_FILE_NAME - output variable where to store the output file.
#
# OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH - output variable where to store the output file path.
# Note that the path will contain an unresolved '${QT_SBOM_OUTPUT_DIR}' which only has a value at
# install time. So the path can't be used sensibly during configure time.
function(_qt_internal_sbom_generate_tag_value_spdx_document)
if(NOT QT_GENERATE_SBOM)
return()
endif()
set(opt_args "")
set(single_args
OPERATION_ID
INPUT_JSON_FILE_PATH
OUTPUT_FILE_PATH
OUTPUT_FILE_NAME
OUT_VAR_OUTPUT_FILE_NAME
OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT QT_INTERNAL_SBOM_PYTHON_EXECUTABLE)
message(FATAL_ERROR "Python interpreter not found for generating tag/value file from JSON.")
endif()
if(NOT QT_INTERNAL_SBOM_DEPS_FOUND_FOR_GENERATE_JSON)
message(FATAL_ERROR
"Python dependencies not found for generating tag/value file from JSON.")
endif()
if(NOT arg_OPERATION_ID)
message(FATAL_ERROR "OPERATION_ID is required")
endif()
if(NOT arg_INPUT_JSON_FILE_PATH)
message(FATAL_ERROR "INPUT_JSON_FILE_PATH is required")
endif()
if(arg_OUTPUT_FILE_PATH)
set(output_path "${arg_OUTPUT_FILE_PATH}")
else()
if(arg_OUTPUT_FILE_NAME)
set(output_name "${arg_OUTPUT_FILE_NAME}")
else()
# Use the input file name without the last extension (without .json) as the output name.
get_filename_component(output_name "${arg_INPUT_JSON_FILE_PATH}" NAME_WLE)
endif()
set(output_path "\${QT_SBOM_OUTPUT_DIR}/${output_name}")
endif()
if(arg_OUT_VAR_OUTPUT_FILE_NAME)
get_filename_component(output_name_resolved "${output_path}" NAME)
set(${arg_OUT_VAR_OUTPUT_FILE_NAME} "${output_name_resolved}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH)
set(${arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH} "${output_path}" PARENT_SCOPE)
endif()
set(content "
message(STATUS
\"Generating tag/value SPDX document: ${output_path} from \"
\"${arg_INPUT_JSON_FILE_PATH}\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m spdx_tools.spdx.clitools.pyspdxtools
-i \"${arg_INPUT_JSON_FILE_PATH}\" -o \"${output_path}\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM conversion to tag/value failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(convert_sbom "${sbom_dir}/convert_to_tag_value_${arg_OPERATION_ID}.cmake")
file(GENERATE OUTPUT "${convert_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_include_files
"${convert_sbom}")
endfunction()
# Helper to verify the generated sbom is valid.
function(_qt_internal_sbom_verify_valid)
if(NOT QT_INTERNAL_SBOM_PYTHON_EXECUTABLE)
message(FATAL_ERROR "Python interpreter not found for verifying SBOM file.")
endif()
if(NOT QT_INTERNAL_SBOM_DEPS_FOUND_FOR_VERIFY_SBOM)
message(FATAL_ERROR "Python dependencies not found for verifying SBOM file")
endif()
set(content "
message(STATUS \"Verifying: \${QT_SBOM_OUTPUT_PATH}\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m spdx_tools.spdx.clitools.pyspdxtools
-i \"\${QT_SBOM_OUTPUT_PATH}\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM verification failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/verify_valid.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to verify the generated sbom is NTIA compliant.
function(_qt_internal_sbom_verify_ntia_compliant)
if(NOT QT_INTERNAL_SBOM_PYTHON_EXECUTABLE)
message(FATAL_ERROR "Python interpreter not found for verifying SBOM file.")
endif()
if(NOT QT_INTERNAL_SBOM_DEPS_FOUND_FOR_RUN_NTIA)
message(FATAL_ERROR "Python dependencies not found for running the SBOM NTIA checker.")
endif()
set(content "
message(STATUS \"Checking for NTIA compliance: \${QT_SBOM_OUTPUT_PATH}\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m ntia_conformance_checker.main
--file \"\${QT_SBOM_OUTPUT_PATH}\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM NTIA verification failed: \{res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/verify_ntia.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to show the main sbom document info in the form of a CLI table.
function(_qt_internal_sbom_show_table)
set(extra_code_begin "")
if(DEFINED ENV{COIN_UNIQUE_JOB_ID})
# The output of the process dynamically adjusts the width of the shown table based on the
# console width. In the CI, the width is very short for some reason, and thus the output
# is truncated in the CI log. Explicitly set a bigger width to avoid this.
set(extra_code_begin "
set(backup_env_columns \$ENV{COLUMNS})
set(ENV{COLUMNS} 150)
")
set(extra_code_end "
set(ENV{COLUMNS} \${backup_env_columns})
")
endif()
set(content "
message(STATUS \"Showing main SBOM document info: \${QT_SBOM_OUTPUT_PATH}\")
${extra_code_begin}
execute_process(
COMMAND ${QT_SBOM_PROGRAM_SBOM2DOC} -i \"\${QT_SBOM_OUTPUT_PATH}\"
RESULT_VARIABLE res
)
${extra_code_end}
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Showing SBOM document failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/show_table.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to audit the generated sbom.
function(_qt_internal_sbom_audit)
set(opt_args NO_ERROR)
set(single_args "")
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(handle_error "")
if(NOT arg_NO_ERROR)
set(handle_error "
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM Audit failed: \${res}\")
endif()
")
endif()
set(content "
message(STATUS \"Auditing SBOM: \${QT_SBOM_OUTPUT_PATH}\")
execute_process(
COMMAND ${QT_SBOM_PROGRAM_SBOMAUDIT} -i \"\${QT_SBOM_OUTPUT_PATH}\"
--disable-license-check --cpecheck --offline
RESULT_VARIABLE res
)
${handle_error}
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/audit.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Returns path to project's potential root source reuse.toml file.
function(_qt_internal_sbom_get_project_reuse_toml_path out_var)
set(reuse_toml_path "${PROJECT_SOURCE_DIR}/REUSE.toml")
set(${out_var} "${reuse_toml_path}" PARENT_SCOPE)
endfunction()
# Helper to generate and install a source SBOM using reuse.
function(_qt_internal_sbom_generate_reuse_source_sbom)
set(opt_args NO_ERROR)
set(single_args "")
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(file_op "${sbom_dir}/generate_reuse_source_sbom.cmake")
_qt_internal_sbom_get_project_reuse_toml_path(reuse_toml_path)
if(NOT EXISTS "${reuse_toml_path}" AND NOT QT_FORCE_SOURCE_SBOM_GENERATION)
set(skip_message
"Skipping source SBOM generation: No reuse.toml file found at '${reuse_toml_path}'.")
message(STATUS "${skip_message}")
set(content "
message(STATUS \"${skip_message}\")
")
file(GENERATE OUTPUT "${file_op}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_post_generation_include_files
"${file_op}")
return()
endif()
set(handle_error "")
if(NOT arg_NO_ERROR)
set(handle_error "
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Source SBOM generation using reuse tool failed: \${res}\")
endif()
")
endif()
set(source_sbom_path "\${QT_SBOM_OUTPUT_PATH_WITHOUT_EXT}.source.spdx")
set(content "
message(STATUS \"Generating source SBOM using reuse tool: ${source_sbom_path}\")
execute_process(
COMMAND ${QT_SBOM_PROGRAM_REUSE} --root \"${PROJECT_SOURCE_DIR}\" spdx
-o ${source_sbom_path}
RESULT_VARIABLE res
)
${handle_error}
")
file(GENERATE OUTPUT "${file_op}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_post_generation_include_files "${file_op}")
endfunction()
# Helper to run 'reuse lint' on the project source dir.
function(_qt_internal_sbom_run_reuse_lint)
set(opt_args
NO_ERROR
)
set(single_args
BUILD_TIME_SCRIPT_PATH_OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
# If no reuse.toml file exists, it means the repo is likely not reuse compliant yet,
# so we shouldn't error out during installation when running the lint.
_qt_internal_sbom_get_project_reuse_toml_path(reuse_toml_path)
if(NOT EXISTS "${reuse_toml_path}" AND NOT QT_FORCE_REUSE_LINT_ERROR)
set(arg_NO_ERROR TRUE)
endif()
set(handle_error "")
if(NOT arg_NO_ERROR)
set(handle_error "
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Running 'reuse lint' failed: \${res}\")
endif()
")
endif()
set(content "
message(STATUS \"Running 'reuse lint' in '${PROJECT_SOURCE_DIR}'.\")
execute_process(
COMMAND ${QT_SBOM_PROGRAM_REUSE} --root \"${PROJECT_SOURCE_DIR}\" lint
RESULT_VARIABLE res
)
${handle_error}
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(file_op_build "${sbom_dir}/run_reuse_lint_build.cmake")
file(GENERATE OUTPUT "${file_op_build}" CONTENT "${content}")
# Allow skipping running 'reuse lint' during installation. But still allow running it during
# build time. This is a fail safe opt-out in case some repo needs it.
if(QT_FORCE_SKIP_REUSE_LINT_ON_INSTALL)
set(skip_message "Skipping running 'reuse lint' in '${PROJECT_SOURCE_DIR}'.")
set(content "
message(STATUS \"${skip_message}\")
")
set(file_op_install "${sbom_dir}/run_reuse_lint_install.cmake")
file(GENERATE OUTPUT "${file_op_install}" CONTENT "${content}")
else()
# Just reuse the already generated script for installation as well.
set(file_op_install "${file_op_build}")
endif()
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${file_op_install}")
if(arg_BUILD_TIME_SCRIPT_PATH_OUT_VAR)
set(${arg_BUILD_TIME_SCRIPT_PATH_OUT_VAR} "${file_op_build}" PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,446 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Parse purl arguments for a specific purl variant, e.g. for parsing all values of arg_PURL_QT_ARGS.
# arguments_var_name is the variable name that contains the args.
macro(_qt_internal_sbom_parse_purl_variant_options prefix arguments_var_name)
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
cmake_parse_arguments(arg "${purl_opt_args}" "${purl_single_args}" "${purl_multi_args}"
${${arguments_var_name}})
_qt_internal_validate_all_args_are_parsed(arg)
endmacro()
# Returns a vcs url where for purls where qt entities of the current repo are hosted.
function(_qt_internal_sbom_get_qt_entity_vcs_url target)
set(opt_args "")
set(single_args
REPO_NAME
VERSION
OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_REPO_NAME)
message(FATAL_ERROR "REPO_NAME must be set")
endif()
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
set(version_part "")
if(arg_VERSION)
set(version_part "@${arg_VERSION}")
endif()
set(vcs_url "https://code.qt.io/qt/${arg_REPO_NAME}.git${version_part}")
set(${arg_OUT_VAR} "${vcs_url}" PARENT_SCOPE)
endfunction()
# Returns a relative path to the source where the target was created, to be embedded into a
# mirror purl as a subpath.
function(_qt_internal_sbom_get_qt_entity_repo_source_dir target)
set(opt_args "")
set(single_args
OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
get_target_property(repo_source_dir "${target}" SOURCE_DIR)
# Get the path relative to the PROJECT_SOURCE_DIR
file(RELATIVE_PATH relative_repo_source_dir "${PROJECT_SOURCE_DIR}" "${repo_source_dir}")
set(sub_path "${relative_repo_source_dir}")
set(${arg_OUT_VAR} "${sub_path}" PARENT_SCOPE)
endfunction()
# Handles purl arguments specified to functions like qt_internal_add_sbom.
# Currently accepts arguments for 3 variants of purls, each of which will generate a separate purl.
# If no arguments are specified, for qt entity types, default values will be chosen.
#
# Purl variants:
# - PURL_QT_ARGS
# args to override Qt's generic purl for Qt modules or patched 3rd party libs
# defaults to something like pkg:generic/TheQtCompany/${repo_name}-${target}@SHA1
# - PURL_MIRROR_ARGS
# args to override Qt's mirror purl, which is hosted on github
# defaults to something like pkg:github/qt/${repo_name}@SHA1
# - PURL_3RDPARTY_UPSTREAM_ARGS
# args to specify a purl pointing to an upstream repo, usually to github or another forge
# no defaults, but could look like: pkg:github/harfbuzz/harfbuzz@v8.5.0
# Example values for harfbuzz:
# PURL_3RDPARTY_UPSTREAM_ARGS
# PURL_TYPE "github"
# PURL_NAMESPACE "harfbuzz"
# PURL_NAME "harfbuzz"
# PURL_VERSION "v8.5.0" # tag
function(_qt_internal_sbom_handle_purl_values target)
_qt_internal_get_sbom_purl_handling_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
# List of purl variants to process.
set(purl_variants "")
_qt_internal_sbom_get_git_version_vars()
set(third_party_types
QT_THIRD_PARTY_MODULE
QT_THIRD_PARTY_SOURCES
)
if(arg_IS_QT_ENTITY_TYPE)
# Qt entities have two purls by default, a QT generic one and a MIRROR hosted on github.
list(APPEND purl_variants MIRROR QT)
elseif(arg_TYPE IN_LIST third_party_types)
# Third party libraries vendored in Qt also have at least two purls, like regular Qt
# libraries, but might also have an upstream one.
# The order in which the purls are generated matters for tools that consume the SBOM. Some
# tools can only handle one PURL per package, so the first one should be the important one.
# For now, I deem that the upstream one if present. Otherwise the github mirror.
if(arg_PURL_3RDPARTY_UPSTREAM_ARGS)
list(APPEND purl_variants 3RDPARTY_UPSTREAM)
endif()
list(APPEND purl_variants MIRROR QT)
else()
# If handling another entity type, handle based on whether any of the purl arguments are
# set.
set(known_purl_variants QT MIRROR 3RDPARTY_UPSTREAM)
foreach(known_purl_variant IN LISTS known_purl_variants)
if(arg_PURL_${known_purl_variant}_ARGS)
list(APPEND purl_variants ${known_purl_variant})
endif()
endforeach()
endif()
if(arg_IS_QT_ENTITY_TYPE
OR arg_TYPE STREQUAL "QT_THIRD_PARTY_MODULE"
OR arg_TYPE STREQUAL "QT_THIRD_PARTY_SOURCES"
)
set(is_qt_purl_entity_type TRUE)
else()
set(is_qt_purl_entity_type FALSE)
endif()
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
set(project_package_options "")
foreach(purl_variant IN LISTS purl_variants)
# Clear previous values.
foreach(option_name IN LISTS purl_opt_args purl_single_args purl_multi_args)
unset(arg_${option_name})
endforeach()
_qt_internal_sbom_parse_purl_variant_options(arg arg_PURL_${purl_variant}_ARGS)
# Check if custom purl args were specified.
set(purl_args_available FALSE)
if(arg_PURL_${purl_variant}_ARGS)
set(purl_args_available TRUE)
endif()
# We want to create a purl either if it's one of Qt's entities and one of it's default
# purl types, or if custom args were specified.
set(consider_purl_processing FALSE)
if((purl_args_available OR is_qt_purl_entity_type) AND NOT arg_NO_PURL)
set(consider_purl_processing TRUE)
endif()
if(consider_purl_processing)
set(purl_args "")
# Override the purl version with the package version.
if(arg_PURL_USE_PACKAGE_VERSION AND arg_VERSION)
set(arg_PURL_VERSION "${arg_VERSION}")
endif()
# Append a vcs_url to the qualifiers if specified.
if(arg_PURL_VCS_URL)
list(APPEND arg_PURL_QUALIFIERS "vcs_url=${arg_PURL_VCS_URL}")
endif()
_qt_internal_forward_function_args(
FORWARD_APPEND
FORWARD_PREFIX arg
FORWARD_OUT_VAR purl_args
FORWARD_OPTIONS
${purl_opt_args}
FORWARD_SINGLE
${purl_single_args}
FORWARD_MULTI
${purl_multi_args}
)
# Qt entity types get special treatment purl.
if(is_qt_purl_entity_type AND NOT arg_NO_DEFAULT_QT_PURL AND
(purl_variant STREQUAL "QT" OR purl_variant STREQUAL "MIRROR"))
_qt_internal_sbom_get_root_project_name_lower_case(repo_project_name_lowercase)
# Add a vcs_url to the generic QT variant.
if(purl_variant STREQUAL "QT")
set(entity_vcs_url_version_option "")
# Can be empty.
if(QT_SBOM_GIT_HASH_SHORT)
set(entity_vcs_url_version_option VERSION "${QT_SBOM_GIT_HASH_SHORT}")
endif()
_qt_internal_sbom_get_qt_entity_vcs_url(${target}
REPO_NAME "${repo_project_name_lowercase}"
${entity_vcs_url_version_option}
OUT_VAR vcs_url)
list(APPEND purl_args PURL_QUALIFIERS "vcs_url=${vcs_url}")
endif()
# Add the subdirectory path where the target was created as a custom qualifier.
_qt_internal_sbom_get_qt_entity_repo_source_dir(${target} OUT_VAR sub_path)
if(sub_path)
list(APPEND purl_args PURL_SUBPATH "${sub_path}")
endif()
# Add the target name as a custom qualifer.
list(APPEND purl_args PURL_QUALIFIERS "library_name=${target}")
# Can be empty.
if(QT_SBOM_GIT_HASH_SHORT)
list(APPEND purl_args VERSION "${QT_SBOM_GIT_HASH_SHORT}")
endif()
# Get purl args the Qt entity type, taking into account defaults.
_qt_internal_sbom_get_qt_entity_purl_args(${target}
NAME "${repo_project_name_lowercase}-${target}"
REPO_NAME "${repo_project_name_lowercase}"
SUPPLIER "${arg_SUPPLIER}"
PURL_VARIANT "${purl_variant}"
${purl_args}
OUT_VAR purl_args
)
endif()
_qt_internal_sbom_assemble_purl(${target}
${purl_args}
OUT_VAR package_manager_external_ref
)
list(APPEND project_package_options ${package_manager_external_ref})
endif()
endforeach()
set(direct_values
PURL_QT_VALUES
PURL_MIRROR_VALUES
PURL_3RDPARTY_UPSTREAM_VALUES
)
foreach(direct_value IN LISTS direct_values)
if(arg_${direct_value})
set(direct_values_per_type "")
foreach(direct_value IN LISTS arg_${direct_value})
_qt_internal_sbom_get_purl_value_extref(
VALUE "${direct_value}" OUT_VAR package_manager_external_ref)
list(APPEND direct_values_per_type ${package_manager_external_ref})
endforeach()
# The order in which the purls are generated, matters for tools that consume the SBOM.
# Some tools can only handle one PURL per package, so the first one should be the
# important one.
# For now, I deem that the directly specified ones (probably via a qt_attribution.json
# file) are the more important ones. So we prepend them.
list(PREPEND project_package_options ${direct_values_per_type})
endif()
endforeach()
set(${arg_OUT_VAR} "${project_package_options}" PARENT_SCOPE)
endfunction()
# Gets a list of arguments to pass to _qt_internal_sbom_assemble_purl when handling a Qt entity
# type. The purl for Qt entity types have Qt-specific defaults, but can be overridden per purl
# component.
# The arguments are saved in OUT_VAR.
function(_qt_internal_sbom_get_qt_entity_purl_args target)
set(opt_args "")
set(single_args
NAME
REPO_NAME
SUPPLIER
VERSION
PURL_VARIANT
OUT_VAR
)
set(multi_args "")
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
list(APPEND opt_args ${purl_opt_args})
list(APPEND single_args ${purl_single_args})
list(APPEND multi_args ${purl_multi_args})
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(supported_purl_variants QT MIRROR)
if(NOT arg_PURL_VARIANT IN_LIST supported_purl_variants)
message(FATAL_ERROR "PURL_VARIANT unknown: ${arg_PURL_VARIANT}")
endif()
if(arg_PURL_VARIANT STREQUAL "QT")
set(purl_type "generic")
set(purl_namespace "${arg_SUPPLIER}")
set(purl_name "${arg_NAME}")
set(purl_version "${arg_VERSION}")
elseif(arg_PURL_VARIANT STREQUAL "MIRROR")
set(purl_type "github")
set(purl_namespace "qt")
set(purl_name "${arg_REPO_NAME}")
set(purl_version "${arg_VERSION}")
endif()
if(arg_PURL_TYPE)
set(purl_type "${arg_PURL_TYPE}")
endif()
if(arg_PURL_NAMESPACE)
set(purl_namespace "${arg_PURL_NAMESPACE}")
endif()
if(arg_PURL_NAME)
set(purl_name "${arg_PURL_NAME}")
endif()
if(arg_PURL_VERSION)
set(purl_version "${arg_PURL_VERSION}")
endif()
set(purl_version_option "")
if(purl_version)
set(purl_version_option PURL_VERSION "${purl_version}")
endif()
set(purl_args
PURL_TYPE "${purl_type}"
PURL_NAMESPACE "${purl_namespace}"
PURL_NAME "${purl_name}"
${purl_version_option}
)
if(arg_PURL_QUALIFIERS)
list(APPEND purl_args PURL_QUALIFIERS "${arg_PURL_QUALIFIERS}")
endif()
if(arg_PURL_SUBPATH)
list(APPEND purl_args PURL_SUBPATH "${arg_PURL_SUBPATH}")
endif()
set(${arg_OUT_VAR} "${purl_args}" PARENT_SCOPE)
endfunction()
# Assembles an external reference purl identifier.
# PURL_TYPE and PURL_NAME are required.
# Stores the result in the OUT_VAR.
# Accepted options:
# PURL_TYPE
# PURL_NAME
# PURL_NAMESPACE
# PURL_VERSION
# PURL_SUBPATH
# PURL_QUALIFIERS
function(_qt_internal_sbom_assemble_purl target)
set(opt_args "")
set(single_args
OUT_VAR
)
set(multi_args "")
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
list(APPEND opt_args ${purl_opt_args})
list(APPEND single_args ${purl_single_args})
list(APPEND multi_args ${purl_multi_args})
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(purl_scheme "pkg")
if(NOT arg_PURL_TYPE)
message(FATAL_ERROR "PURL_TYPE must be set")
endif()
if(NOT arg_PURL_NAME)
message(FATAL_ERROR "PURL_NAME must be set")
endif()
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
# https://github.com/package-url/purl-spec
# Spec is 'scheme:type/namespace/name@version?qualifiers#subpath'
set(purl "${purl_scheme}:${arg_PURL_TYPE}")
if(arg_PURL_NAMESPACE)
string(APPEND purl "/${arg_PURL_NAMESPACE}")
endif()
string(APPEND purl "/${arg_PURL_NAME}")
if(arg_PURL_VERSION)
string(APPEND purl "@${arg_PURL_VERSION}")
endif()
if(arg_PURL_QUALIFIERS)
# TODO: Note that the qualifiers are expected to be URL encoded, which this implementation
# is not doing at the moment.
list(JOIN arg_PURL_QUALIFIERS "&" qualifiers)
string(APPEND purl "?${qualifiers}")
endif()
if(arg_PURL_SUBPATH)
string(APPEND purl "#${arg_PURL_SUBPATH}")
endif()
_qt_internal_sbom_get_purl_value_extref(VALUE "${purl}" OUT_VAR result)
set(${arg_OUT_VAR} "${result}" PARENT_SCOPE)
endfunction()
# Takes a PURL VALUE and returns an SBOM purl external reference in OUT_VAR.
function(_qt_internal_sbom_get_purl_value_extref)
set(opt_args "")
set(single_args
OUT_VAR
VALUE
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
if(NOT arg_VALUE)
message(FATAL_ERROR "VALUE must be set")
endif()
# SPDX SBOM External reference type.
set(ext_ref_prefix "PACKAGE-MANAGER purl")
set(external_ref "${ext_ref_prefix} ${arg_VALUE}")
set(result "EXTREF" "${external_ref}")
set(${arg_OUT_VAR} "${result}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,250 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Helper macro to find python and a given dependency. Expects the caller to set all of the vars.
# Meant to reduce the line noise due to the repeated calls.
macro(_qt_internal_sbom_find_python_and_dependency_helper_lambda)
_qt_internal_sbom_find_python_and_dependency_helper(
PYTHON_ARGS
${extra_python_args}
${python_common_args}
DEPENDENCY_ARGS
DEPENDENCY_IMPORT_STATEMENT "${import_statement}"
OUT_VAR_PYTHON_PATH python_path
OUT_VAR_PYTHON_FOUND python_found
OUT_VAR_DEP_FOUND dep_found
OUT_VAR_PYTHON_AND_DEP_FOUND everything_found
OUT_VAR_DEP_FIND_OUTPUT dep_find_output
)
endmacro()
# Tries to find python and a given dependency based on the args passed to PYTHON_ARGS and
# DEPENDENCY_ARGS which are forwarded to the respective finding functions.
# Returns the path to the python interpreter, whether it was found, whether the dependency was
# found, whether both were found, and the reason why the dependency might not be found.
function(_qt_internal_sbom_find_python_and_dependency_helper)
set(opt_args)
set(single_args
OUT_VAR_PYTHON_PATH
OUT_VAR_PYTHON_FOUND
OUT_VAR_DEP_FOUND
OUT_VAR_PYTHON_AND_DEP_FOUND
OUT_VAR_DEP_FIND_OUTPUT
)
set(multi_args
PYTHON_ARGS
DEPENDENCY_ARGS
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(everything_found_inner FALSE)
set(deps_find_output_inner "")
if(NOT arg_OUT_VAR_PYTHON_PATH)
message(FATAL_ERROR "OUT_VAR_PYTHON_PATH var is required")
endif()
if(NOT arg_OUT_VAR_PYTHON_FOUND)
message(FATAL_ERROR "OUT_VAR_PYTHON_FOUND var is required")
endif()
if(NOT arg_OUT_VAR_DEP_FOUND)
message(FATAL_ERROR "OUT_VAR_DEP_FOUND var is required")
endif()
if(NOT arg_OUT_VAR_PYTHON_AND_DEP_FOUND)
message(FATAL_ERROR "OUT_VAR_PYTHON_AND_DEP_FOUND var is required")
endif()
if(NOT arg_OUT_VAR_DEP_FIND_OUTPUT)
message(FATAL_ERROR "OUT_VAR_DEP_FIND_OUTPUT var is required")
endif()
_qt_internal_sbom_find_python_helper(
${arg_PYTHON_ARGS}
OUT_VAR_PYTHON_PATH python_path_inner
OUT_VAR_PYTHON_FOUND python_found_inner
)
if(python_found_inner AND python_path_inner)
_qt_internal_sbom_find_python_dependency_helper(
${arg_DEPENDENCY_ARGS}
PYTHON_PATH "${python_path_inner}"
OUT_VAR_FOUND dep_found_inner
OUT_VAR_OUTPUT dep_find_output_inner
)
if(dep_found_inner)
set(everything_found_inner TRUE)
endif()
endif()
set(${arg_OUT_VAR_PYTHON_PATH} "${python_path_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_PYTHON_FOUND} "${python_found_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_DEP_FOUND} "${dep_found_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_PYTHON_AND_DEP_FOUND} "${everything_found_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_DEP_FIND_OUTPUT} "${dep_find_output_inner}" PARENT_SCOPE)
endfunction()
# Tries to find the python intrepreter, given the QT_SBOM_PYTHON_INTERP path hint, as well as
# other options.
# Ignores any previously found python.
# Returns the python interpreter path and whether it was successfully found.
#
# This is intentionally a function, and not a macro, to prevent overriding the Python3_EXECUTABLE
# non-cache variable in a global scope in case if a different python is found and used for a
# different purpose (e.g. qtwebengine or qtinterfaceframework).
# The reason to use a different python is that an already found python might not be the version we
# need, or might lack the dependencies we need.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21797#note_901621 claims that finding multiple
# python versions in separate directory scopes is possible, and I claim a function scope is as
# good as a directory scope.
function(_qt_internal_sbom_find_python_helper)
set(opt_args
SEARCH_IN_FRAMEWORKS
QUIET
)
set(single_args
VERSION
OUT_VAR_PYTHON_PATH
OUT_VAR_PYTHON_FOUND
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR_PYTHON_PATH)
message(FATAL_ERROR "OUT_VAR_PYTHON_PATH var is required")
endif()
if(NOT arg_OUT_VAR_PYTHON_FOUND)
message(FATAL_ERROR "OUT_VAR_PYTHON_FOUND var is required")
endif()
# Allow disabling looking for a python interpreter shipped as part of a macOS system framework.
if(NOT arg_SEARCH_IN_FRAMEWORKS)
set(Python3_FIND_FRAMEWORK NEVER)
endif()
set(required_version "")
if(arg_VERSION)
set(required_version "${arg_VERSION}")
endif()
set(find_quiet "")
if(arg_QUIET)
set(find_quiet "QUIET")
endif()
# Locally reset any executable that was possibly already found.
# We do this to ensure we always re-do the lookup/
# This needs to be set to an empty string, to override any cache variable
set(Python3_EXECUTABLE "")
# This needs to be unset, because the Python module checks whether the variable is defined, not
# whether it is empty.
unset(_Python3_EXECUTABLE)
if(QT_SBOM_PYTHON_INTERP)
set(Python3_ROOT_DIR ${QT_SBOM_PYTHON_INTERP})
endif()
find_package(Python3 ${required_version} ${find_quiet} COMPONENTS Interpreter)
set(${arg_OUT_VAR_PYTHON_PATH} "${Python3_EXECUTABLE}" PARENT_SCOPE)
set(${arg_OUT_VAR_PYTHON_FOUND} "${Python3_Interpreter_FOUND}" PARENT_SCOPE)
endfunction()
# Helper that takes an python import statement to run using the given python interpreter path,
# to confirm that the given python dependency can be found.
# Returns whether the dependency was found and the output of running the import, for error handling.
function(_qt_internal_sbom_find_python_dependency_helper)
set(opt_args "")
set(single_args
DEPENDENCY_IMPORT_STATEMENT
PYTHON_PATH
OUT_VAR_FOUND
OUT_VAR_OUTPUT
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_PYTHON_PATH)
message(FATAL_ERROR "Python interpreter path not given.")
endif()
if(NOT arg_DEPENDENCY_IMPORT_STATEMENT)
message(FATAL_ERROR "Python depdendency import statement not given.")
endif()
if(NOT arg_OUT_VAR_FOUND)
message(FATAL_ERROR "Out var found variable not given.")
endif()
set(python_path "${arg_PYTHON_PATH}")
execute_process(
COMMAND
${python_path} -c "${arg_DEPENDENCY_IMPORT_STATEMENT}"
RESULT_VARIABLE res
OUTPUT_VARIABLE output
ERROR_VARIABLE output
)
if("${res}" STREQUAL "0")
set(found TRUE)
set(output "${output}")
else()
set(found FALSE)
string(CONCAT output "SBOM Python dependency ${arg_DEPENDENCY_IMPORT_STATEMENT} not found. "
"Error:\n${output}")
endif()
set(${arg_OUT_VAR_FOUND} "${found}" PARENT_SCOPE)
if(arg_OUT_VAR_OUTPUT)
set(${arg_OUT_VAR_OUTPUT} "${output}" PARENT_SCOPE)
endif()
endfunction()
# Helper to find a python installed CLI utility.
# Expected to be in PATH.
function(_qt_internal_sbom_find_python_dependency_program)
set(opt_args
REQUIRED
)
set(single_args
NAME
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(program_name "${arg_NAME}")
string(TOUPPER "${program_name}" upper_name)
set(cache_var "QT_SBOM_PROGRAM_${upper_name}")
set(hints "")
# The path to python installed apps is different on Windows compared to UNIX, so we use
# a different path than where the python interpreter might be located.
if(QT_SBOM_PYTHON_APPS_PATH)
list(APPEND hints ${QT_SBOM_PYTHON_APPS_PATH})
endif()
find_program(${cache_var}
NAMES ${program_name}
HINTS ${hints}
)
if(NOT ${cache_var})
if(arg_REQUIRED)
set(message_type "FATAL_ERROR")
set(prefix "Required ")
else()
set(message_type "STATUS")
set(prefix "Optional ")
endif()
message(${message_type} "${prefix}SBOM python program '${program_name}' not found.")
endif()
endfunction()

View File

@ -0,0 +1,162 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Records information about a system library target, usually due to a qt_find_package call.
# This information is later used to generate packages for the system libraries, but only after
# confirming that the library was used (linked) into any of the Qt targets.
function(_qt_internal_sbom_record_system_library_usage target)
if(NOT QT_GENERATE_SBOM)
return()
endif()
set(opt_args "")
set(single_args
TYPE
PACKAGE_VERSION
FRIENDLY_PACKAGE_NAME
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_TYPE)
message(FATAL_ERROR "TYPE must be set")
endif()
# A package might be looked up more than once, make sure to record it once.
get_property(already_recorded GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_target_${target})
if(already_recorded)
return()
endif()
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_target_${target} TRUE)
# Defer spdx id creation until _qt_internal_sbom_begin_project is called, so we know the
# project name. The project name is used in the package infix generation of the system library,
# but _qt_internal_sbom_record_system_library_usage might be called before sbom generation
# has started, e.g. during _qt_internal_find_third_party_dependencies.
set(spdx_options
${target}
TYPE "${arg_TYPE}"
PACKAGE_NAME "${arg_FRIENDLY_PACKAGE_NAME}"
)
get_cmake_property(sbom_repo_begin_called _qt_internal_sbom_repo_begin_called)
if(sbom_repo_begin_called AND TARGET "${target}")
_qt_internal_sbom_record_system_library_spdx_id(${target} ${spdx_options})
else()
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_spdx_options_${target} "${spdx_options}")
endif()
# Defer sbom info creation until we detect usage of the system library (whether the library is
# linked into any other target).
set_property(GLOBAL APPEND PROPERTY
_qt_internal_sbom_recorded_system_library_targets "${target}")
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_options_${target} "${ARGN}")
endfunction()
# Helper to record spdx ids of all system library targets that were found so far.
function(_qt_internal_sbom_record_system_library_spdx_ids)
get_property(recorded_targets GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_targets)
if(NOT recorded_targets)
return()
endif()
foreach(target IN LISTS recorded_targets)
get_property(args GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_spdx_options_${target})
# qt_find_package PROVIDED_TARGETS might refer to non-existent targets in certain cases,
# like zstd::libzstd_shared for qt_find_package(WrapZSTD), because we are not sure what
# kind of zstd build was done. Make sure to check if the target exists before recording it.
if(TARGET "${target}")
set(target_unaliased "${target}")
get_target_property(aliased_target "${target}" ALIASED_TARGET)
if(aliased_target)
set(target_unaliased ${aliased_target})
endif()
_qt_internal_sbom_record_system_library_spdx_id(${target_unaliased} ${args})
else()
message(DEBUG
"Skipping recording system library for SBOM because target does not exist: "
" ${target}")
endif()
endforeach()
endfunction()
# Helper to record the spdx id of a system library target.
function(_qt_internal_sbom_record_system_library_spdx_id target)
# Save the spdx id before the sbom info is added, so we can refer to it in relationships.
_qt_internal_sbom_record_target_spdx_id(${ARGN} OUT_VAR package_spdx_id)
if(NOT package_spdx_id)
message(FATAL_ERROR "Could not generate spdx id for system library target: ${target}")
endif()
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_package_${target} "${package_spdx_id}")
endfunction()
# Goes through the list of consumed system libraries (those that were linked in) and creates
# sbom packages for them.
# Uses information from recorded system libraries (calls to qt_find_package).
function(_qt_internal_sbom_add_recorded_system_libraries)
get_property(recorded_targets GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_targets)
get_property(consumed_targets GLOBAL PROPERTY _qt_internal_sbom_consumed_system_library_targets)
set(unconsumed_targets "${recorded_targets}")
set(generated_package_names "")
foreach(target IN LISTS consumed_targets)
# Some system targets like qtspeech SpeechDispatcher::SpeechDispatcher might be aliased,
# and we can't set properties on them, so unalias the target name.
set(target_original "${target}")
get_target_property(aliased_target "${target}" ALIASED_TARGET)
if(aliased_target)
set(target ${aliased_target})
endif()
get_property(args GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_options_${target})
get_property(package_name GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_package_${target})
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_target_${target} "")
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_options_${target} "")
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_package_${target} "")
# Guard against generating a package multiple times. Can happen when multiple targets belong
# to the same package.
if(sbom_generated_${package_name})
continue()
endif()
# Automatic system library sbom recording happens at project root source dir scope, which
# means it might accidentally pick up a qt_attribution.json file from the project root,
# that is not intended to be use for system libraries.
# For now, explicitly disable using the root attribution file.
list(APPEND args NO_CURRENT_DIR_ATTRIBUTION)
list(APPEND generated_package_names "${package_name}")
set(sbom_generated_${package_name} TRUE)
_qt_internal_extend_sbom(${target} ${args})
_qt_internal_finalize_sbom(${target})
list(REMOVE_ITEM unconsumed_targets "${target_original}")
endforeach()
message(DEBUG "System libraries that were recorded, but not consumed: ${unconsumed_targets}")
message(DEBUG "Generated SBOMs for the following system packages: ${generated_package_names}")
# Clean up, before configuring next repo project.
set_property(GLOBAL PROPERTY _qt_internal_sbom_consumed_system_library_targets "")
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_targets "")
endfunction()

View File

@ -68,7 +68,10 @@ is not specified")
# It's necessary to call actual test inside 'cmd.exe', because 'execute_process' uses
# SW_HIDE to avoid showing a console window, it affects other GUI as well.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/17690 for details.
set(extra_runner "cmd /c")
#
# Run the command using the proxy 'call' command to avoid issues related to invalid
# processing of quotes and spaces in cmd.exe arguments.
set(extra_runner "cmd /c call")
endif()
if(arg_PRE_RUN)

View File

@ -31,3 +31,77 @@ function(qt_internal_sbom_end_qt_repo_project)
_qt_internal_sbom_end_qt_repo_project(${ARGN})
endfunction()
function(qt_internal_sbom_add_files)
_qt_internal_sbom_add_files(${ARGN})
endfunction()
function(qt_internal_sbom_add_cmake_include_step)
_qt_internal_sbom_add_cmake_include_step(${ARGN})
endfunction()
function(qt_internal_sbom_add_external_reference)
_qt_internal_sbom_generate_add_external_reference(${ARGN})
endfunction()
function(qt_internal_sbom_add_project_relationship)
_qt_internal_sbom_generate_add_project_relationship(${ARGN})
endfunction()
function(qt_internal_sbom_generate_tag_value_spdx_document)
_qt_internal_sbom_generate_tag_value_spdx_document(${ARGN})
set(opt_args "")
set(single_args
OUT_VAR_OUTPUT_FILE_NAME
OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
if(arg_OUT_VAR_OUTPUT_FILE_NAME)
set(${arg_OUT_VAR_OUTPUT_FILE_NAME} "${${arg_OUT_VAR_OUTPUT_FILE_NAME}}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH)
set(${arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH} "${${arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH}}"
PARENT_SCOPE)
endif()
endfunction()
function(qt_internal_sbom_get_project_spdx_id out_var)
set(result "")
if(QT_GENERATE_SBOM)
get_cmake_property(project_spdx_id _qt_internal_sbom_project_spdx_id)
if(project_spdx_id)
set(result "${project_spdx_id}")
endif()
endif()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
function(qt_internal_sbom_get_target_spdx_id target out_var)
set(result "")
if(QT_GENERATE_SBOM)
_qt_internal_sbom_get_spdx_id_for_target(${target} result)
endif()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
function(qt_internal_sbom_get_external_document_ref_spdx_id project_name out_var)
set(result "")
if(QT_GENERATE_SBOM)
string(TOLOWER "${project_name}" project_name_lowercase)
_qt_internal_sbom_get_external_document_ref_spdx_id("${project_name_lowercase}" result)
endif()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
macro(qt_internal_sbom_get_git_version_vars)
_qt_internal_sbom_get_git_version_vars()
endmacro()

View File

@ -902,6 +902,20 @@ function(qt_internal_add_test name)
endif()
endif()
if(MACOS AND NOT CMAKE_GENERATOR STREQUAL "Xcode")
# Add com.apple.security.get-task-allow entitlement to each
# test binary, so we can hook into the Swift crash handling.
if(NOT arg_QMLTEST AND arg_SOURCES)
set(entitlements_file
"${__qt_internal_cmake_apple_support_files_path}/test.entitlements.plist")
add_custom_command(TARGET "${name}"
POST_BUILD COMMAND codesign --sign -
--entitlements "${entitlements_file}"
"$<TARGET_FILE:${name}>"
)
endif()
endif()
qt_internal_add_test_finalizers("${name}")
endfunction()

View File

@ -385,6 +385,7 @@ function(qt_export_tools module_name)
# List of package dependencies that need be find_package'd when using the Tools package.
set(package_deps "")
set(third_party_deps "")
# Additional cmake files to install
set(extra_cmake_files "")
@ -397,7 +398,15 @@ function(qt_export_tools module_name)
# e.g. qtwaylandscanner depends on WaylandScanner (non-qt package).
get_target_property(extra_packages "${tool_name}" QT_EXTRA_PACKAGE_DEPENDENCIES)
if(extra_packages)
list(APPEND package_deps "${extra_packages}")
foreach(third_party_dep IN LISTS extra_packages)
list(GET third_party_dep 0 third_party_dep_name)
list(GET third_party_dep 1 third_party_dep_version)
# Assume that all tool thirdparty deps are mandatory.
# TODO: Components are not supported
list(APPEND third_party_deps
"${third_party_dep_name}\\\;FALSE\\\;${third_party_dep_version}\\\;\\\;")
endforeach()
endif()
get_target_property(_extra_cmake_files "${tool_name}" EXTRA_CMAKE_FILES)

View File

@ -7,10 +7,10 @@ function (qt_internal_setup_wasm_target_properties wasmTarget)
target_link_options("${wasmTarget}" INTERFACE
"SHELL:-s MAX_WEBGL_VERSION=2"
"SHELL:-s FETCH=1"
"SHELL:-s WASM_BIGINT=1"
"SHELL:-s STACK_SIZE=5MB")
set(executable_link_flags "-sFETCH")
## wasm64
if (WASM64)
target_compile_options("${wasmTarget}" INTERFACE "SHELL:-s MEMORY64=1" )
@ -99,7 +99,7 @@ function (qt_internal_setup_wasm_target_properties wasmTarget)
set(enable_side_module_if_needed
"$<$<IN_LIST:$<TARGET_PROPERTY:TYPE>,${side_modules}>:SHELL:-s SIDE_MODULE=1>")
set(enable_main_module_if_needed
"$<$<IN_LIST:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:SHELL:-s MAIN_MODULE=1>")
"$<$<IN_LIST:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:SHELL:-sMAIN_MODULE=1 ${executable_link_flags}>")
set(set_shared_module_type_if_needed
"${enable_side_module_if_needed}"
"${enable_main_module_if_needed}"
@ -115,7 +115,7 @@ function (qt_internal_setup_wasm_target_properties wasmTarget)
target_link_options("${wasmTarget}" INTERFACE "${set_shared_module_type_if_needed}")
else()
target_link_options("${wasmTarget}" INTERFACE "SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=1")
target_link_options("${wasmTarget}" INTERFACE "SHELL:-sERROR_ON_UNDEFINED_SYMBOLS=1 ${executable_link_flags}")
endif()
# Suppress warnings for known issues for developer builds

View File

@ -8,7 +8,7 @@ function(qt_internal_check_msvc_versions)
set(min_msvc_version "1930")
if(MSVC_VERSION VERSION_LESS min_msvc_version)
message(FATAL_ERROR
"Qt requires at least Visual Studio 2019 (MSVC ${min_msvc_version} or newer), "
"Qt requires at least Visual Studio 2022 (MSVC ${min_msvc_version} or newer), "
"you're building against version ${MSVC_VERSION}. "
"You can turn off this version check by setting QT_NO_MSVC_MIN_VERSION_CHECK to ON."
)

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>

View File

@ -141,6 +141,16 @@ instructions:
maxTimeBetweenOutput: 14400
userMessageOnFailure: >
Failed to run tests.
- type: ExecuteCommand
command: >
cmake -E copy
Testing{{.Env.CI_PATH_SEP}}Temporary{{.Env.CI_PATH_SEP}}LastTest.log
{{.Env.COIN_CTEST_RESULTSDIR}}{{.Env.CI_PATH_SEP}}CTest.log
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
ignoreExitCode: false
userMessageOnFailure: >
Failed to copy LastTest.log to testresults directory.
executeOn: always
- type: Group
enable_if:
condition: runtime
@ -155,16 +165,13 @@ instructions:
maxTimeBetweenOutput: 14400
userMessageOnFailure: >
Failed to run tests.
- type: Group
instructions:
- type: ExecuteCommand
command: >
cmake -E copy
Testing{{.Env.CI_PATH_SEP}}Temporary{{.Env.CI_PATH_SEP}}LastTest.log
{{.Env.COIN_CTEST_RESULTSDIR}}{{.Env.CI_PATH_SEP}}CTest.log
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
ignoreExitCode: false
ignoreExitCode: true
userMessageOnFailure: >
Failed to copy LastTest.log to testresults directory.
executeOn: always

View File

@ -10,7 +10,7 @@ instructions:
testdir="$(dirname $1)"
testexecutable="$1"
echo RUNNING via serial: "$quoted_args"
echo "cmd rtp exec -p 200 -t 0x01000000 -u 1000000 $testexecutable -- $quoted_args" > /home/qt/work/vx.sh
echo "cmd rtp exec -p 200 -t 0x01000000 -u 0x1000000 $testexecutable -- $quoted_args" > /home/qt/work/vx.sh
echo "cmd echo \"qtest_in_vxworks_complete: $?\"" >> /home/qt/work/vx.sh
#rtp exec Execute a process.
# -p : specify the initial task priority
@ -22,11 +22,17 @@ instructions:
# qtest_in_vxworks_complete echo is used to detect test process completion as it will
# be echoed after test process ends normally or crashes when normal log lines are not present.
# Check that emulator is functioning
echo "cmd echo \"health check\"" > /tmp/guest.in
sleep 0.5
read -t 5 echoline</tmp/guest.out
read -t 1 testline</tmp/guest.out
( echo "cmd echo \"health check\"" > /tmp/guest.in ) & pid=$!
( sleep 5 && kill -HUP $pid ) 2>/dev/null & watcher=$!
wait $pid 2>/dev/null && pkill -HUP -P $watcher
if [[ "$?" -eq "0" ]]; then
read -t 5 echoline</tmp/guest.out
read -t 1 testline</tmp/guest.out
fi
if [[ -z "$testline" ]]; then
echo "Restarting stuck emulator"
pkill qemu-system
@ -58,4 +64,16 @@ instructions:
exitcode=$(echo "$line" | sed -nr 's/qtest_in_vxworks_complete: (-?[0-9]+)/\1/gp' | tr -d '\r')
exit $exitcode
fi
# Handle crashes
if echo "$line" | /usr/bin/grep -qE "(SIGSEGV)|(SIGABRT)"
then
# Empty output pipe
while read -t 1 line; do
echo $line
done < /tmp/guest.out
echo "Test crashed"
pkill qemu-system # Kill emulator to force restart on next test start
exit 1
fi
done < /tmp/guest.out

View File

@ -15,6 +15,9 @@ productname = Qt
navigation.homepage = index.html
navigation.hometitle = "$productname $QT_VER"
# Set trademarks page (located in qt/qtdoc)
navigation.trademarkspage = Trademarks
#Words to ignore for auto-linking
ignorewords += \
macOS \

View File

@ -36,6 +36,10 @@
\externalpage https://developer.android.com/build/configure-app-module
\title Android: Configure the app module
*/
/*!
\externalpage https://developer.android.com/ndk/guides/ndk-stack
\title Android: ndk-stack
*/
/*!
\externalpage https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl
\title iOS: canOpenURL:

View File

@ -126,8 +126,9 @@ macro.QtMinorVersion.match = "\\d+\\.(\\d+)"
# along with the offline docs, you must specify it manually. In .qdocconf, to do it for all formats
# at once, add:
#
# {HTML.extraimages,qhp.QtDoc.extraFiles, DocBook.extraimages} += images/dQw4w9WgXcQ.jpg
# {HTML.extraimages,qhp.<qhp_project>.extraFiles,DocBook.extraimages} += images/dQw4w9WgXcQ.jpg
#
# Where <qhp_project> is a project name listed in `qhp.projects`.
macro.youtube.HTML = "<div class=\"video\">\n" \
"<a href=\"https://www.youtube.com/watch/?v=\1\">\n"\
"<img src=\"images/\1.jpg\"" \

View File

@ -6,10 +6,26 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QScreen>
#if QT_CONFIG(translation)
# include <QLocale>
# include <QLibraryInfo>
# include <QTranslator>
#endif
using namespace Qt::StringLiterals;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
#if QT_CONFIG(translation)
QTranslator translator;
if (translator.load(QLocale::system(), "qtbase"_L1, "_"_L1,
QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
app.installTranslator(&translator);
}
#endif
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCommandLineParser parser;

View File

@ -18,7 +18,7 @@
Browser::Browser(QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::Browser)
, m_ui{std::make_unique<Ui::Browser>()}
{
m_ui->setupUi(this);
@ -60,9 +60,7 @@ Browser::Browser(QWidget *parent)
}
Browser::~Browser()
{
delete m_ui;
}
= default;
void Browser::exec()
{

View File

@ -7,6 +7,8 @@
#include <QWidget>
#include <QSqlTableModel>
#include <memory>
QT_FORWARD_DECLARE_CLASS(QSqlError)
QT_BEGIN_NAMESPACE
@ -20,8 +22,8 @@ class Browser : public QWidget
{
Q_OBJECT
public:
Browser(QWidget *parent = nullptr);
~Browser();
explicit Browser(QWidget *parent = nullptr);
~Browser() override;
QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
const QString &user, const QString &passwd, int port);
@ -50,7 +52,7 @@ signals:
void statusMessage(const QString &message);
private:
Ui::Browser *m_ui;
const std::unique_ptr<Ui::Browser> m_ui;
};
class CustomModel : public QSqlTableModel

View File

@ -14,6 +14,7 @@ ConnectionWidget::ConnectionWidget(QWidget *parent)
, tree(new QTreeWidget(this))
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins({});
tree->setHeaderLabels(QStringList(tr("Database")));
tree->header()->setStretchLastSection(true);
QAction *refreshAction = new QAction(tr("Refresh"), tree);
@ -33,9 +34,7 @@ ConnectionWidget::ConnectionWidget(QWidget *parent)
}
ConnectionWidget::~ConnectionWidget()
{
}
= default;
void ConnectionWidget::refresh()
{

View File

@ -14,8 +14,8 @@ class ConnectionWidget : public QWidget
{
Q_OBJECT
public:
ConnectionWidget(QWidget *parent = nullptr);
~ConnectionWidget();
explicit ConnectionWidget(QWidget *parent = nullptr);
~ConnectionWidget() override;
QSqlDatabase currentDatabase() const;

View File

@ -11,7 +11,7 @@
QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::QSqlConnectionDialogUi)
, m_ui{std::make_unique<Ui::QSqlConnectionDialogUi>()}
{
m_ui->setupUi(this);
@ -21,19 +21,10 @@ QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent)
m_ui->dbCheckBox->setEnabled(false);
m_ui->comboDriver->addItems(drivers);
connect(m_ui->okButton, &QPushButton::clicked,
this, &QSqlConnectionDialog::onOkButton);
connect(m_ui->cancelButton, &QPushButton::clicked,
this, &QSqlConnectionDialog::reject);
connect(m_ui->dbCheckBox, &QCheckBox::stateChanged,
this, &QSqlConnectionDialog::onDbCheckBox);
}
QSqlConnectionDialog::~QSqlConnectionDialog()
{
delete m_ui;
}
= default;
QString QSqlConnectionDialog::driverName() const
{
@ -70,18 +61,13 @@ bool QSqlConnectionDialog::useInMemoryDatabase() const
return m_ui->dbCheckBox->isChecked();
}
void QSqlConnectionDialog::onOkButton()
void QSqlConnectionDialog::accept()
{
if (m_ui->comboDriver->currentText().isEmpty()) {
QMessageBox::information(this, tr("No database driver selected"),
tr("Please select a database driver"));
m_ui->comboDriver->setFocus();
} else {
accept();
QDialog::accept();
}
}
void QSqlConnectionDialog::onDbCheckBox()
{
m_ui->connGroupBox->setEnabled(!m_ui->dbCheckBox->isChecked());
}

View File

@ -6,6 +6,8 @@
#include <QDialog>
#include <memory>
QT_BEGIN_NAMESPACE
namespace Ui
{
@ -17,8 +19,8 @@ class QSqlConnectionDialog : public QDialog
{
Q_OBJECT
public:
QSqlConnectionDialog(QWidget *parent = nullptr);
~QSqlConnectionDialog();
explicit QSqlConnectionDialog(QWidget *parent = nullptr);
~QSqlConnectionDialog() override;
QString driverName() const;
QString databaseName() const;
@ -28,12 +30,10 @@ public:
int port() const;
bool useInMemoryDatabase() const;
private slots:
void onOkButton();
void onDbCheckBox();
void accept() override;
private:
Ui::QSqlConnectionDialogUi *m_ui;
const std::unique_ptr<Ui::QSqlConnectionDialogUi> m_ui;
};
#endif

View File

@ -27,13 +27,7 @@
<property name="title" >
<string>Connection settings</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>8</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="1" >
<widget class="QComboBox" name="comboDriver" />
</item>
@ -163,47 +157,11 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -216,9 +174,56 @@
<tabstop>editHostname</tabstop>
<tabstop>portSpinBox</tabstop>
<tabstop>dbCheckBox</tabstop>
<tabstop>okButton</tabstop>
<tabstop>cancelButton</tabstop>
</tabstops>
<resources/>
<connections/>
<connections>
<connection>
<sender>dbCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>connGroupBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>165</x>
<y>248</y>
</hint>
<hint type="destinationlabel">
<x>107</x>
<y>221</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QSqlConnectionDialogUi</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>19</x>
<y>278</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>244</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QSqlConnectionDialogUi</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>58</x>
<y>276</y>
</hint>
<hint type="destinationlabel">
<x>58</x>
<y>258</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -106,11 +106,10 @@
system counterclockwise by a number of degrees determined by the current
hour and minute. This means that the hand will be shown rotated clockwise
by the required amount.
We save and restore the transformation matrix before and after the
rotation because we want to place the minute hand without having to
take into account any previous rotations.
We save and restore the transformation matrix before and after the rotation
by instantiating a QPainterStateGuard because we want to place the minute
hand without having to take into account any previous rotations.
\snippet widgets/analogclock/analogclock.cpp 17
\snippet widgets/analogclock/analogclock.cpp 19
We draw markers around the edge of the clock for each hour in the same
@ -123,7 +122,7 @@
\snippet widgets/analogclock/analogclock.cpp 21
For the seconds hand we do the same and add two cicles as a visual highlight.
For the seconds hand we do the same and add two circles as a visual highlight.
\snippet widgets/analogclock/analogclock.cpp 23
\codeline

View File

@ -370,8 +370,8 @@
RenderArea widget, and we calculate their positions using two \c
for loops and the widgets height and width.
For each copy we first save the current painter state (pushes the
state onto a stack). Then we translate the coordinate system,
For each copy we first save the current painter state by instantiating
a QPainterStateGuard. Then we translate the coordinate system,
using the QPainter::translate() function, to the position
determined by the variables of the \c for loops. If we omit this
translation of the coordinate system all the copies of the shape
@ -420,9 +420,9 @@
\snippet painting/basicdrawing/renderarea.cpp 13
Then, when we are finished rendering a copy of the shape we can
restore the original painter state, with its associated coordinate
system, using the QPainter::restore() function. In this way we
Then, when we are finished rendering a copy of the shape,
the original painter state is restored by QPainterStateGuard,
which calls the QPainter::restore() function. In this way, we
ensure that the next shape copy will be rendered in the correct
position.

View File

@ -161,13 +161,11 @@
\snippet painting/transformations/renderarea.cpp 6
Before we start to render the shape, we call the QPainter::save()
function.
QPainter::save() saves the current painter state (i.e. pushes the
state onto a stack) including the current coordinate system. The
rationale for saving the painter state is that the following call
to the \c transformPainter() function will transform the
Before we start to render the shape, we instantiate
a QPainterStateGuard to save the current painter state (i.e. push the
state onto a stack) including the current coordinate system while
in scope. The rationale for saving the painter state is that the
following call to the \c transformPainter() function will transform the
coordinate system depending on the currently chosen transformation
operations, and we need a way to get back to the original state to
draw the outline.

View File

@ -6,6 +6,7 @@
#include <QLayout>
#include <QPainter>
#include <QPainterStateGuard>
#include <QPainterPath>
const int alpha = 155;
@ -76,7 +77,7 @@ void XFormView::resizeEvent(QResizeEvent *e)
void XFormView::paint(QPainter *p)
{
p->save();
QPainterStateGuard guard(p);
p->setRenderHint(QPainter::Antialiasing);
p->setRenderHint(QPainter::SmoothPixmapTransform);
switch (m_type) {
@ -90,7 +91,6 @@ void XFormView::paint(QPainter *p)
drawTextType(p);
break;
}
p->restore();
}
void XFormView::updateControlPoints(const QPolygonF &points)

View File

@ -5,6 +5,7 @@
#include <QPainter>
#include <QPainterPath>
#include <QPainterStateGuard>
//! [0]
RenderArea::RenderArea(QWidget *parent)
@ -106,7 +107,7 @@ void RenderArea::paintEvent(QPaintEvent * /* event */)
//! [10]
for (int x = 0; x < width(); x += 100) {
for (int y = 0; y < height(); y += 100) {
painter.save();
QPainterStateGuard guard(&painter);
painter.translate(x, y);
//! [10] //! [11]
if (transformed) {
@ -161,7 +162,6 @@ void RenderArea::paintEvent(QPaintEvent * /* event */)
painter.drawPixmap(10, 10, pixmap);
}
//! [12] //! [13]
painter.restore();
}
}

View File

@ -4,6 +4,7 @@
#include "renderarea.h"
#include <QPainter>
#include <QPainterStateGuard>
#include <QPaintEvent>
//! [0]
@ -61,10 +62,11 @@ void RenderArea::paintEvent(QPaintEvent *event)
//! [5]
//! [6]
painter.save();
transformPainter(painter);
drawShape(painter);
painter.restore();
{
QPainterStateGuard guard(&painter);
transformPainter(painter);
drawShape(painter);
}
//! [6]
//! [7]

View File

@ -4,6 +4,7 @@
#include "analogclock.h"
#include <QPainter>
#include <QPainterStateGuard>
#include <QTime>
#include <QTimer>
@ -78,12 +79,12 @@ void AnalogClock::paintEvent(QPaintEvent *)
//! [16]
//! [18]
//! [17]
painter.save();
//! [17] //! [19]
painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
painter.drawConvexPolygon(hourHand, 4);
painter.restore();
//! [19]
{
QPainterStateGuard guard(&painter);
painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
painter.drawConvexPolygon(hourHand, 4);
}
//! [18] //! [19]
//! [20]
@ -97,10 +98,11 @@ void AnalogClock::paintEvent(QPaintEvent *)
painter.setBrush(minuteColor);
//! [22]
painter.save();
painter.rotate(6.0 * time.minute());
painter.drawConvexPolygon(minuteHand, 4);
painter.restore();
{
QPainterStateGuard guard(&painter);
painter.rotate(6.0 * time.minute());
painter.drawConvexPolygon(minuteHand, 4);
}
//! [21] //! [22]
@ -109,12 +111,13 @@ void AnalogClock::paintEvent(QPaintEvent *)
//! [23]
//! [24]
painter.save();
painter.rotate(6.0 * time.second());
painter.drawConvexPolygon(secondsHand, 4);
painter.drawEllipse(-3, -3, 6, 6);
painter.drawEllipse(-5, -68, 10, 10);
painter.restore();
{
QPainterStateGuard guard(&painter);
painter.rotate(6.0 * time.second());
painter.drawConvexPolygon(secondsHand, 4);
painter.drawEllipse(-3, -3, 6, 6);
painter.drawEllipse(-5, -68, 10, 10);
}
//! [24]
//! [25]

View File

@ -7,6 +7,7 @@
#include <QCoreApplication>
#include <QMouseEvent>
#include <QPainter>
#include <QPainterStateGuard>
#include <QTime>
#include <QTimer>
@ -93,10 +94,11 @@ void ShapedClock::paintEvent(QPaintEvent *)
painter.setPen(Qt::NoPen);
painter.setBrush(hourColor);
painter.save();
painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
painter.drawConvexPolygon(hourHand, 4);
painter.restore();
{
QPainterStateGuard guard(&painter);
painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
painter.drawConvexPolygon(hourHand, 4);
}
for (int i = 0; i < 12; ++i) {
painter.drawRect(73, -3, 16, 6);
@ -105,19 +107,21 @@ void ShapedClock::paintEvent(QPaintEvent *)
painter.setBrush(minuteColor);
painter.save();
painter.rotate(6.0 * time.minute());
painter.drawConvexPolygon(minuteHand, 4);
painter.restore();
{
QPainterStateGuard guard(&painter);
painter.rotate(6.0 * time.minute());
painter.drawConvexPolygon(minuteHand, 4);
}
painter.setBrush(secondsColor);
painter.save();
painter.rotate(6.0 * time.second());
painter.drawConvexPolygon(secondsHand, 4);
painter.drawEllipse(-3, -3, 6, 6);
painter.drawEllipse(-5, -68, 10, 10);
painter.restore();
{
QPainterStateGuard guard(&painter);
painter.rotate(6.0 * time.second());
painter.drawConvexPolygon(secondsHand, 4);
painter.drawEllipse(-3, -3, 6, 6);
painter.drawEllipse(-5, -68, 10, 10);
}
painter.setPen(minuteColor);

View File

@ -32,6 +32,11 @@
"file type" : "build system",
"spdx" : ["MIT AND BSD-3-Clause"]
},
"cmake/QtPublicSbomOpsHelpers.cmake" : {
"comment" : "MIT licensed copied parts",
"file type" : "build system",
"spdx" : ["MIT AND BSD-3-Clause"]
},
"tests/auto/cmake/test_plugin_shared_static_flavor\\.cmake" : {
"comment" : "Exception. This is a test file.",
"file type" : "test",

View File

@ -1,6 +1,6 @@
[
{
"Id": "D3D12MemoryAllocator",
"Id": "d3d12memoryallocator",
"Name": "D3D12 Memory Allocator",
"QDocModule": "qtgui",
"Description": "D3D12 Memory Allocator",
@ -8,7 +8,7 @@
"Homepage": "https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator",
"Version": "f128d39b7a95b4235bd228d231646278dc6c24b2",
"PURL": "pkg:github/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator@f128d39b7a95b4235bd228d231646278dc6c24b2",
"PURL": "pkg:github/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator@$<VERSION>",
"License": "MIT License",
"LicenseId": "MIT",
"LicenseFile": "LICENSE.txt",

View File

@ -1,6 +1,6 @@
[
{
"Id": "VulkanMemoryAllocator",
"Id": "vulkanmemoryallocator",
"Name": "Vulkan Memory Allocator",
"QDocModule": "qtgui",
"Description": "Vulkan Memory Allocator",
@ -8,7 +8,7 @@
"Homepage": "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
"Version": "3.1.0",
"PURL": "pkg:github/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator@v3.1.0",
"PURL": "pkg:github/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator@v$<VERSION>",
"License": "MIT License",
"LicenseId": "MIT",
"LicenseFile": "LICENSE.txt",

View File

@ -0,0 +1,67 @@
From eb08d0a94e6f64c2ba78536c00c654102ed5cc41 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Thu, 19 Dec 2024 14:02:08 -0300
Subject: mark the API static so it can't be exported
from QtCore
This affects static builds, where symbol visibility doesn't apply.
---
src/3rdparty/blake2/src/blake2.h | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/3rdparty/blake2/src/blake2.h b/src/3rdparty/blake2/src/blake2.h
index ca390305e60..0a90a9d2294 100644
--- a/src/3rdparty/blake2/src/blake2.h
+++ b/src/3rdparty/blake2/src/blake2.h
@@ -142,17 +142,17 @@ extern "C" {
};
/* Streaming API */
- int blake2s_init( blake2s_state *S, size_t outlen );
- int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen );
- int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
- int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
- int blake2s_final( blake2s_state *S, void *out, size_t outlen );
-
- int blake2b_init( blake2b_state *S, size_t outlen );
- int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
- int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
- int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
- int blake2b_final( blake2b_state *S, void *out, size_t outlen );
+ static int blake2s_init( blake2s_state *S, size_t outlen );
+ static int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen );
+ static int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
+ static int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
+ static int blake2s_final( blake2s_state *S, void *out, size_t outlen );
+
+ static int blake2b_init( blake2b_state *S, size_t outlen );
+ static int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
+ static int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
+ static int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
+ static int blake2b_final( blake2b_state *S, void *out, size_t outlen );
int blake2sp_init( blake2sp_state *S, size_t outlen );
int blake2sp_init_key( blake2sp_state *S, size_t outlen, const void *key, size_t keylen );
@@ -176,8 +176,8 @@ extern "C" {
int blake2xb_final(blake2xb_state *S, void *out, size_t outlen);
/* Simple API */
- int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
- int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
+ static int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
+ static int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
int blake2bp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
@@ -186,7 +186,7 @@ extern "C" {
int blake2xb( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
/* This is simply an alias for blake2b */
- int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
+ static int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
#if defined(__cplusplus)
}
--
2.47.1

View File

@ -1,7 +1,7 @@
version = 1
[[annotations]]
path = ["src/blake2b-ref.c", "src/blake2s-ref.c", "src/blake2.h", "src/blake2-impl.h"]
path = ["src/blake2b-ref.c", "src/blake2s-ref.c", "src/blake2.h", "src/blake2-impl.h", "0001-mark-the-API-static-so-it-cant-be-exported-from-QtCore.patch"]
comment = "Copyright line mixed with other text."
precedence = "override"
SPDX-FileCopyrightText = "Copyright 2012, Samuel Neves <sneves@dei.uc.pt>"

View File

@ -7,9 +7,9 @@
"Description": "BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and SHA-3, yet is at least as secure as the latest standard SHA-3.",
"Homepage": "https://blake2.net/",
"Version": "54f4faa4c16ea34bcd59d16e8da46a64b259fc07",
"DownloadLocation": "https://github.com/BLAKE2/BLAKE2/tree/54f4faa4c16ea34bcd59d16e8da46a64b259fc07",
"PURL": "pkg:github/BLAKE2/BLAKE2@54f4faa4c16ea34bcd59d16e8da46a64b259fc07",
"Version": "ed1974ea83433eba7b2d95c5dcd9ac33cb847913",
"DownloadLocation": "https://github.com/BLAKE2/BLAKE2/tree/ed1974ea83433eba7b2d95c5dcd9ac33cb847913",
"PURL": "pkg:github/BLAKE2/BLAKE2@$<VERSION>",
"CPE": "cpe:2.3:a:blake2:blake2:*:*:*:*:*:*:*:*",
"License": "Creative Commons Zero v1.0 Universal or Apache License 2.0",
"LicenseId": "CC0-1.0 OR Apache-2.0",

View File

@ -142,17 +142,17 @@ extern "C" {
};
/* Streaming API */
int blake2s_init( blake2s_state *S, size_t outlen );
int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen );
int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
int blake2s_final( blake2s_state *S, void *out, size_t outlen );
static int blake2s_init( blake2s_state *S, size_t outlen );
static int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen );
static int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
static int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
static int blake2s_final( blake2s_state *S, void *out, size_t outlen );
int blake2b_init( blake2b_state *S, size_t outlen );
int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
int blake2b_final( blake2b_state *S, void *out, size_t outlen );
static int blake2b_init( blake2b_state *S, size_t outlen );
static int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
static int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
static int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
static int blake2b_final( blake2b_state *S, void *out, size_t outlen );
int blake2sp_init( blake2sp_state *S, size_t outlen );
int blake2sp_init_key( blake2sp_state *S, size_t outlen, const void *key, size_t keylen );
@ -176,8 +176,8 @@ extern "C" {
int blake2xb_final(blake2xb_state *S, void *out, size_t outlen);
/* Simple API */
int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
static int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
static int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
int blake2bp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
@ -186,7 +186,7 @@ extern "C" {
int blake2xb( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
/* This is simply an alias for blake2b */
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
static int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
#if defined(__cplusplus)
}

View File

@ -7,8 +7,8 @@
"Homepage": "https://github.com/google/double-conversion",
"Version": "3.3.0",
"DownloadLocation": "https://github.com/google/double-conversion/releases/tag/v3.3.0",
"PURL": "pkg:github/google/double-conversion@v3.3.0",
"CPE": "cpe:2.3:a:google:double-conversion:3.3.0:*:*:*:*:*:*:*",
"PURL": "pkg:github/google/double-conversion@v$<VERSION>",
"CPE": "cpe:2.3:a:google:double-conversion:$<VERSION>:*:*:*:*:*:*:*",
"License": "BSD 3-clause \"New\" or \"Revised\" License",
"LicenseId": "BSD-3-Clause",
"LicenseFile": "LICENSE",

View File

@ -11,10 +11,10 @@
"Version": "2.13.3",
"DownloadLocation": "https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.gz",
"PURL": [
"pkg:github/freetype/freetype@VER-2-13-3"
"pkg:github/freetype/freetype@VER-$<VERSION_DASHED>"
],
"CPE": [
"cpe:2.3:a:freetype:freetype:2.13:3:*:*:*:*:*:*"
"cpe:2.3:a:freetype:freetype:$<VERSION>:*:*:*:*:*:*:*"
],
"License": "Freetype Project License or GNU General Public License v2.0 only",

View File

@ -6,8 +6,8 @@
"Homepage": "https://gradle.org",
"Version": "8.10",
"DownloadLocation": "https://github.com/gradle/gradle/releases/tag/v8.10.0",
"PURL": "pkg:github/gradle/gradle@v8.10.0",
"CPE": "cpe:2.3:a:gradle:gradle:8.10.0:*:*:*:*:*:*:*",
"PURL": "pkg:github/gradle/gradle@v$<VERSION>",
"CPE": "cpe:2.3:a:gradle:gradle:$<VERSION>:*:*:*:*:*:*:*",
"QtUsage": "Needed to create Android packages",
"License": "Apache License 2.0",
"LicenseId": "Apache-2.0",

View File

@ -9,8 +9,8 @@
"Homepage": "http://harfbuzz.org",
"Version": "10.1.0",
"DownloadLocation": "https://github.com/harfbuzz/harfbuzz/releases/tag/10.1.0",
"PURL": "pkg:github/harfbuzz/harfbuzz@10.1.0",
"CPE": "cpe:2.3:a:harfbuzz_project:harfbuzz:10.1.0:*:*:*:*:*:*:*",
"PURL": "pkg:github/harfbuzz/harfbuzz@$<VERSION>",
"CPE": "cpe:2.3:a:harfbuzz_project:harfbuzz:$<VERSION>:*:*:*:*:*:*:*",
"License": "MIT License",
"LicenseId": "MIT",
"LicenseFile": "COPYING",

View File

@ -1,6 +1,6 @@
[
{
"Id": "icc-sRGB-color-profile",
"Id": "icc-srgb-color-profile",
"Name": "sRGB color profile icc file",
"QDocModule": "qtgui",
"QtUsage": "Used in Qt Gui (Embedded into PDF/A-1b files generated by QPrinter/QPdfWriter).",

View File

@ -1,3 +1,122 @@
3.1.0
=====
### Significant changes relative to 3.1 beta1:
1. Fixed an issue in the TurboJPEG API whereby, when generating a
lossless JPEG image with more than 8 bits per sample, specifying a point
transform value greater than 7 resulted in an error ("Parameter value out of
range") unless `TJPARAM_PRECISION`/`TJ.PARAM_PRECISION` was specified before
`TJPARAM_LOSSLESSPT`/`TJ.PARAM_LOSSLESSPT`.
2. Fixed a regression introduced by 1.4 beta1[3] that prevented
`jpeg_set_defaults()` from resetting the Huffman tables to default (baseline)
values if Huffman table optimization or progressive mode was previously enabled
in the same libjpeg instance.
3. Fixed an issue whereby lossless JPEG compression could not be disabled if it
was previously enabled in a libjpeg or TurboJPEG instance.
`jpeg_set_defaults()` now disables lossless JPEG compression in a libjpeg
instance, and setting `TJPARAM_LOSSLESS`/`TJ.PARAM_LOSSLESS` to `0` now
disables lossless JPEG compression in a TurboJPEG instance.
3.1 beta1
=========
### Significant changes relative to 3.0.4:
1. The libjpeg-turbo source tree has been reorganized to make it easier to find
the README files, license information, and build instructions. The
documentation for the libjpeg API library and associated programs has been
moved into the **doc/** subdirectory, all C source code and headers have been
moved into a new **src/** subdirectory, and test scripts have been moved into a
new **test/** subdirectory.
2. cjpeg no longer allows GIF input files to be converted into
12-bit-per-sample JPEG files. That was never a useful feature, since GIF
images have at most 256 colors referenced from a palette of 8-bit-per-component
RGB values.
3. Added support for lossless JPEG images with 2 to 15 bits per sample to the
libjpeg and TurboJPEG APIs. When creating or decompressing a lossless JPEG
image and when loading or saving a PBMPLUS image, functions/methods specific to
8-bit samples now handle 8-bit samples with 2 to 8 bits of data precision
(specified using the `data_precision` field in `jpeg_compress_struct` or
`jpeg_decompress_struct` or using `TJPARAM_PRECISION`/`TJ.PARAM_PRECISION`),
functions/methods specific to 12-bit samples now handle 12-bit samples with 9
to 12 bits of data precision, and functions/methods specific to 16-bit samples
now handle 16-bit samples with 13 to 16 bits of data precision. Refer to
[libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and the TurboJPEG
API documentation for more details.
4. All deprecated constants and methods in the TurboJPEG Java API have been
removed.
5. TJBench command-line arguments are now more consistent with those of cjpeg,
djpeg, and jpegtran. More specifically:
- `-copynone` has been replaced with `-copy none`.
- `-fastdct` has been replaced with `-dct fast`.
- `-fastupsample` has been replaced with `-nosmooth`.
- `-hflip` and `-vflip` have been replaced with
`-flip {horizontal|vertical}`.
- `-limitscans` has been replaced with `-maxscans`, which allows the scan
limit to be specified.
- `-rgb`, `-bgr`, `-rgbx`, `-bgrx`, `-xbgr`, `-xrgb`, and `-cmyk` have
been replaced with `-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|cmyk}`.
- `-rot90`, `-rot180`, and `-rot270` have been replaced with
`-rotate {90|180|270}`.
- `-stoponwarning` has been replaced with `-strict`.
- British spellings for `gray` (`grey`) and `optimize` (`optimise`) are
now allowed.
The old command-line arguments are deprecated and will be removed in a
future release. TJBench command-line arguments can now be abbreviated as well.
(Where possible, the abbreviations are the same as those supported by cjpeg,
djpeg, and jpegtran.)
6. Added a new TJBench option (`-pixelformat gray`) that can be used to test
the performance of compressing/decompressing a grayscale JPEG image from/to a
packed-pixel grayscale image.
7. Fixed an issue whereby, if `TJPARAM_NOREALLOC` was set, TurboJPEG
compression and lossless transformation functions ignored the JPEG buffer
size(s) passed to them and assumed that the JPEG buffer(s) had been allocated
to a worst-case size returned by `tj3JPEGBufSize()`. This behavior was never
documented, although the documentation was unclear regarding whether the JPEG
buffer size should be specified if a JPEG buffer is pre-allocated to a
worst-case size.
8. The TurboJPEG C and Java APIs have been improved in the following ways:
- New image I/O methods (`TJCompressor.loadSourceImage()` and
`TJDecompressor.saveImage()`) have been added to the Java API. These methods
work similarly to the `tj3LoadImage*()` and `tj3SaveImage*()` functions in the
C API.
- The TurboJPEG lossless transformation function and methods now add
restart markers to all destination images if
`TJPARAM_RESTARTBLOCKS`/`TJ.PARAM_RESTARTBLOCKS` or
`TJPARAM_RESTARTROWS`/`TJ.PARAM_RESTARTROWS` is set.
- New functions/methods (`tj3SetICCProfile()` /
`TJCompressor.setICCProfile()` / `TJTransformer.setICCProfile()` and
`tj3GetICCProfile()` / `TJDecompressor.getICCProfile()`) can be used to embed
and retrieve ICC profiles.
- A new parameter (`TJPARAM_SAVEMARKERS`/`TJ.PARAM_SAVEMARKERS`) can be
used to specify the types of markers that will be copied from the source image
to the destination image during lossless transformation if
`TJXOPT_COPYNONE`/`TJTransform.OPT_COPYNONE` is not specified.
- A new convenience function/method (`tj3TransformBufSize()` /
`TJTransformer.bufSize()`) can be used to compute the worst-case destination
buffer size for a given lossless transform, taking into account cropping,
transposition of the width and height, grayscale conversion, and the embedded
or extracted ICC profile.
9. TJExample has been replaced with three programs (TJComp, TJDecomp, and
TJTran) that demonstrate how to approximate the functionality of cjpeg, djpeg,
and jpegtran using the TurboJPEG C and Java APIs.
3.0.4
=====
@ -51,7 +170,11 @@ cropping regions to be unduly rejected when performing 90-degree rotation,
270-degree rotation, transposition, transverse transposition, or grayscale
conversion.
8. Fixed an issue whereby the TurboJPEG lossless transformation function and
8. Fixed a regression, introduced by 3.0 beta2[4], that prevented the
`tjTransform()` backward compatibility function from copying extra markers from
the source image to the destination image.
9. Fixed an issue whereby the TurboJPEG lossless transformation function and
methods did not honor `TJXOPT_COPYNONE`/`TJTransform.OPT_COPYNONE` unless it
was specified for all lossless transforms.
@ -302,8 +425,8 @@ information.
`TJPARAM_LOSSLESSPT`/`TJ.PARAM_LOSSLESSPT`), and a cjpeg/TJBench option
(`-lossless`) can be used to create a lossless JPEG image. (Decompression of
lossless JPEG images is handled automatically.) Refer to
[libjpeg.txt](libjpeg.txt), [usage.txt](usage.txt), and the TurboJPEG API
documentation for more details.
[libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and the TurboJPEG
API documentation for more details.
6. Added support for 12-bit-per-component (lossy and lossless) and
16-bit-per-component (lossless) JPEG images to the libjpeg and TurboJPEG APIs:
@ -330,8 +453,8 @@ to create a 12-bit-per-component or 16-bit-per-component JPEG image.
(Decompression and transformation of 12-bit-per-component and
16-bit-per-component JPEG images is handled automatically.)
Refer to [libjpeg.txt](libjpeg.txt), [usage.txt](usage.txt), and the
TurboJPEG API documentation for more details.
Refer to [libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and
the TurboJPEG API documentation for more details.
2.1.5.1
@ -1392,7 +1515,7 @@ use of AltiVec instructions.
2. Added two new libjpeg API functions (`jpeg_skip_scanlines()` and
`jpeg_crop_scanline()`) that can be used to partially decode a JPEG image. See
[libjpeg.txt](libjpeg.txt) for more details.
[libjpeg.txt](doc/libjpeg.txt) for more details.
3. The TJCompressor and TJDecompressor classes in the TurboJPEG Java API now
implement the Closeable interface, so those classes can be used with a

View File

@ -94,7 +94,7 @@ intended solely for clarification.
The Modified (3-clause) BSD License
===================================
Copyright (C)2009-2023 D. R. Commander. All Rights Reserved.<br>
Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.<br>
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -36,16 +36,18 @@ TO DO Plans for future IJG releases.
Other documentation files in the distribution are:
User documentation:
usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
rdjpgcom, and wrjpgcom.
*.1 Unix-style man pages for programs (same info as usage.txt).
wizard.txt Advanced usage instructions for JPEG wizards only.
change.log Version-to-version change highlights.
doc/usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
rdjpgcom, and wrjpgcom.
doc/*.1 Unix-style man pages for programs (same info as
usage.txt).
doc/wizard.txt Advanced usage instructions for JPEG wizards only.
doc/change.log Version-to-version change highlights.
Programmer and internal documentation:
libjpeg.txt How to use the JPEG library in your own programs.
example.c Sample code for calling the JPEG library.
structure.txt Overview of the JPEG library's internal structure.
coderules.txt Coding style rules --- please read if you contribute code.
doc/libjpeg.txt How to use the JPEG library in your own programs.
src/example.c Sample code for calling the JPEG library.
doc/structure.txt Overview of the JPEG library's internal structure.
doc/coderules.txt Coding style rules --- please read if you contribute
code.
Please read at least usage.txt. Some information can also be found in the JPEG
FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find

View File

@ -69,8 +69,10 @@ JPEG images:
generating planar YUV images and performing multiple simultaneous lossless
transforms on an image. The Java interface for libjpeg-turbo is written on
top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
[TJExample.java](java/TJExample.java) for examples of its usage and to
users of libjpeg-turbo. Refer to [tjcomp.c](src/tjcomp.c),
[tjdecomp.c](src/tjdecomp.c), [tjtran.c](src/tjtran.c),
[TJComp.java](java/TJComp.java), [TJDecomp.java](java/TJDecomp.java), and
[TJTran.java](java/TJTran.java) for examples of its usage and to
<https://libjpeg-turbo.org/Documentation/Documentation> for API
documentation.
@ -80,8 +82,9 @@ JPEG images:
more powerful. The libjpeg API implementation in libjpeg-turbo is both
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
(see below.) Refer to [cjpeg.c](cjpeg.c) and [djpeg.c](djpeg.c) for examples
of its usage and to [libjpeg.txt](libjpeg.txt) for API documentation.
(see below.) Refer to [cjpeg.c](src/cjpeg.c) and [djpeg.c](src/djpeg.c) for
examples of its usage and to [libjpeg.txt](doc/libjpeg.txt) for API
documentation.
There is no significant performance advantage to either API when both are used
to perform similar operations.
@ -133,9 +136,9 @@ extensions at compile time with:
#ifdef JCS_ALPHA_EXTENSIONS
[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
how to check for the existence of the colorspace extensions at compile time and
run time.
[jcstest.c](src/jcstest.c), located in the libjpeg-turbo source tree,
demonstrates how to check for the existence of the colorspace extensions at
compile time and run time.
libjpeg v7 and v8 API/ABI Emulation
-----------------------------------

View File

@ -40,12 +40,11 @@ copy_file() {
}
copy_file "LICENSE.md" "LICENSE"
copy_file "ChangeLog.md" "ChangeLog.md"
copy_file "README.md" "README.md"
copy_file "README.ijg" "README.ijg"
FILES="
change.log
ChangeLog.md
README.md
README.ijg
jconfig.h.in
jconfigint.h.in
@ -136,9 +135,9 @@ FILES="
"
for i in $FILES; do
copy_file "$i" "src/$i"
copy_file "src/$i" "src/$i"
done
copy_file "jversion.h.in" "src/jversion.h"
copy_file "src/jversion.h.in" "src/jversion.h"
cyear=$(grep COPYRIGHT_YEAR $LIBJPEG_DIR/CMakeLists.txt | sed -e 's/.*"\(.*\)".*/\1/')
sed -i -e "s/@COPYRIGHT_YEAR@/$cyear/" $TARGET_DIR/src/jversion.h

View File

@ -7,10 +7,10 @@
"Description": "The Independent JPEG Group's JPEG software",
"Homepage": "http://libjpeg-turbo.virtualgl.org/",
"Version": "3.0.4",
"DownloadLocation": "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.0.4/libjpeg-turbo-3.0.4.tar.gz",
"PURL": "pkg:github/libjpeg-turbo/libjpeg-turbo@3.0.4",
"CPE": "cpe:2.3:a:libjpeg-turbo:libjpeg-turbo:3.0.4:*:*:*:*:*:*:*",
"Version": "3.1.0",
"DownloadLocation": "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.1.0/libjpeg-turbo-3.1.0.tar.gz",
"PURL": "pkg:github/libjpeg-turbo/libjpeg-turbo@$<VERSION>",
"CPE": "cpe:2.3:a:libjpeg-turbo:libjpeg-turbo:$<VERSION>:*:*:*:*:*:*:*",
"License": "Independent JPEG Group License and BSD 3-Clause \"New\" or \"Revised\" License",
"LicenseId": "IJG AND BSD-3-Clause",

View File

@ -5,7 +5,7 @@
* Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -194,19 +194,19 @@ jpeg_finish_compress(j_compress_ptr cinfo)
/* We bypass the main controller and invoke coef controller directly;
* all work is being done from the coefficient buffer.
*/
if (cinfo->data_precision == 16) {
if (cinfo->data_precision <= 8) {
if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
} else if (cinfo->data_precision <= 12) {
if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
} else {
#ifdef C_LOSSLESS_SUPPORTED
if (!(*cinfo->coef->compress_data_16) (cinfo, (J16SAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
} else if (cinfo->data_precision == 12) {
if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
} else {
if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
}
}
(*cinfo->master->finish_pass) (cinfo);

View File

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -88,8 +88,21 @@ _jpeg_write_scanlines(j_compress_ptr cinfo, _JSAMPARRAY scanlines,
#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
JDIMENSION row_ctr, rows_left;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
if (cinfo->global_state != CSTATE_SCANNING)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);

View File

@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2009-2012, 2015, 2022, D. R. Commander.
* Copyright (C) 2009-2012, 2015, 2022, 2024, D. R. Commander.
* Copyright (C) 2014, MIPS Technologies, Inc., California.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@ -552,8 +552,21 @@ _jinit_color_converter(j_compress_ptr cinfo)
{
my_cconvert_ptr cconvert;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@ -607,9 +620,11 @@ _jinit_color_converter(j_compress_ptr cinfo)
*/
switch (cinfo->jpeg_color_space) {
case JCS_GRAYSCALE:
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless &&
cinfo->in_color_space != cinfo->jpeg_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
if (cinfo->num_components != 1)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_GRAYSCALE)
@ -631,8 +646,10 @@ _jinit_color_converter(j_compress_ptr cinfo)
break;
case JCS_RGB:
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless && !IsExtRGB(cinfo->in_color_space))
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (rgb_red[cinfo->in_color_space] == 0 &&
@ -652,9 +669,11 @@ _jinit_color_converter(j_compress_ptr cinfo)
break;
case JCS_YCbCr:
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless &&
cinfo->in_color_space != cinfo->jpeg_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (IsExtRGB(cinfo->in_color_space)) {
@ -679,9 +698,11 @@ _jinit_color_converter(j_compress_ptr cinfo)
break;
case JCS_CMYK:
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless &&
cinfo->in_color_space != cinfo->jpeg_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK) {
@ -696,9 +717,11 @@ _jinit_color_converter(j_compress_ptr cinfo)
break;
case JCS_YCCK:
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless &&
cinfo->in_color_space != cinfo->jpeg_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK) {

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -346,6 +346,14 @@ _jinit_c_diff_controller(j_compress_ptr cinfo, boolean need_full_buffer)
int ci, row;
jpeg_component_info *compptr;
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
diff = (my_diff_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_diff_controller));

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2020, 2022, D. R. Commander.
* Copyright (C) 2020, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -40,7 +40,16 @@ jinit_compress_master(j_compress_ptr cinfo)
/* Preprocessing */
if (!cinfo->raw_data_in) {
if (cinfo->data_precision == 16) {
if (cinfo->data_precision <= 8) {
jinit_color_converter(cinfo);
jinit_downsampler(cinfo);
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
} else if (cinfo->data_precision <= 12) {
j12init_color_converter(cinfo);
j12init_downsampler(cinfo);
j12init_c_prep_controller(cinfo,
FALSE /* never need full buffer here */);
} else {
#ifdef C_LOSSLESS_SUPPORTED
j16init_color_converter(cinfo);
j16init_downsampler(cinfo);
@ -49,27 +58,18 @@ jinit_compress_master(j_compress_ptr cinfo)
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
} else if (cinfo->data_precision == 12) {
j12init_color_converter(cinfo);
j12init_downsampler(cinfo);
j12init_c_prep_controller(cinfo,
FALSE /* never need full buffer here */);
} else {
jinit_color_converter(cinfo);
jinit_downsampler(cinfo);
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
}
}
if (cinfo->master->lossless) {
#ifdef C_LOSSLESS_SUPPORTED
/* Prediction, sample differencing, and point transform */
if (cinfo->data_precision == 16)
j16init_lossless_compressor(cinfo);
else if (cinfo->data_precision == 12)
if (cinfo->data_precision <= 8)
jinit_lossless_compressor(cinfo);
else if (cinfo->data_precision <= 12)
j12init_lossless_compressor(cinfo);
else
jinit_lossless_compressor(cinfo);
j16init_lossless_compressor(cinfo);
/* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) {
ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
@ -78,26 +78,26 @@ jinit_compress_master(j_compress_ptr cinfo)
}
/* Need a full-image difference buffer in any multi-pass mode. */
if (cinfo->data_precision == 16)
j16init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
else if (cinfo->data_precision == 12)
if (cinfo->data_precision <= 8)
jinit_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
else if (cinfo->data_precision <= 12)
j12init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
else
jinit_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
j16init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else {
if (cinfo->data_precision == 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Forward DCT */
if (cinfo->data_precision == 12)
if (cinfo->data_precision == 8)
jinit_forward_dct(cinfo);
else if (cinfo->data_precision == 12)
j12init_forward_dct(cinfo);
else
jinit_forward_dct(cinfo);
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) {
#ifdef C_ARITH_CODING_SUPPORTED
@ -125,16 +125,16 @@ jinit_compress_master(j_compress_ptr cinfo)
cinfo->optimize_coding));
}
if (cinfo->data_precision == 16)
if (cinfo->data_precision <= 8)
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
else if (cinfo->data_precision <= 12)
j12init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
else
#ifdef C_LOSSLESS_SUPPORTED
j16init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
else if (cinfo->data_precision == 12)
j12init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
else
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
jinit_marker_writer(cinfo);

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -308,6 +308,14 @@ _jinit_lossless_compressor(j_compress_ptr cinfo)
{
lossless_comp_ptr losslessc;
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Create subobject in permanent pool */
losslessc = (lossless_comp_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -140,8 +140,21 @@ _jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
jpeg_component_info *compptr;
int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
main_ptr = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,

View File

@ -190,13 +190,19 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
if ((long)jd_samplesperrow != samplesperrow)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
/* Lossy JPEG images must have 8 or 12 bits per sample. Lossless JPEG images
* can have 2 to 16 bits per sample.
*/
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->data_precision != 8 && cinfo->data_precision != 12 &&
cinfo->data_precision != 16)
#else
if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
if (cinfo->master->lossless) {
if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
{
if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
/* Check that number of components won't exceed internal array sizes */
if (cinfo->num_components > MAX_COMPONENTS)
@ -731,6 +737,7 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
cinfo->num_scans = 1;
}
#ifdef C_LOSSLESS_SUPPORTED
/* Disable smoothing and subsampling in lossless mode, since those are lossy
* algorithms. Set the JPEG colorspace to the input colorspace. Disable raw
* (downsampled) data input, because it isn't particularly useful without
@ -747,6 +754,7 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
ci++, compptr++)
compptr->h_samp_factor = compptr->v_samp_factor = 1;
}
#endif
/* Validate parameters, determine derived values */
initial_setup(cinfo, transcode_only);

View File

@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, 2018, 2023, D. R. Commander.
* Copyright (C) 2009-2011, 2018, 2023-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -220,6 +220,9 @@ jpeg_set_defaults(j_compress_ptr cinfo)
cinfo->scan_info = NULL;
cinfo->num_scans = 0;
/* Default is lossy output */
cinfo->master->lossless = FALSE;
/* Expect normal source image, not raw downsampled data */
cinfo->raw_data_in = FALSE;
@ -297,9 +300,11 @@ jpeg_default_colorspace(j_compress_ptr cinfo)
case JCS_EXT_BGRA:
case JCS_EXT_ABGR:
case JCS_EXT_ARGB:
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless)
jpeg_set_colorspace(cinfo, JCS_RGB);
else
#endif
jpeg_set_colorspace(cinfo, JCS_YCbCr);
break;
case JCS_YCbCr:
@ -479,10 +484,12 @@ jpeg_simple_progression(j_compress_ptr cinfo)
if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
cinfo->master->lossless = FALSE;
jpeg_default_colorspace(cinfo);
}
#endif
/* Figure space needed for script. Calculation must match code below! */
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -324,8 +324,21 @@ _jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
jpeg_component_info *compptr;
int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
if (need_full_buffer) /* safety check */
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);

View File

@ -8,7 +8,7 @@
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2014, MIPS Technologies, Inc., California.
* Copyright (C) 2015, 2019, 2022, D. R. Commander.
* Copyright (C) 2015, 2019, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -470,8 +470,21 @@ _jinit_downsampler(j_compress_ptr cinfo)
jpeg_component_info *compptr;
boolean smoothok = TRUE;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef C_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
downsample = (my_downsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,

View File

@ -161,17 +161,21 @@ default_decompress_parms(j_decompress_ptr cinfo)
int cid2 = cinfo->comp_info[2].component_id;
if (cid0 == 1 && cid1 == 2 && cid2 == 3) {
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless)
cinfo->jpeg_color_space = JCS_RGB; /* assume RGB w/out marker */
else
#endif
cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
} else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
else {
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless)
cinfo->jpeg_color_space = JCS_RGB; /* assume it's RGB */
else
#endif
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
}
}

View File

@ -128,20 +128,19 @@ output_pass_setup(j_decompress_ptr cinfo)
}
/* Process some data */
last_scanline = cinfo->output_scanline;
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->data_precision == 16)
(*cinfo->main->process_data_16) (cinfo, (J16SAMPARRAY)NULL,
&cinfo->output_scanline,
(JDIMENSION)0);
else
#endif
if (cinfo->data_precision == 12)
if (cinfo->data_precision <= 8)
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
&cinfo->output_scanline, (JDIMENSION)0);
else if (cinfo->data_precision <= 12)
(*cinfo->main->process_data_12) (cinfo, (J12SAMPARRAY)NULL,
&cinfo->output_scanline,
(JDIMENSION)0);
#ifdef D_LOSSLESS_SUPPORTED
else
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
&cinfo->output_scanline, (JDIMENSION)0);
(*cinfo->main->process_data_16) (cinfo, (J16SAMPARRAY)NULL,
&cinfo->output_scanline,
(JDIMENSION)0);
#endif
if (cinfo->output_scanline == last_scanline)
return FALSE; /* No progress made, must suspend */
}
@ -314,8 +313,21 @@ _jpeg_read_scanlines(j_decompress_ptr cinfo, _JSAMPARRAY scanlines,
#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
JDIMENSION row_ctr;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
if (cinfo->global_state != DSTATE_SCANNING)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);

View File

@ -6,7 +6,7 @@
* Modified 2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2009, 2011-2012, 2014-2015, 2022, D. R. Commander.
* Copyright (C) 2009, 2011-2012, 2014-2015, 2022, 2024, D. R. Commander.
* Copyright (C) 2013, Linaro Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@ -759,8 +759,21 @@ _jinit_color_deconverter(j_decompress_ptr cinfo)
my_cconvert_ptr cconvert;
int ci;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@ -802,9 +815,11 @@ _jinit_color_deconverter(j_decompress_ptr cinfo)
switch (cinfo->out_color_space) {
case JCS_GRAYSCALE:
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless &&
cinfo->jpeg_color_space != cinfo->out_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
cinfo->out_color_components = 1;
if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
cinfo->jpeg_color_space == JCS_YCbCr) {
@ -830,8 +845,10 @@ _jinit_color_deconverter(j_decompress_ptr cinfo)
case JCS_EXT_BGRA:
case JCS_EXT_ABGR:
case JCS_EXT_ARGB:
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless && cinfo->jpeg_color_space != JCS_RGB)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
if (cinfo->jpeg_color_space == JCS_YCbCr) {
#ifdef WITH_SIMD
@ -858,8 +875,10 @@ _jinit_color_deconverter(j_decompress_ptr cinfo)
break;
case JCS_RGB565:
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
cinfo->out_color_components = 3;
if (cinfo->dither_mode == JDITHER_NONE) {
if (cinfo->jpeg_color_space == JCS_YCbCr) {
@ -893,9 +912,11 @@ _jinit_color_deconverter(j_decompress_ptr cinfo)
break;
case JCS_CMYK:
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless &&
cinfo->jpeg_color_space != cinfo->out_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
#endif
cinfo->out_color_components = 4;
if (cinfo->jpeg_color_space == JCS_YCCK) {
cconvert->pub._color_convert = ycck_cmyk_convert;

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -350,6 +350,14 @@ _jinit_d_diff_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
int ci;
jpeg_component_info *compptr;
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
diff = (my_diff_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_diff_controller));

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
* Copyright (C) 2010, 2016, 2018, 2022, 2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@ -56,14 +56,19 @@ initial_setup(j_decompress_ptr cinfo)
(long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
/* For now, precision must match compiled-in value... */
/* Lossy JPEG images must have 8 or 12 bits per sample. Lossless JPEG images
* can have 2 to 16 bits per sample.
*/
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->data_precision != 8 && cinfo->data_precision != 12 &&
cinfo->data_precision != 16)
#else
if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
if (cinfo->master->lossless) {
if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
{
if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
/* Check that number of components won't exceed internal array sizes */
if (cinfo->num_components > MAX_COMPONENTS)

View File

@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, D. R. Commander.
* Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -278,6 +278,14 @@ _jinit_lossless_decompressor(j_decompress_ptr cinfo)
{
lossless_decomp_ptr losslessd;
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Create subobject in permanent pool */
losslessd = (lossless_decomp_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,

View File

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2016, 2022, D. R. Commander.
* Copyright (C) 2010, 2016, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -431,8 +431,21 @@ _jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
int ci, rgroup, ngroups;
jpeg_component_info *compptr;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
main_ptr = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,

View File

@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, 2016, 2019, 2022-2023, D. R. Commander.
* Copyright (C) 2009-2011, 2016, 2019, 2022-2024, D. R. Commander.
* Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
@ -422,7 +422,50 @@ prepare_range_limit_table(j_decompress_ptr cinfo)
#endif
int i;
if (cinfo->data_precision == 16) {
if (cinfo->data_precision <= 8) {
table = (JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
cinfo->sample_range_limit = table;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
/* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE)i;
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
/* End of simple table, rest of first half of post-IDCT table */
for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
table[i] = MAXJSAMPLE;
/* Second half of post-IDCT table */
memset(table + (2 * (MAXJSAMPLE + 1)), 0,
(2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
} else if (cinfo->data_precision <= 12) {
table12 = (J12SAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
sizeof(J12SAMPLE));
table12 += (MAXJ12SAMPLE + 1); /* allow negative subscripts of simple
table */
cinfo->sample_range_limit = (JSAMPLE *)table12;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
memset(table12 - (MAXJ12SAMPLE + 1), 0,
(MAXJ12SAMPLE + 1) * sizeof(J12SAMPLE));
/* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJ12SAMPLE; i++)
table12[i] = (J12SAMPLE)i;
table12 += CENTERJ12SAMPLE; /* Point to where post-IDCT table starts */
/* End of simple table, rest of first half of post-IDCT table */
for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
table12[i] = MAXJ12SAMPLE;
/* Second half of post-IDCT table */
memset(table12 + (2 * (MAXJ12SAMPLE + 1)), 0,
(2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
} else {
#ifdef D_LOSSLESS_SUPPORTED
table16 = (J16SAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@ -449,49 +492,6 @@ prepare_range_limit_table(j_decompress_ptr cinfo)
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
} else if (cinfo->data_precision == 12) {
table12 = (J12SAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
sizeof(J12SAMPLE));
table12 += (MAXJ12SAMPLE + 1); /* allow negative subscripts of simple
table */
cinfo->sample_range_limit = (JSAMPLE *)table12;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
memset(table12 - (MAXJ12SAMPLE + 1), 0,
(MAXJ12SAMPLE + 1) * sizeof(J12SAMPLE));
/* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJ12SAMPLE; i++)
table12[i] = (J12SAMPLE)i;
table12 += CENTERJ12SAMPLE; /* Point to where post-IDCT table starts */
/* End of simple table, rest of first half of post-IDCT table */
for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
table12[i] = MAXJ12SAMPLE;
/* Second half of post-IDCT table */
memset(table12 + (2 * (MAXJ12SAMPLE + 1)), 0,
(2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
} else {
table = (JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
cinfo->sample_range_limit = table;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
/* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE)i;
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
/* End of simple table, rest of first half of post-IDCT table */
for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
table[i] = MAXJSAMPLE;
/* Second half of post-IDCT table */
memset(table + (2 * (MAXJSAMPLE + 1)), 0,
(2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
}
}
@ -521,10 +521,12 @@ master_selection(j_decompress_ptr cinfo)
* particularly useful without subsampling and has not been tested in
* lossless mode.
*/
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
cinfo->raw_data_out = FALSE;
cinfo->scale_num = cinfo->scale_denom = 1;
}
#endif
/* Initialize dimensions and other stuff */
jpeg_calc_output_dimensions(cinfo);
@ -570,12 +572,12 @@ master_selection(j_decompress_ptr cinfo)
if (cinfo->enable_1pass_quant) {
#ifdef QUANT_1PASS_SUPPORTED
if (cinfo->data_precision == 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
if (cinfo->data_precision == 8)
jinit_1pass_quantizer(cinfo);
else if (cinfo->data_precision == 12)
j12init_1pass_quantizer(cinfo);
else
jinit_1pass_quantizer(cinfo);
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
master->quantizer_1pass = cinfo->cquantize;
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
@ -585,12 +587,12 @@ master_selection(j_decompress_ptr cinfo)
/* We use the 2-pass code to map to external colormaps. */
if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
#ifdef QUANT_2PASS_SUPPORTED
if (cinfo->data_precision == 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
if (cinfo->data_precision == 8)
jinit_2pass_quantizer(cinfo);
else if (cinfo->data_precision == 12)
j12init_2pass_quantizer(cinfo);
else
jinit_2pass_quantizer(cinfo);
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
master->quantizer_2pass = cinfo->cquantize;
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
@ -605,41 +607,41 @@ master_selection(j_decompress_ptr cinfo)
if (!cinfo->raw_data_out) {
if (master->using_merged_upsample) {
#ifdef UPSAMPLE_MERGING_SUPPORTED
if (cinfo->data_precision == 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
if (cinfo->data_precision == 8)
jinit_merged_upsampler(cinfo); /* does color conversion too */
else if (cinfo->data_precision == 12)
j12init_merged_upsampler(cinfo); /* does color conversion too */
else
jinit_merged_upsampler(cinfo); /* does color conversion too */
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else {
if (cinfo->data_precision == 16) {
if (cinfo->data_precision <= 8) {
jinit_color_deconverter(cinfo);
jinit_upsampler(cinfo);
} else if (cinfo->data_precision <= 12) {
j12init_color_deconverter(cinfo);
j12init_upsampler(cinfo);
} else {
#ifdef D_LOSSLESS_SUPPORTED
j16init_color_deconverter(cinfo);
j16init_upsampler(cinfo);
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
} else if (cinfo->data_precision == 12) {
j12init_color_deconverter(cinfo);
j12init_upsampler(cinfo);
} else {
jinit_color_deconverter(cinfo);
jinit_upsampler(cinfo);
}
}
if (cinfo->data_precision == 16)
if (cinfo->data_precision <= 8)
jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
else if (cinfo->data_precision <= 12)
j12init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
else
#ifdef D_LOSSLESS_SUPPORTED
j16init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
else if (cinfo->data_precision == 12)
j12init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
else
jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
}
if (cinfo->master->lossless) {
@ -647,12 +649,12 @@ master_selection(j_decompress_ptr cinfo)
/* Prediction, sample undifferencing, point transform, and sample size
* scaling
*/
if (cinfo->data_precision == 16)
j16init_lossless_decompressor(cinfo);
else if (cinfo->data_precision == 12)
if (cinfo->data_precision <= 8)
jinit_lossless_decompressor(cinfo);
else if (cinfo->data_precision <= 12)
j12init_lossless_decompressor(cinfo);
else
jinit_lossless_decompressor(cinfo);
j16init_lossless_decompressor(cinfo);
/* Entropy decoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) {
ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
@ -663,23 +665,23 @@ master_selection(j_decompress_ptr cinfo)
/* Initialize principal buffer controllers. */
use_c_buffer = cinfo->inputctl->has_multiple_scans ||
cinfo->buffered_image;
if (cinfo->data_precision == 16)
j16init_d_diff_controller(cinfo, use_c_buffer);
else if (cinfo->data_precision == 12)
if (cinfo->data_precision <= 8)
jinit_d_diff_controller(cinfo, use_c_buffer);
else if (cinfo->data_precision <= 12)
j12init_d_diff_controller(cinfo, use_c_buffer);
else
jinit_d_diff_controller(cinfo, use_c_buffer);
j16init_d_diff_controller(cinfo, use_c_buffer);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else {
if (cinfo->data_precision == 16)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Inverse DCT */
if (cinfo->data_precision == 12)
if (cinfo->data_precision == 8)
jinit_inverse_dct(cinfo);
else if (cinfo->data_precision == 12)
j12init_inverse_dct(cinfo);
else
jinit_inverse_dct(cinfo);
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Entropy decoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) {
#ifdef D_ARITH_CODING_SUPPORTED
@ -708,18 +710,18 @@ master_selection(j_decompress_ptr cinfo)
}
if (!cinfo->raw_data_out) {
if (cinfo->data_precision == 16)
if (cinfo->data_precision <= 8)
jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
else if (cinfo->data_precision <= 12)
j12init_d_main_controller(cinfo,
FALSE /* never need full buffer here */);
else
#ifdef D_LOSSLESS_SUPPORTED
j16init_d_main_controller(cinfo,
FALSE /* never need full buffer here */);
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#endif
else if (cinfo->data_precision == 12)
j12init_d_main_controller(cinfo,
FALSE /* never need full buffer here */);
else
jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
}
/* We can now tell the memory manager to allocate virtual arrays. */

View File

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2022-2023, D. R. Commander.
* Copyright (C) 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -267,8 +267,21 @@ _jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
{
my_post_ptr post;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
post = (my_post_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,

View File

@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2010, 2015-2016, 2022, D. R. Commander.
* Copyright (C) 2010, 2015-2016, 2022, 2024, D. R. Commander.
* Copyright (C) 2014, MIPS Technologies, Inc., California.
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2019-2020, Arm Limited.
@ -421,8 +421,21 @@ _jinit_upsampler(j_decompress_ptr cinfo)
boolean need_buffer, do_fancy;
int h_in_group, v_in_group, h_out_group, v_out_group;
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
#ifdef D_LOSSLESS_SUPPORTED
if (cinfo->master->lossless) {
#if BITS_IN_JSAMPLE == 8
if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
#else
if (cinfo->data_precision > BITS_IN_JSAMPLE ||
cinfo->data_precision < BITS_IN_JSAMPLE - 3)
#endif
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
} else
#endif
{
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
}
if (!cinfo->master->jinit_upsampler_no_alloc) {
upsample = (my_upsample_ptr)

View File

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2016, 2021-2022, D. R. Commander.
* Copyright (C) 2016, 2021-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -156,8 +156,9 @@ typedef my_memory_mgr *my_mem_ptr;
struct jvirt_sarray_control {
JSAMPARRAY mem_buffer; /* => the in-memory buffer (if
cinfo->data_precision is 12, then this is
actually a J12SAMPARRAY) */
cinfo->data_precision > 8, then this is
actually a J12SAMPARRAY or a
J16SAMPARRAY) */
JDIMENSION rows_in_array; /* total virtual array height */
JDIMENSION samplesperrow; /* width of array (and of memory buffer) */
JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */
@ -449,8 +450,8 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 16 ?
sizeof(J16SAMPLE) : (data_precision == 12 ?
size_t sample_size = data_precision > 12 ?
sizeof(J16SAMPLE) : (data_precision > 8 ?
sizeof(J12SAMPLE) :
sizeof(JSAMPLE));
@ -477,7 +478,44 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
rowsperchunk = numrows;
mem->last_rowsperchunk = rowsperchunk;
if (data_precision == 16) {
if (data_precision <= 8) {
/* Get space for row pointers (small object) */
result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
(size_t)(numrows * sizeof(JSAMPROW)));
/* Get the rows themselves (large objects) */
currow = 0;
while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace;
workspace += samplesperrow;
}
}
return result;
} else if (data_precision <= 12) {
/* Get space for row pointers (small object) */
result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
(size_t)(numrows *
sizeof(J12SAMPROW)));
/* Get the rows themselves (large objects) */
currow = 0;
while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace12 = (J12SAMPROW)alloc_large(cinfo, pool_id,
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
for (i = rowsperchunk; i > 0; i--) {
result12[currow++] = workspace12;
workspace12 += samplesperrow;
}
}
return (JSAMPARRAY)result12;
} else {
#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
/* Get space for row pointers (small object) */
result16 = (J16SAMPARRAY)alloc_small(cinfo, pool_id,
@ -501,43 +539,6 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
ERREXIT1(cinfo, JERR_BAD_PRECISION, data_precision);
return NULL;
#endif
} else if (data_precision == 12) {
/* Get space for row pointers (small object) */
result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
(size_t)(numrows *
sizeof(J12SAMPROW)));
/* Get the rows themselves (large objects) */
currow = 0;
while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace12 = (J12SAMPROW)alloc_large(cinfo, pool_id,
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
for (i = rowsperchunk; i > 0; i--) {
result12[currow++] = workspace12;
workspace12 += samplesperrow;
}
}
return (JSAMPARRAY)result12;
} else {
/* Get space for row pointers (small object) */
result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
(size_t)(numrows * sizeof(JSAMPROW)));
/* Get the rows themselves (large objects) */
currow = 0;
while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace;
workspace += samplesperrow;
}
}
return result;
}
}
@ -703,8 +704,8 @@ realize_virt_arrays(j_common_ptr cinfo)
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 16 ?
sizeof(J16SAMPLE) : (data_precision == 12 ?
size_t sample_size = data_precision > 12 ?
sizeof(J16SAMPLE) : (data_precision > 8 ?
sizeof(J12SAMPLE) :
sizeof(JSAMPLE));
@ -821,8 +822,8 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 16 ?
sizeof(J16SAMPLE) : (data_precision == 12 ?
size_t sample_size = data_precision > 12 ?
sizeof(J16SAMPLE) : (data_precision > 8 ?
sizeof(J12SAMPLE) :
sizeof(JSAMPLE));
@ -840,7 +841,27 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
if (rows <= 0) /* this chunk might be past end of file! */
break;
byte_count = rows * bytesperrow;
if (data_precision == 16) {
if (data_precision <= 8) {
if (writing)
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
(void *)ptr->mem_buffer[i],
file_offset, byte_count);
else
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
(void *)ptr->mem_buffer[i],
file_offset, byte_count);
} else if (data_precision <= 12) {
J12SAMPARRAY mem_buffer12 = (J12SAMPARRAY)ptr->mem_buffer;
if (writing)
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
(void *)mem_buffer12[i],
file_offset, byte_count);
else
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
(void *)mem_buffer12[i],
file_offset, byte_count);
} else {
#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
J16SAMPARRAY mem_buffer16 = (J16SAMPARRAY)ptr->mem_buffer;
@ -855,26 +876,6 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
#else
ERREXIT1(cinfo, JERR_BAD_PRECISION, data_precision);
#endif
} else if (data_precision == 12) {
J12SAMPARRAY mem_buffer12 = (J12SAMPARRAY)ptr->mem_buffer;
if (writing)
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
(void *)mem_buffer12[i],
file_offset, byte_count);
else
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
(void *)mem_buffer12[i],
file_offset, byte_count);
} else {
if (writing)
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
(void *)ptr->mem_buffer[i],
file_offset, byte_count);
else
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
(void *)ptr->mem_buffer[i],
file_offset, byte_count);
}
file_offset += byte_count;
}
@ -926,8 +927,8 @@ access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 16 ?
sizeof(J16SAMPLE) : (data_precision == 12 ?
size_t sample_size = data_precision > 12 ?
sizeof(J16SAMPLE) : (data_precision > 8 ?
sizeof(J12SAMPLE) :
sizeof(JSAMPLE));

View File

@ -86,22 +86,26 @@ extern "C" {
/* Data structures for images (arrays of samples and of DCT coefficients).
*/
typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples with
2-bit through 8-bit data precision. */
typedef JSAMPROW *JSAMPARRAY; /* ptr to some JSAMPLE rows (a 2-D JSAMPLE
array) */
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D JSAMPLE array: top index is color */
typedef J12SAMPLE *J12SAMPROW; /* ptr to one image row of 12-bit pixel
samples. */
typedef J12SAMPROW *J12SAMPARRAY; /* ptr to some 12-bit sample rows (a 2-D
12-bit sample array) */
typedef J12SAMPARRAY *J12SAMPIMAGE; /* a 3-D 12-bit sample array: top index is
typedef J12SAMPLE *J12SAMPROW; /* ptr to one image row of pixel samples
with 9-bit through 12-bit data
precision. */
typedef J12SAMPROW *J12SAMPARRAY; /* ptr to some J12SAMPLE rows (a 2-D
J12SAMPLE array) */
typedef J12SAMPARRAY *J12SAMPIMAGE; /* a 3-D J12SAMPLE array: top index is
color */
typedef J16SAMPLE *J16SAMPROW; /* ptr to one image row of 16-bit pixel
samples. */
typedef J16SAMPROW *J16SAMPARRAY; /* ptr to some 16-bit sample rows (a 2-D
16-bit sample array) */
typedef J16SAMPARRAY *J16SAMPIMAGE; /* a 3-D 16-bit sample array: top index is
typedef J16SAMPLE *J16SAMPROW; /* ptr to one image row of pixel samples
with 13-bit through 16-bit data
precision. */
typedef J16SAMPROW *J16SAMPARRAY; /* ptr to some J16SAMPLE rows (a 2-D
J16SAMPLE array) */
typedef J16SAMPARRAY *J16SAMPIMAGE; /* a 3-D J16SAMPLE array: top index is
color */
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
@ -708,11 +712,12 @@ struct jpeg_decompress_struct {
*/
JSAMPLE *sample_range_limit; /* table for fast range-limiting
If data_precision is 12 or 16, then this is
actually a J12SAMPLE pointer or a J16SAMPLE
pointer, so callers must type-cast it in
order to read 12-bit or 16-bit samples from
the array. */
If data_precision is 9 to 12, then this is
actually a J12SAMPLE pointer, and if
data_precision is 13 to 16, then this is
actually a J16SAMPLE pointer, so callers
must type-cast it in order to read samples
from the array. */
/*
* These fields are valid during any one scan.

View File

@ -93,7 +93,6 @@
/* Image I/O functions (cdjpeg.h) */
#ifdef C_LOSSLESS_SUPPORTED
#define _jinit_read_gif j16init_read_gif
#define _jinit_read_ppm j16init_read_ppm
#endif
@ -209,7 +208,6 @@
#define _buffer buffer12
/* Image I/O functions (cdjpeg.h) */
#define _jinit_read_gif j12init_read_gif
#define _jinit_write_gif j12init_write_gif
#define _jinit_read_ppm j12init_read_ppm
#define _jinit_write_ppm j12init_write_ppm
@ -324,7 +322,6 @@
#define _buffer buffer
/* Image I/O functions (cdjpeg.h) */
#define _jinit_read_gif jinit_read_gif
#define _jinit_write_gif jinit_write_gif
#define _jinit_read_ppm jinit_read_ppm
#define _jinit_write_ppm jinit_write_ppm

View File

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2013, 2022, D. R. Commander.
* Copyright (C) 2013, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@ -25,7 +25,7 @@ add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table(cinfo);
else
else if (cinfo->is_decompressor)
return;
/* Copy the number-of-symbols-of-each-code-length counts */

Some files were not shown because too many files have changed in this diff Show More