summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
Commit message (Collapse)AuthorAgeFilesLines
* QFactoryLoader: reserve() two QListsMarc Mutz2025-06-271-0/+2
| | | | | | | | | | Either of them may see additional append()s after the first loop, but we can at least skip the first few reallocations by reserving d->library.size(). Pick-to: 6.10 6.9 Change-Id: I1c2ccdc47444657957dd593a76d75fe210536b5b Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: drop libraries mutex soonerMarc Mutz2025-06-271-0/+2
| | | | | | | | | | | | | | | | | | | | | Both QFactoryLoader::metaDataKeys() and QFactoryLoader::metaData() locked the mutex under QT_CONFIG(library) near the start of the function and never dropped it until the end of the function. This is not necessary and, by Amdahl's Law, reduces concurrency. Drop the mutex before the #endif again. This isn't as good as splitting the metaDataKeys() loop into one that extracts the QPluginParsedMetaDatas, dropping the mutex, and then another doing the JSON work, but it's better than the status quo and the best the maintainer will accept. Amends 878e3342e1c9bd8a4da6a2e9e1508dacbe0c7ab6. Pick-to: 6.10 6.9 Change-Id: Ie69d4a2d20ac02c4331ffcc3f1281caf7cbeb6fe Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: don't use std::vector::at()Marc Mutz2025-06-271-2/+2
| | | | | | | | | | | | | Unlike the Qt containers, STL container at() is checked, and throws an exception. Use op[], which is unchecked, and allows checkers like Coverity and UBSan to detect the issue, because UB always means it's unintentional. Amends e60aed5ed000b635d8424f9120249725d9e68c78. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Icec96bc3939a80c1845f4335c93d3c920627ac0e Reviewed-by: Thiago Macieira <[email protected]>
* Mark qtbase/src/corelib/plugin files as security-criticalMagdalena Stojek2025-06-049-0/+10
| | | | | | | | | | | | | | | - quuid.cpp parses the string representation of a UUID - qfactoryloader.cpp parses metadata from loaded plugin - qcoffpeparser.cpp, qelfparser_p.cpp and qmachparser.cpp as they are binary object files parsers - qlibrary.cpp, qlibrary_unix.cpp, qlibrary_win.cpp, qpluginloader.cpp are responsible for finding and loading plugins from untrusted locations. Fixes: QTBUG-135193 Change-Id: Ibbcefeab80e7455225ade620bdba45dbc592c581 Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Matthias Rauter <[email protected]>
* QLibrary/Darwin: don't use RTLD_NODELETE, just don't dlclose()Thiago Macieira2025-05-253-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As the comment says, the OS does support the flag and a perusal of the source code for dyld[1] shows it does handle the flag, setting an internal flag called "leaveMapped", which is different from the "neverUnload" flag. My guess is that it literally just leaves the memory for the plugin mapped, but removes all links to it in the dyld internal data structures. That results in the Objective C runtime crashing when running content from NODELETE plugins that has been dlclose()d. This probably explains why lldb stops seeing those symbols too: (lldb) f frame #0: 0x0000000103872eb4 QtCore`QLibraryPrivate::unload_sys(this=0x000060000179c210) at qlibrary_unix.cpp:258:21 -> 258 if (doTryUnload && dlclose(pHnd.loadAcquire())) { (lldb) target modules list libqcocoa.dylib [ 0] 81EB58D5-8D31-333A-9E8C-F2385F6EFCF4 0x00000001043de000 libqcocoa.dylib (lldb) image lookup -vn QCocoaEventDispatcher::QCocoaEventDispatcher 2 matches found in libqcocoa.dylib: Address: libqcocoa.dylib[0x0000000000036480] (libqcocoa.dylib.__TEXT.__text + 190368) Summary: libqcocoa.dylib`QCocoaEventDispatcher::QCocoaEventDispatcher(QObject*) at qcocoaeventdispatcher.mm:776 ... (lldb) n (lldb) target modules list libqcocoa.dylib [ 0] 81EB58D5-8D31-333A-9E8C-F2385F6EFCF4 libqcocoa.dylib[0x0000000000000000] libqcocoa.dylib (lldb) image lookup -vn QCocoaEventDispatcher::QCocoaEventDispatcher [1] https://github.com/apple-oss-distributions/dyld Task-number: QTBUG-135044 Task-number: QTBUG-134080 Task-number: QTBUG-133861 Task-number: QTBUG-132697 Task-number: QTBUG-102984 Task-number: QTBUG-132381 Pick-to: 6.9 6.9.0 6.8 Change-Id: I7da3b3615a6ace7c72d1fffd5cf560d8f8a4e1bb Reviewed-by: Tor Arne Vestbø <[email protected]>
* QFactoryLoader: embed the Private class into the front-endThiago Macieira2025-03-242-41/+26
| | | | | | | | | | | Simplifies the code and avoids unnecessary indirections. It's done in a quirky way with a d member with operator->() to mostly preserve Git history. Change-Id: I0989ef9b4cd7a620c891fffdb521d4280896d275 Reviewed-by: Tor Arne Vestbø <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: remove dependency on QObjectThiago Macieira2025-03-242-26/+7
| | | | | | | | | This class doesn't have signals or slots, so it doesn't need to depend on QObject. Change-Id: Ie4d7f47c659f4319abb6fffd181973fbb3a91ff3 Reviewed-by: Tor Arne Vestbø <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: do destroy the staticplugin instances tooThiago Macieira2025-03-241-2/+13
| | | | | | | | | | The previous commit ensured we did delete the instances of regular, dynamic plugins when this QFactoryLoader went out of scope. This commit repeats the same technique for the staticplugins. Change-Id: Ic9ff94cf7a6de95c63fbfffd30b8a418c211e824 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
* QFactoryLoader: unload the plugins we loadedThiago Macieira2025-03-241-0/+23
| | | | | | | | | | | | | | | | | We just left everything for QLibraryStore::cleanup() to do when that ran at QtCore unload time. Which is certainly weird because that meant no other library could be unloaded if it was a dependency of a plugin we'd loaded. Now, this should allow the libraries to start unloading before QtCore, when the Q_GLOBAL_STATICs holding the QFactoryLoaders get destroyed by ::exit(). This also explicitly deletes the instances in each of those dynamic plugins, otherwise they may remain around and cause crashes later. This is not done for instances coming from staticplugins - see next commit. Change-Id: I752d41069e192c7be4a0fffd5ab0a253108b0b0c Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
* QFactoryLoader: also move staticplugin instances to the main threadThiago Macieira2025-03-242-9/+17
| | | | | | | | | | | | | We already move the instances coming from dynamic plugins, but for some reason we don't for the ones coming from staticplugins. There's no hint about it in the history; my guess is it was simply forgotten when the staticplugins were added. This necessitated extending the mutex lock over the staticplugin list scan so we'd reach the QObject::moveToThread() call too. Change-Id: Ibe0107a9daf46792b09efffd9a7d9c45214aa589 Reviewed-by: Tor Arne Vestbø <[email protected]>
* QUuid: fix qHash() on 64-bit platformsMarc Mutz2025-03-191-4/+3
| | | | | | | | | | | | | | | | | | | | | The old implementation from Qt 5 time only affected the 32 LSB of the result. The upper bits were completely determined by the seed, and the seed alone. To see this, note that all except the seed are at most 32-bit values, and no shifting out of that range occurs, either. Fix by just using qHashBits(), making sure (with a static_assert()) that QUuid has unique object representation (= can be compared for equality using memcmp()). [ChangeLog][QtCore][QUuid] Improved the performance of the qHash() function on 64-bit platforms by populating all bits of the output (was: only lower 32 bits). Amends 55d68a16aafb93aa15bcdbd78892006777b6067a. Pick-to: 6.9 6.8 6.5 Change-Id: Ibf67350f571889fd21e0acc82639c053c0d606b6 Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: move QPluginParsedMetaData to qplugin_p.hThiago Macieira2025-03-093-27/+32
| | | | | | | | | | | | | | Which is a more central header, with no other dependencies. This is just a declarative structure with no .cpp requirements, so it fits there. This way, qlibrary_p.h won't depend on qfactory_p.h. QLibrary, QPluginLoader and QFactoryLoader are inextricably linked (the plugin-parsing code is in qfactoryloader.cpp because QFactoryLoader needs it to parse metadata too). This will later allow me to make qfactory_p.h depend on qlibrary_p.h. Change-Id: I0544826807f97d366142fffde0ebdc802273ffc2 Reviewed-by: Ahmad Samir <[email protected]>
* Corelib: implement support for COFF-PE & DLLs in CYGWINCarlo Bramini2025-03-076-5/+16
| | | | | | | | Much of the code was already implemented for WIN32. The patch adds relevant code and implements few exceptions for CYGWIN. Change-Id: I0621075a8a989f64a4c2391d25220ef1686342d8 Reviewed-by: Thiago Macieira <[email protected]>
* QUuid: mark Version::UnixEpoch as since 6.9Marc Mutz2025-01-081-2/+2
| | | | | | | | | | ... because it is. Amends d89cef439f5c1a58aeff879a12d9a33292764b7f. Pick-to: 6.9 Change-Id: I82cfb386c058a0dda873022377ec91368c71e026 Reviewed-by: Thiago Macieira <[email protected]>
* Bootstrap: remove QUuid and QCryptographicHash: they're now unusedThiago Macieira2024-12-301-6/+2
| | | | | | | | The previous commit removed the one use of QUuid and, through it, QCryptographicHash in one of the three bootstrapped tools. Change-Id: I31b7f9f6aa402709bad7fffd3a65e86be7f6d882 Reviewed-by: Ahmad Samir <[email protected]>
* QFactoryLoader: load extraSearchPath firstMike Chen2024-12-231-3/+3
| | | | | | | | | | Since `QT_QPA_PLATFORM_PLUGIN_PATH` or `-platformpluginpath` specifies the path to platform plugins, `extraSearchPath` should be loaded first. Pick-to: 6.8 6.9 Change-Id: I2e62fbf2021250ca864c669a7bbd7d56acd67d1e Reviewed-by: Thiago Macieira <[email protected]>
* QUuid: add support for creating UUID v7Ahmad Samir2024-12-073-5/+109
| | | | | | | | | | | | | | | | | | | Thanks to Thiago for the more efficient way of using 12 bits of the sub-milliseconds part of the timestamp. Previously I used the method described in the RFC (value of type double multiplied by 4096). Add a private helper to check the version since now there is a gap in the Version enum values (UUID v6 isn't supported). Drive-by, document Version::Sha1 enumerator. [ChangeLog][QtCore][QUuid] Added support for creating UUID v7 as described in https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7 Fixes: QTBUG-130672 Change-Id: Idfea9fbb12a7f28e25b27b56a3b402799afb4864 Reviewed-by: Thiago Macieira <[email protected]>
* Create qdoc macros for C++ class docs 2.1: qHash()Marc Mutz2024-11-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a family of qdoc macros to document the various qHash() overloads we have. This patch does not change the \relates of the qHash() functions, they remain as inconsistent as they have been. Created QTBUG-129815 to clean things up. Since this author expects the \relates to change in the future, there are different \qhash commands, and all except \qhashbuiltin take the class name as an argument, for use in a centrally-choreographed fix for QTBUG-129815. As drive-by's, fix: - missing documentation about Key having to support qHash() in the associative Qt containers - drop noexcept and default arguments from \fn lines that needed to have their argument names changed - move the QStringView overload from qhash.cpp to qstringview.cpp (as it \relates to the former) Fixes: QTBUG-129574 Pick-to: 6.8 6.5 Change-Id: I8e8c2edc27422cbe5823f56baf3a24d7f7050836 Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Jaishree Vyas <[email protected]>
* QtCore: don't use QString::utf16() where the string is \0-terminatedAhmad Samir2024-11-131-2/+2
| | | | | | | | | | | | As requested in the code review, use str.data_ptr().data() to skip the detaching check where we need a non-const pointer and it's immediately clear the string isn't shared. Amends 525aff168e30940f35ff5bca3192bd89614784f4. Task-number: QTBUG-125871 Change-Id: Ib4df35fcbeac8778fbc2c5acfabdef52f9360df3 Reviewed-by: Thiago Macieira <[email protected]>
* QtCore: use QString::unicode() where null-termination is guaranteedAhmad Samir2024-11-041-1/+2
| | | | | | | | Instead of QString::utf16() which does some extra work to ensure null-termination for QString::fromRawData() strings. Change-Id: I21b367c0463d0f9099dbdbce3973fe33601e145e Reviewed-by: Thiago Macieira <[email protected]>
* QUuid: restore sorting order of Qt < 6.8Thiago Macieira2024-10-212-3/+12
| | | | | | | | | | | | | | | | | | | | This brings back and adapted version of the sorting code that was removed by commit 15f753ca5a60b5273d243f528978e25c28a9b56d. The issue, as shown in the test, is that we store data1, data2, and data3 as native-endian integers, so the bitcasts in the new code cause them to become mangled in little-endian platforms. Since this is a weird behavior and we'll be changing the sorting order in Qt 7 anyway, I've left a warning for us to think about it at the time. [ChangeLog][QtCore][QUuid] Fixed a regression that caused QUuid sorting order to change for some UUIDs, compared to Qt 6.7 and earlier versions. Fixes: QTBUG-130155 Pick-to: 6.8 Change-Id: I5eeb7b36bfc5ed7218e1fffd6a773c582ad0f6f4 Reviewed-by: Ivan Solovev <[email protected]>
* QFactoryLoader: fix the ability to load symlinks to pluginsThiago Macieira2024-10-171-1/+1
| | | | | | | | | | | | | | | Amends commit 7cf39bd785e8ba817960d48b120983cafcc539f3, which changed to use QDirListing but used FilesOnly. As documented, that does not include symlinks to files. I'm updating a few other uses of FilesOnly where they were ported from QDir::Files and it would be reasonable to expect that symlink to files would be included. That's why I've left QNetworkDiskCache alone. Fixes: QTBUG-130109 Pick-to: 6.8 Change-Id: I1fa195b42fd5e00be157fffd6c861f6ddb1eeed1 Reviewed-by: Ahmad Samir <[email protected]>
* Add debug when skipping plugins due to new QPA version checkAllan Sandfeld Jensen2024-10-021-1/+3
| | | | | | Pick-to: 6.8 Change-Id: Id1fae6b455a4fa5a66bbae3d312a16b2c50d6ac0 Reviewed-by: Tor Arne Vestbø <[email protected]>
* Cleanup plugin version preference logicAllan Sandfeld Jensen2024-10-011-2/+6
| | | | | | | | | The old logic was hard to read and not very thorough. Now prefer exact matches, better too old than too new, and otherwise the newest. Change-Id: I0266f0f24b085fa5de91fc348abe0091b0f6be81 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
* Fix crash with KDE's platformtheme pluginAllan Sandfeld Jensen2024-09-291-2/+8
| | | | | | | | Require QPA plugins to match qt major.minor rules Pick-to: 6.8 Change-Id: I78d40bb22d41b71db83c6a89c8ac8e319ec51d43 Reviewed-by: Thiago Macieira <[email protected]>
* QUuid: make more methods constexprIvan Solovev2024-08-302-28/+41
| | | | | | | | | | | | | | | | | Use QT6_{DECL,CALL}_NEW_OVERLOAD mechanism to provide new constexpr overloads for isNull(), variant(), and version(). Move the old methods into removed_api.cpp Use this as an opportunity to optimize the implementaiton of the methods. Also add compile-time checks to the tests. It turns out that QNX compiler fails to compile the default QUuid::isNull() implementation in constexpr context, so rewrite it using a loop. Change-Id: Ia23c81194ea27b369f00ce73b016695600187e46 Reviewed-by: Marc Mutz <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* Introduce QT_COMPILER_SUPPORTS_INT128 in qsystemdetectionŁukasz Matysiak2024-08-291-1/+2
| | | | | | | | | | | | | | | | | | c661dbd42d87f151e0c6f9e50fb21a137dad850c injected `QT_NO_INT128` into every TU when compiling for VxWorks. VxWorks uses a custom stdlib implementation that does not support 128bit ints and at the same time they use an off the shelf Clang that defines `__SIZEOF_INT128__` which is used to detect if 128b ints are available. This resulted in Qt falsely assuming that 128b ints are available. Detect if 128bit are available instead of injecting `QT_NO_INT128` and define `QT_COMPILER_SUPPORTS_INT128`, use it instead of directly checking `__SIZEOF_INT128__`. Task-number: QTBUG-115777 Pick-to: 6.8 Change-Id: I7531ebe780b4bdd78b42daf8dae0e522a316a88e Reviewed-by: Marc Mutz <[email protected]>
* QUuid:: fix UB in (Id128Bytes) ctorMarc Mutz2024-08-181-5/+8
| | | | | | | | | | | | | | | After qbswap() has run, the Id128Bytes active member is data64, yet the rest of the QUuid constructor accesses .data. This is UB. Use the void* dest overload of qbswap() or memcpy() the Id128Bytes into a char buffer and consume data from there instead. Amends 686c02224c03735356bdab987bf62644eb34cc34. Task-number: QTBUG-120637 Pick-to: 6.8 6.7 6.6 6.5 Change-Id: Iba62a692391a5600b867c30dcb3bc50b82ee072f Reviewed-by: Thiago Macieira <[email protected]>
* Logging: use qCDebug/Warning/Info when for categorized loggingVolker Hilsheimer2024-07-161-1/+1
| | | | | | | | | | | | | When building qt with QT_NO_DEBUG/WARNING/INFO_OUTPUT set, then the qDebug/Warning/Info macros expand to `QMessageLogger::noDebug`. That helper is not defined to take a logging category or category function, so using `qDebug(lcX, ...)` breaks the build. The correct way to emit categorized logging is to use the qCDebug/Warning/Info macros. Task-number: QTBUG-125589 Pick-to: 6.8 6.7 6.5 Change-Id: I968b0e826871a09023c11fec9e51caa5a2c4dc0b Reviewed-by: Jonas Karlsson <[email protected]>
* QLibrary/Unix: update the x86-64-v3 prefix path in our searchThiago Macieira2024-07-101-2/+4
| | | | | | | | | | | | | | | | | | | | glibc introduced the glibc-hwcaps/XXXX path in glibc 2.33 (2020) and removed the old, legacy "haswell/" prefix in glibc 2.37 (2022). This means anyone deploying HW-capable libraries must be deploying symlinks, so we are not losing functionality. Because it says "glibc-hwcaps", I am now making this dependent on glibc for libraries. Added unit testing for this feature. Tested on Linux, FreeBSD, macOS, and Windows (the QLibrary test SKIPs everywhere except Linux). We do create a "libtheplugin.dylib.avx2" on macOS with this change, but won't attempt to load it (Darwin has fat binaries so lipo(1)ing the files together would be the right thing to do). Pick-to: 6.8 Change-Id: Ic0adfa808d28487a8303fffd17d9e78ec87bbd9a Reviewed-by: Fabian Kosmale <[email protected]>
* QLibrary: move prefixes_sys() to the header and make it prefix_sys()Thiago Macieira2024-07-084-15/+11
| | | | | | | | | | | | There's only one prefix for Unix ("lib") and none for Windows, so there's no need to allocate a QList for it in this function. For one of the two callers, it was also possible to avoid the QList and QString allocations, at the expense of testing the same file twice on Windows. We can't do the same for Unix systems because we may add more elements to the QList. Change-Id: Ic0adfa808d28487a8303fffd17d9e6d35aaa79f4 Reviewed-by: Fabian Kosmale <[email protected]>
* QPluginLoader: set an errorString if resolving qt_plugin_instance failsThiago Macieira2024-07-081-1/+3
| | | | | | | | | | We're getting load() == false but errorString() == "Unknown error". Not backporting past 6.8 because of a new translatable string. Pick-to: 6.8 Change-Id: Ic0adfa808d28487a8303fffd17d9ee19ce074e4b Reviewed-by: Fabian Kosmale <[email protected]>
* QUuid: simplify the three-way comparison functions to make them constexprThiago Macieira2024-07-032-65/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While retaining the old sorting order, this allows us to simplify the ifdef'ery and produces much better code. With Clang, an equality check is vmovdqu (%rdi), %xmm0 vpxor (%rsi), %xmm0, %xmm0 vptest %xmm0, %xmm0 sete %al in C++20 mode. GCC generates four 64-bit loads instead of using vectors: movbeq (%rdi), %rax movbeq 8(%rdi), %rdx movbeq (%rsi), %r8 movbeq 8(%rsi), %rcx movq %rdx, %r10 movq %rax, %r11 movq %r8, %rdx movq %rcx, %rax xorq %r10, %rax xorq %r11, %rdx orq %rdx, %rax sete %al (the four MOV in the middle don't seem necessary) For the sorting case, the compilers need to generate extra code because of the check on the variant, something I'm scheduling for removal in Qt 7.0. For long-term sorting code, both GCC and Clang generate four 64-bit load-and-swap-endianness instructions, but Clang for some reason also kept the 128-bit vector code (I'm guessing it's a minor optimization bug that will be corrected in due time). Pick-to: 6.8 Change-Id: I46feca3a447244a8ba19fffd17dceacc8e528c3e Reviewed-by: Ivan Solovev <[email protected]>
* QDirListing: add flags to handle entries filteringAhmad Samir2024-06-271-1/+1
| | | | | | | | | | | | | | | | | | By extending IteratorFlag so that it replaces both QDir::Filter and QDirIterator::IteratorFlag enums, but with better defaults (based on how QDir/Iterator is used in 15-20 years worth of code in Qt and KDE). Make the QDirListing(QDir ~~) ctor private, also change it to use QDirIterator::IteratatorFlags; it will be used to port existing code. If QDir is ported to use QDirListing::IteratorFlags, instead of QDir::Filters, a public QDirListing(QDir) constructor can then be added. Pick-to: 6.8 Fixes: QTBUG-125504 Task-number: QTBUG-125859 Change-Id: Ide4ff8279f554029ac30d0579b0e8373ed4337f7 Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: Prioritize plugin that matches Qt's build configTor Arne Vestbø2024-06-211-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In debug-and-release builds (on Windows or Apple operating systems), we will scan for plugin libraries and find both debug and release versions of these libraries. However, we do not end up loading both, thanks to additional logic. On Windows we rely on logic in QLibraryPrivate::updatePluginState() that uses the IsDebug metadata of the plugin, skipping any mismatch. On Apple operating systems, there is logic in QFactoryLoaderPrivate's updateSinglePath that ties to match the `_debug` suffix of the plugin with the Qt build config. As the string matching logic for Apple platforms is fragile we want to remove it, but we can't re-use the logic for Windows, to ensure we only load a single copy of a plugin, as the Windows logic prevents _any_ mismatch between plugin config and Qt config, even for non- debug-and-release builds (due to the Windows runtime being incompatible between debug and release). To solve this we add logic to QFactoryLoader to prioritize plugins based on the Qt build config, similar to how we prioritize plugins based on their Qt version if we find two or more plugins claiming the same plugin key. Pick-to: 6.8 Change-Id: I772ba8ae79627e39418ba80107e3729bba8f9ac8 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Don't use _debug suffix to determine if a plugin is built in debug modeTor Arne Vestbø2024-06-211-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The string based suffix check is fragile, and doesn't account for Qt builds where the build is debug but we don't suffix the library. The check was added in 27239f4fcfa6f64d60e7b79185ff413878152ebd, where we started linking explicitly to the debug library in a framework, in which case we could end up loading both the debug and release Qt libraries into the same process if we loaded mismatched plugins. However 7044409c878f100c005b76fc90717b4f71667f04 removed the explicit linking, and nowadays we always link to the release version of the framework library, and rely on DYLD_IMAGE_SUFFIX to switch to loading the debug libraries, which applies globally to all libraries loaded. This means we no longer need the _debug suffix check in the plugin factory loader to account for the logic introduced initially in 27239f4fcfa6f64d60e7b79185ff413878152ebd. And as we now have logic to avoid loading duplicate plugins in the case of a debug-release-build we can safely remove the check. Pick-to: 6.8 Change-Id: I75685afa16a33aa41448f9a369dbefa8539418fd Reviewed-by: Thiago Macieira <[email protected]>
* QFactoryLoader: Clarify how we track the prioritized library for a keyTor Arne Vestbø2024-06-211-5/+5
| | | | | | | | | | | Assigning to a variable named `previous` to promote a library to be the current/prioritized library is needlessly obfuscated. Amends 6675e8c942c2f9797d66269368c729c5556528c2. Pick-to: 6.8 Change-Id: Ibdd48cbb5daba60c231f9f71133c3b58d32f7781 Reviewed-by: Marc Mutz <[email protected]>
* qlibrary_unix.cpp: Make adding 'lib' prefix possible even when the file name ↵Rym Bouabid2024-06-191-2/+0
| | | | | | | | | | | | | | | | | | | | | | | starts with 'lib' Loading QLibrary("library_manager") and QLibrary("lib_example") is not possible if their binaries are called liblibrary_manager.so and liblib_examplep.so. Remove this prefix check: if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix)) ,in order to allow calling dlopen() with "lib" prefix added to the name even if the name starts with "lib". The drawback of removing the check is that extra dlopen() calls will take place in other cases such as: "libexample.so". In this case we will have two extra calls of dlopen() taking "liblibexample.so" and "liblibexample". Fixes: QTBUG-23470 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: I2c0b1b81edf8253443388aa67d24f4cd64d4123d Reviewed-by: Thiago Macieira <[email protected]>
* Straighten out various logging categoriesUlf Hermann2024-06-191-1/+1
| | | | | | | | | | | | Either make them static or declare them in a header. We want them to be static wherever possible, in order to reduce the number of visible symbols. If they can't be static, however, they should at least be declared in only one place. Task-number: QTBUG-67692 Change-Id: I6f3b596ed4f0adc9873dd0a5f54f055a991a6207 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* QLibrary/Unix: fix mojibake of dlerror()Thiago Macieira2024-06-181-4/+4
| | | | | | | | | | Amends a6a56814702612d8981f594a6158d70a7928cb99 where I replaced a function that correctly did QString::fromLocal8Bit() with QLatin1StringView. Pick-to: 6.7 6.8 Change-Id: Ic0adfa808d28487a8303fffd17d9ec0817eda3e8 Reviewed-by: Giuseppe D'Angelo <[email protected]>
* QUuid: rewrite compareThreeWay() in idiomatic formMarc Mutz2024-06-171-8/+8
| | | | | | | | | | | | | | | | | | | | | A lexicographical ordering chain with 3way-compare should call op<=> (or it's stand-in, compareThreeWay()) exactly once per element pair in the source ranges. First checking for != and then with <=> means we do the check twice. In this case, when comparing built-in types, the optimizer will probably fold everything for us, but code like this, at this time, has a high chance of being the source of a CnP operation, and the target may compare QStrings this way, so use the idiomatic form to let copy-pasters fall into the pit of success. Amends ef964c254c7a72bc05b1f4f0c6f270f9ad21fecd. Pick-to: 6.8 Change-Id: Ib8344087f23435fc58740165afecd499722d1f00 Reviewed-by: Ivan Solovev <[email protected]>
* Logging: Add a macro for static logging categoryUlf Hermann2024-06-053-3/+3
| | | | | | | | | | | | Since name clashes between logging categories are so common, having a way to explicitly avoid them is important. So far, we are depending on internals of Q_LOGGING_CATEGORY to place the "static" in the right location. That's less than ideal. Task-number: QTBUG-67692 Change-Id: Ifeda5297d1d1220a57118b3bf7c7310e4ddd4f93 Reviewed-by: Tor Arne Vestbø <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* QUuid: port createUuidV{3,5}() to QByteArrayViewMarc Mutz2024-05-292-9/+22
| | | | | | | | | | | | | | | | | | | | Requires to mark the existing QString overload as Q_WEAK_OVERLOAD.¹ And since this non-polymorphic class is exported wholesale, we need to involve REMOVED_SINCE here, too. ¹ While QString and QByteArray don't overload well, the new overload set makes calls with QByteArray arguments ambiguous, unless the QString overload is demoted to a weak one. As a drive-by, change the QUuid argument passing from cref to by-value, fixing a Clazy warning. [ChangeLog][QtCore][QUuid] Ported createUuidV3() and createUuidV5() from QByteArray to QByteArrayView, made them noexcept, and fixed various ambiguities in the overload set. Change-Id: I9f71209f2ddb58ace4e15fb68418b1a21d2b3602 Reviewed-by: Ivan Solovev <[email protected]>
* QCryptographicHash: extend hashInto to more than one piece of dataMarc Mutz2024-05-292-9/+9
| | | | | | | | | | | | | | | | This allows use of the noexcept static function in cases where more than one piece of data needs to be hashed, and concatenation of said data would have to allocate memory. Port QUuid to use the new function, allowing to mark the V3 and V5 create functions noexcept. As a drive-by, take QUuid by value in the internal helper function, fixing a Clazy warning. Task-number: QTBUG-125431 Change-Id: I17938f0be44c91085e2aaa5574953f8dceacc990 Reviewed-by: Thiago Macieira <[email protected]>
* Replace QUuid::toRfc4122() with toBytes() where possibleMarc Mutz2024-05-281-1/+1
| | | | | | | | | They're content-equivalent, except that the latter doesn't have to allocate a return value on the heap. Pick-to: 6.7 Change-Id: Ifcae47b487c80c2bac02900f08393b386cfe806c Reviewed-by: Mårten Nordheim <[email protected]>
* Remove CHECK macro from quuid.h fileTatiana Borisova2024-05-241-5/+6
| | | | | | | | | | | - CHECK name is too common, it turns out webengine uses it widely Amends ef964c254c7a72bc05b1f4f0c6f270f9ad21fecd. Fixes: QTBUG-125627 Change-Id: I53d90621c09c0f50b7bea910875192bc49095987 Reviewed-by: Ivan Solovev <[email protected]>
* QUuid, GUID: use new comparison helper macrosTatiana Borisova2024-05-222-55/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | Replace public friend operators operator==(), operator!=(), operator<(), etc of QUuid and GUID with friend methods comparesEqual() / compareThreeWay(). Use Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE, because the (in)equality operators are constexpr. And then we use helper macros, because the other relational operators are not constexpr. Cannot make relational operators constexpr, because it requires to make variant() and isNull() methods constexpr and QT_CORE_INLINE_SINCE. But the experiments show that it does not work with adding constexpr to QT_CORE_INLINE_SINCE. Put relational operators under !QT_CORE_REMOVED_SINCE(6, 8) to prevent an ambiguity. On Windows the metatype for QUuid is created in removed_api.cpp. That leads to an ambiguity, and as a result the compiler fails to create the equals methods of QMetaTypeInterface. This, in turn, leads to the failed comparisons. The usage of !QT_CORE_REMOVED_SINCE(6, 8) solves the problem. Task-number: QTBUG-120304 Change-Id: I640bdeb8f1f7306ba06b9e4193d008cf2bb6dbfb Reviewed-by: Ivan Solovev <[email protected]>
* Android: don't call JNI_OnLoad for libraries opened with QLibraryVolker Hilsheimer2024-04-161-8/+0
| | | | | | | | | | | | | | | | | | | | JNI_OnLoad gets called automatically by the JVM when it loads a shared library. A native library that is loaded by native code shouldn't have it's JNI_OnLoad entry point function called, as that would indicate that the plugin is loaded by the JVM, which it is not. If framework or application code requires that function to be called (and wants to perform error handling, such as closing the library again if the function returns JNI_ERR), then that can and should be done explicitly. [ChangeLog][Android][QLibrary] Loading a shared library with QLibrary no longer implicily calls a JNI_OnLoad implementation. Fixes: QTBUG-92007 Pick-to: 6.7 Change-Id: I9aa71ec73b950029e0ae1be7d54e1c8576f356ab Reviewed-by: Assam Boudjelthia <[email protected]>
* QLibrary: fake RLTD_NODELETE by not calling dlclose()Thiago Macieira2024-04-031-3/+6
| | | | | | | | | | On systems without the RTLD_NODELETE flag, simply don't call dlclose() and leak the handle. Amends ef5ab6e00664caf0af23b21593f809d718c9dfc7. Pick-to: 6.7 Change-Id: I01ec3c774d9943adb903fffd17b76673562daa8a Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Ivan Solovev <[email protected]>
* QLibrary/Unix: remove two unused, exported private functionsThiago Macieira2024-03-271-14/+0
| | | | | | | | | | | | | | Commit 87362f3f58056e29563936102b29070f3e7e945a added qt_linux_find_symbol_sys(). Given the authors and reviewers, I'm guessing that was used somewhere in qtdeclarative. Indeed, its use was removed in qtdeclarative/67191c2b3213259c6eaf045154e9370faa085868 ("Remove qqmlmemoryprofiler*"). qt_mac_resolve_sys() was never used in the public repository, as far as I can tell. Change-Id: I6818d78a57394e37857bfffd17bbf1fae8688b1a Reviewed-by: Ahmad Samir <[email protected]>