summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* QMetaType: don't use global relocations to the lambdas and structuresThiago Macieira2022-08-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | The way the Qt 6.0 QMetaTypeInterface was designed, using a static inline variable in a template, would normally require the linker and dynamic linker to merge all copies and choose a single copy as the official one. But because of hidden visibility and of Windows DLLs, QMetaType already copes with multiple copies NOT getting merged. So we may as well ask the linkers not to bother and use simpler, local relocations to find those symbols. They are all supposed to still be equivalent and it's an ODR violation if they're not. The Apple ld64 linker complains if you use this type of global relocation: ld: warning: direct access in function [...] to global weak symbol 'QtPrivate::QMetaTypeInterfaceWrapper<int>::metaType' Fixes: QTBUG-93471 Pick-to: 6.3 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f98a10aa719434 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add a test to confirm that types are equal across librariesThiago Macieira2022-08-127-5/+193
| | | | | | | | Because of the template shenanigans. This is just to make sure. Pick-to: 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f989e7d555894f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove assertion from ownMethodIndex that breaks testsSami Shalayel2022-08-101-0/+39
| | | | | | | | | | | | | | | | | | | | ownMethodIndex works for all kind of methods, also for constructors. Therefore, remove the assertion there (that checks for non constructors) and add a test in qtbase so it does not happen again. The test broken by the assertion is in qtdeclarative: tst_QJSEngine::newQMetaObject(). Also rename QMetaMethodPrivate::ownConstructorIndex() to ownConstructorMethodIndex() as the previous naming implied that ownMethodIndex() could not be used for constructors. amends b73ab954dffffc462b6f6efe5a2dd97efeab0038 Task-number: QTBUG-105360 Change-Id: I0244993ed79bee055645b5443f5d02e1c089a6c6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Tests: remove #define COMMAThiago Macieira2022-08-092-13/+12
| | | | | | | | | | Those were workarounds to passing a comma to a macro, but there are ways around it. The simplest is to just use variadic macros; another, which has been applied to Q_DECLARE_METATYPE for a long time, is to define an alias to the thing you're trying to use. Change-Id: Ie4bb662dcb274440ab8bfffd17097fbf0c53eabc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove blacklist of tryAcquireWithTimeout on WindowsAllan Sandfeld Jensen2022-08-071-6/+0
| | | | | | | Hasn't failed on Windows in months Change-Id: Id14eaead667dfba93807592a7e0cb4da7f91f16f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qputenv: port to QByteArrayViewMarc Mutz2022-08-063-7/+7
| | | | | | | | | | | | | | | | | | | | The vast majority of in-tree users pass simple and short C string literals as the value. By porting to QByteArrayView, we document that we'll accept non-NUL-terminated data, and do the NUL-termination internally, using SSO'ed std::string, saving memory allocations in the common case of short strings. I didn't bother to check which direction std::string takes for nullptrs these days (there was a change accepted in that area for C++20 or 23), so play it safe and protect against them. Follow-up to Task-number: QTBUG-105302 Change-Id: I2369acc62f1d5cbc26135396cfe0602d8c75300c Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qputenv: defend against non-NUL-terminated QByteArray valuesMarc Mutz2022-08-051-1/+5
| | | | | | | | | | | | | | | | | | | | | | | The old code assumed that a QByteArray's data() is always NUL-terminated. Due to the conflation of owners and non-owners in QByteArray (but also in case we ever get efficient substringing), this is not always the case, e.g. QByteArray::fromRawData() does not ensure NUL-termination. From QString::utf16(), we learn that the condition to check for is QArrayData::isMutable(). After working around the fact that QByteArray::data_ptr() doesn't exist for const QBAs and that empty QBAs always refer to QByteArray::empty_, which is !isMutable(), we can detect this situation and re-allocate without introducing new API. This is the fix for Qt ≤ 6.4. For Qt 6.5, we'll port the function to QByteArrayView. Pick-to: 6.4 6.3 6.2 5.15 Fixes: QTBUG-105302 Change-Id: I3416535ab09d601e0e87b2767f2c024ba1217e64 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add Latin 1 case-insensitive Boyer-Moore searcherØystein Heskestad2022-08-041-0/+104
| | | | | | | | | | The std::boyer_moore_searcher is buggy for older verions of Microsoft's STL, and missing in AppleClang's libc++ with an inefficient fall back. Fixes: QTBUG-100236 Change-Id: Ic3cc916946546d2ef78456cd15e1425d957b989d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Rearrange the skipping of a test to give a better messageEdward Welbourne2022-08-031-2/+4
| | | | | | | | | | When tst_QDateTime::fromStringStringFormat_localTimeZone_data() skips due to feature timezone being undefined, it should report that as the issue, rather than claiming the system doesn't support the particular zones used in the test. Change-Id: I9837ac95c6d92317fbec7fcca184f7b7e6f81441 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make 'zz' format an alias for 'z' in time format stringsEdward Welbourne2022-08-032-2/+3
| | | | | | | | | | | | | | Also document the (seldom helpful) handling of over-long repeats of a format. Add test to QDateTime and amend QLocale test. [ChangeLog][QtCore][QDateTime] Doubling the 'z' format in a date-time or time format string now produces the same output as a single 'z'. Previously, this would have produced two copies of the milliseconds field (eliding any trailing zeros in each). Contrast with 'zzz', which produces the full milliseconds field, including any trailing zeros. Change-Id: I4c60462b062fee4079370096d745c191c1939506 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtBase: Windows: Replace some deprecated API usagesYuhang Zhao2022-08-031-1/+1
| | | | | | | | | | | | Microsoft recommends to use CoInitializeEx() and SetWindowLongPtr()/GetWindowLongPtr() in new code. Use COINIT_DISABLE_OLE1DDE to avoid overhead of initializing and using obsolete technology. Pick-to: 6.4 Change-Id: I9d16943e864d4487dd4f46fd9325579c298c52b9 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-03298-0/+900
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QMetaObject: fix calling overloaded functions & constructorsThiago Macieira2022-08-011-2/+69
| | | | | | | | | | | The rewrites in a1c34d8bd09bfc6e80dcb06c7900d40c2d32518c, 0f76e55bc440a70f5d9530a192c9ce6334a8f069 and in commit b73ab954dffffc462b6f6efe5a2dd97efeab0038 didn't do this right, though no problem ended up happening. In particular, the constructor one failed to check if there were even more parameters. Change-Id: I6f936da6f6e84d649f70fffd1706f827ba635584 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Notify observers even when dependency is goneFabian Kosmale2022-08-011-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem description: -------------------- Assume we have two properties, P1 and P2. Assume further that we assign a binding to P2, so that it depends on P1. Let the binding additionally capture some (non-QProperty) boolean, and only create the dependency to P1 if the boolean is true. The state afterwards is P1:[p1vaue|firstObserver] | | v ---[p2binding] / P2:[p2value|binding] If the boolean is set to false, and P1 changes its value, we still correctly re-evaluate the binding and update P2's value. However, during binding evaluation we will notice that there is no further dependency from P2 on P1, and remove its observer. The state afterwards is P1:[p1vaue|firstObserver=nullptr] ---[p2binding] / P2:[p2value|binding] Then, during the notify phase, we traverse the observer's again, starting from P1's firstObserver. Given that it is nullptr now, we never reach P2's binding, and thus won't send a notification from it. Fix: ---- We store a list of all visited binding-observers (in a QVarLengthArray, to avoid allocations as long as possible). After the binding evaluation phase, we then use that list to send notifications from every binding that we visited. As we already have a list of all bindings, we no longer need to recurse on binding-observes during the notification process; instead, we only need to deal with static callbacks and ChangeHandlers. The pre-existing notification logic is still kept for the grouped update case, where we already have a list of all delayed properties, and should therefore not encounter the same issue. Unifying its codepath with the existing logic is left as an exercise for a later patch. Fixes: QTBUG-105204 Task-number: QTBUG-104982 Pick-to: 6.4 6.3 6.2 Change-Id: I2951f7d9597f4da0b8560a64dfb834f7ad86e757 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_QMetaType: fix warning that buffer may be unusedThiago Macieira2022-07-311-2/+2
| | | | | | | | | | | | | We pass a pointer to uninitialized memory to QMetaType::create(). There's no harm because we're using the invalid QMetaType, but GCC is actually right to complain for any other type. qtestcase.h:54:25: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized] qmetatype.h:454:11: note: by argument 2 of type ‘const void*’ to ‘void* QMetaType::create(const void*) const’ declared here Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd1703eb7967acf0d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QRegularExpression: introduce (global)matchViewGiuseppe D'Angelo2022-07-291-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QRegularExpression::match (and globalMatch) is currently overloaded for QString and QStringView. This creates a subtle API asymmetry: QRegularExpression re; auto m1 = re.match(getQString()); // OK auto m2 = re.match(getStdU16String()); // Dangling This goes against our decision that every time that there's a possible lifetime issue at play, it should be "evident". Solving the lifetime issue here is possible, but tricky -- since QRegularExpression is out-of-line, one needs a type-erased container for the input string (basically, std::any) to keep it alive and so on. Instead I went for the simpler solution: deprecate match(QStringView) and introduce matchView(QStringView) (same for globalMatch). This makes it clear that the call is matching over a view and therefore users are supposed to keep the source object alive. Drive-by, remove the documentation that says that the QString overloads might not keep the string alive: they do and forever will. [ChangeLog][QtCore][QRegularExpression] Added the matchView() and globalMatchView() functions that operate on string views. The match(QStringView) and globalMatch(QStringView) overloads have been deprecated. Change-Id: I054b8605c2fdea59b556dcfea8920ef4eee78ee9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaObject: rewrite invokeMethod()Thiago Macieira2022-07-281-3/+13
| | | | | | | | | | | | Use the QMetaMethodPrivate::invokeImpl() function we added in the last commit, without recreating the method signature. Instead, only do a comparison on the method name and allow invokeImpl() to decide whether this method can be called with the given arguments. This will allow invokeImpl() to have more flexibility in deciding if the arguments match, using the stored metatype information. Change-Id: I36b24183fbd041179f2ffffd17021a86484bfab6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaObject: rewrite QMetaMethod::invokeThiago Macieira2022-07-281-0/+4
| | | | | | | | | | | | | This adds an internal method to QMetaMethodPrivate to do the work of actually placing the call on a given meta method. This rewrite should make the code clearer, but make no otherwise perceptible difference in behavior. The next commit will rewrite QMetaObject::invokeMethod to use this new, internal function to avoid doing a lot of string allocations. Change-Id: I36b24183fbd041179f2ffffd170219c0deaaf7f5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-28114-132/+132
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* tst_QMetaObject: add a test for using Q_ARG with a non-const refThiago Macieira2022-07-271-0/+15
| | | | | | | | | | | | | | This is in use in tst_qdbusinterface.cpp, so let's have it here to make sure it works: QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg), Q_ARG(QDBusVariant, arg2), Q_ARG(QDBusVariant&, retArg2))); Change-Id: I36b24183fbd041179f2ffffd170271424c048292 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaObject: make sure we don't mix references with non-refsThiago Macieira2022-07-271-0/+10
| | | | | | | | We should fail to even find the method. `QString' and `QString&` are not compatible. Change-Id: I36b24183fbd041179f2ffffd170259bcf07fd459 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaObject: add some tests for passing and receiving pointersThiago Macieira2022-07-273-1/+86
| | | | | Change-Id: I36b24183fbd041179f2ffffd170259a81d65a36e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaObject: change tests to forward-declared-onlyThiago Macieira2022-07-274-22/+42
| | | | | | | | | | | | | | The type MyUnregisteredType needs to be only forward-declared for the trick to work. The issue is not about registration, because since commit fa987d44417528856d5e80ed7b48ba99e19fa307 ("MetaObject: Store the QMetaType of the methods"), we will record the meta type of the type anyway, which will eventually allow the meta object to actually find this type. Instead, the tests are valid for a type that is only forward-declared. Change-Id: I36b24183fbd041179f2ffffd1702182746f7c1b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove qvariant_p.hThiago Macieira2022-07-271-1/+0
| | | | | Change-Id: I3859764fed084846bcb0fffd1704480153e34973 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* QVariant: split the warning from customConstruct()Thiago Macieira2022-07-271-2/+8
| | | | | | | | | In one of the three calls to customConstruct() -- QVariant::detach() -- we've already checked that the type is valid, so don't re-emit the warning there. Change-Id: I3859764fed084846bcb0fffd1703a3c7c0fb3164 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: don't record trivial construction function pointersThiago Macieira2022-07-272-20/+106
| | | | | | | | | | | | We can implement the trivial {default,copy,move} construction outselves inside qmetatype.cpp and qvariant.cpp, simplifying the QMetaType interface object, removing up to three relocations per QMTI. This adds the testing for QMetaType::isXxxConstructible and isDestructible that couldn't be added before. Change-Id: Ic44396b31ba04712aab3fffd16ff0a28f541d507 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add registerType() and qRegisterMetaType(QMetaType)Thiago Macieira2022-07-261-0/+24
| | | | | | | | | | | | | | | | | | | | | | | This also rewrites QMetaType::id() on top of the helper, with the benefit of calling a member static function, so QMetaType doesn't need to be spilled onto the stack. In some upcoming changes I need to ensure that QMetaTypes are registered so they can be found by name and I'd like to have a dedicated function name for that, instead of calling .id(). Since I needed to add docs for the new function, I've updated for the old one too. [ChangeLog][QMetaType] Added QMetaType::registerType() and an overload of qRegisterMetaType() taking QMetaType (the two functions do the same thing). These two functions ensure a given QMetaType is registered with the Qt global registry, so they can be found by name later. Using qRegisterMetaType<T>() also accomplishes the same thing, but is slightly better for completely generic code because it will avoid emitting the registration for built-in types. Change-Id: I3859764fed084846bcb0fffd170351d606034c22 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: fix isRegistered()Thiago Macieira2022-07-262-0/+10
| | | | | | | | It's not registered until an ID is assigned. Pick-to: 6.4 Change-Id: I3859764fed084846bcb0fffd17034f5b369c5b4d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: suppress most warningsThiago Macieira2022-07-261-1/+16
| | | | | | | | It's not warning-free, but it's much better. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323c9ed12dd23 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: merge flags and flagsStaticlessThiago Macieira2022-07-262-52/+42
| | | | | | | | | And rewrite them with templates. QMetaType::typeFlags() simply calls flags() anyway. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323f9d8c80466 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QByteArray: fix base64 round-trip w/more than 2GiB dataMarc Mutz2022-07-261-0/+40
| | | | | | | | | | | | | | | | | There was an explicit int cast in fromBase64Encoding() which was never ported to qsizetype and therefore truncated the result. Fix by removing the int cast. Add a test, optimize it for as low memory usage as possible, given we need to work in input and output data each in excess of 2GiB. Fixes: QTBUG-104985 Pick-to: 6.4 6.3 6.2 Change-Id: I9c0924957e62e5cb3003132cd811b8b0315d8ac1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVariant: do allow non-default-constructible typesThiago Macieira2022-07-221-2/+29
| | | | | | | | | | | | So long as you only ask us to copy it. Copying is mandatory, though. I'll firm up the warning in a later commit, which may not get cherry- picked as far back. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-105140 Change-Id: I3859764fed084846bcb0fffd170432abf65dc197 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QCursor: add missing QT_DEPRECATED_VERSION_X_6_0 for deprecated methodsIvan Solovev2022-07-211-6/+6
| | | | | | | | | | | | | | | | | When the method is wrapped into if QT_DEPRECATED_SINCE(MAJ, MIN) we also need to add QT_DEPRECATED_VERSION_[X_]_MAJ_MIN macro right in front of the method declaraion, to actually trigger a deprecation warning. This patch does that for QCursor's deprecated methods, and fixes all related compilation warnings in QtBase. Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: Ic8d059e8c852d4b2dee55e7ea94f4fc7a402cdf4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QVariant: Avoid crash when constructed from unsuitable metatypeFabian Kosmale2022-07-211-0/+47
| | | | | | | | | | | | | | If the metatype does not support copy and default construction, then it it unsuitunsuitable for use in QMetaType. We cannot prevent users from passing in such metatypes (as we have e.g. a ctor taking QMetaType), so verify this in customConstruct, and make the variant invalid in that case. Pick-to: 6.2 6.3 6.4 Change-Id: Ib1f0149c8fb9a1cce0049fd0311980754cc85d1b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QByteArray: fix custom QCOMPARE for QBAs > 2GiBMarc Mutz2022-07-201-1/+1
| | | | | | | | | | | | | | | The tst_QByteArray test redefines the QCOMPARE macro to check the LHS to be NUL-terminated. Because the code was never ported from int to qsizetype, it fails for QByteArrays of size > 2GiB. Fix by porting to qsizetype. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104985 Change-Id: Ib3951b0efed5f734ae1324ea2d455bb7762fb9c4 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMutex: limit moreStress test to idealThreadCount threadsVolker Hilsheimer2022-07-201-5/+7
| | | | | | | | | | | | Or the previous limit, 10. The test has a flaky and failing history, esp on macOS. Trying to provoke race conditions with more threads than we have cores has little value. Pick-to: 6.4 Change-Id: I99dd2b5a6f64faa83963c279c84fc547416f914f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread: Clean up bindingStatusOrList if object gets deletedFabian Kosmale2022-07-141-0/+14
| | | | | | | | | | | | Deal with the case that the object gets deleted between a call to moveToThread and the start of the thread by removing the object from the list in that case. Fixes: QTBUG-104014 Pick-to: 6.4 Change-Id: Ib249b6e8e8dfbc4d1332bb99a57fa9d3cff16465 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess: skip processesInMultipleThreads test on emulatorsVolker Hilsheimer2022-07-132-0/+6
| | | | | | | | | | The test has timed out when run on ARM in qemu. We start more threads than the ideal count, which is likely too much for the emulator when not running the native architecture. Pick-to: 6.4 Change-Id: I42e11945070646551e77c10618df762a4bffc8ba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use debug stream in QTest::toString's default fallback if possibleVolker Hilsheimer2022-07-131-0/+2
| | | | | | | | | | | | | | | | | | | | For built-in types, this is a compile-time assert - we should not have any types in Qt for which we have neither debug streaming nor a QTest::toString specialization implemented. A build of most of Qt submodules passes with this change, after minor modifications to some tests. We cannot declare QSizeHint::Policy as a metatype after the QMetaType has already been instantiated for it, and the QDebug stream operator for QElaspedTimer needs to be correctly declared within the namespace. Add a self-test function for a custom type, and update reference files of the self-test. Task-number: QTBUG-104867 Pick-to: 6.4 Change-Id: I2936db5933f4589fce45f47cf2f3224ed614d8c9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QThread: Initialize bindingStatus for adopted threadsFabian Kosmale2022-07-131-0/+17
| | | | | | | | | | | | | If we create a QThread from QThread::current(), we want it to have a correct value for its bindingStatus. Thus, initialize bindingStatus in the ctor of QAdoptedThread. Task-number: QTBUG-101177 Task-number: QTBUG-102403 Pick-to: 6.4 6.3 Change-Id: I3ef27ed62c5dc25eed05d551c72743a1b8528318 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QJniObject: Add template overloads for get/setStaticFieldVolker Hilsheimer2022-07-121-0/+7
| | | | | | | | | | | | | | Allow specifying the Java class on which to set/get the field via its corresponding C++ type, removing the need to explicitly provide the Java type string. Those were missing from a085a14d76553ebd1fa4a4a11a27110ee544a531, which was noticed when porting QtConnectivity over to the new template APIs. Pick-to: 6.4 Change-Id: I8f324c9fcc486b4c6c2f2b9051f7eca0cbec0e91 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Specialize MetaObjectForType for non-pointer QObject-derived typesMikolaj Boc2022-07-121-0/+1
| | | | | | | | | | | | | | | | | | QMetaTypeInterfaceWrapper tries to find the metaObjectFunction using the MetaObjectForType template. Using SFINAE, for a QObject, it should resolve to a suitable specialization. Such a specialization doesn't yet exist. It had to be created. The following path returns nullptr for registered meta types: auto metatype = QMetaType(typeId); requestedTestType.metaObject() -> returns nullptr since a bad template argument is fed to MetaObjectForType<T> in QMetaTypeInterfaceWrapper<IneritingFromQObject>::metaType's static initializer. Change-Id: I8b31c51e12cb19c333e00480b0177354b910ce1e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port QXmlStremReader to QAnyStringViewSona Kurazyan2022-07-121-0/+22
| | | | | | | | | | | | | | | | Port the constructor and addData() method to QAnyStringView, but keep the overloads taking a QByteArray to avoid extra copies when actual QByteArray is passed. These overlaods need to be Q_WEAK_OVERLOADs, to avoid ambiguities (e.g. for const char * arguments). Additionally, add a test to make sure the patch doesn't break parsing from a QLatin1StringView input. [ChangeLog][QtCore][QXmlStremReader] Added constructor and addData() overloads taking QAnyStringView. Change-Id: I0efaab82a2123271c88407e380f3c67d1099a4a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add wasm exception for tst_qcharDavid Skoland2022-07-111-0/+5
| | | | | | | | | Since wasm doesn't like filesystems that well, we omit this test in tst_qchar for wasm, this allows us to still run the test without the case where it needs to read the normalization file. Change-Id: I37e54d97e119f94e1a9ca53917d0b93183321899 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QString: fix lifetime issues with QRegularExpression APIsGiuseppe D'Angelo2022-07-101-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QString has several functions taking a QRegularExpression: indexOf(), contains(), and so on. Some of those have an out-argument of type QRegularExpressionMatch, to report the details of the match (if any). For instance: QRegularExpression re(...); QRegularExpressionMatch match; if (string.contains(re, &match)) use(match); The code used to route the implementation of these functions through QStringView (which has the very same functions). This however opens up a lifetime problem with temporary strings: if (getString().contains(re, &match)) use(match); // match is dangling Here `match` is dangling because it is referencing data into the destroyed temporary -- nothing is keeping the string alive. This is against the rules we've decided for Qt, and it's also asymmetric with the corresponding code that uses QRegularExpression directly instead: match = re.match(getString()); if (match.hasMatch()) use(match); // not dangling ... although we've documented not to do this. (In light of the decision we've made w.r.t. temporaries, the documentation is wrong anyways.) Here QRE takes a copy of the string and stores it in the match object, thus keeping it alive. Hence, extend the implementation of the QString functions to keep a (shallow) copy of the string. To keep the code shared as much as possible with QStringView, in theory one could have a function taking a std::variant<QString, QStringView> and that uses the currently active member. However I've found that std::variant here creates some abysmal codegen, so instead I went for a simpler approach -- pass a QStringView and an optional pointer to a QString. Use the latter if it's loaded. QStringView has some inline code that calls into exported functions, so I can't change the signature of them without breaking BC; I'm instead adding new unexported functions and a Qt 7 note to unify them. Change-Id: I7c65885a84069d0fbb902dcc96ddff543ca84562 Fixes: QTBUG-103940 Pick-to: 6.2 6.3 6.4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live QDebug op<< QMetaType!Marc Mutz2022-07-091-0/+24
| | | | | | | | | | | It's needed in QtHttpServer. [ChangeLog][QtCore][QDebug] Can now stream QMetaType. [ChangeLog][QtCore][QMetaType] Can now be streamed through QDebug. Change-Id: I974d77d678137715472a3907ab1e50ba2dbaa087 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add support for scoped JNI callbacksJuha Vuolle2022-07-072-0/+89
| | | | | | | | | | | | | | This commit adds macros for declaring scoped native callbacks which are in namespace or for example defined as static class member variables. The existing macros don't allow this as they use QtJniMethods namespace and the introduced callbacks' namespaces are not enclosed in that namespace, yielding a compilation error. Pick-to: 6.4 Change-Id: I754560bea7e9a1b57c2661d1ee7236e78db39ba1 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove uses of Q_ATOMIC_INT{8,16,32}_IS_SUPPORTEDMarc Mutz2022-07-062-32/+14
| | | | | | | | | | | It's always true these days, assert so in qatomic.cpp and tst_QAtomicInteger. Update the docs. Pick-to: 6.4 Change-Id: I3684cff96c1d2e05677314e29514cc279bd6b1a1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add support for naming JNI functions with the unstringify macroJuha Vuolle2022-07-052-0/+27
| | | | | | | | | | | | | | The manually defined native JNI function tables allow defining a name that may be different from the actual function name; this name is then used from the Java-side. This can be useful to provide also as an option with the new "unstringifying" macros which can help for example in porting code to these new macros. Pick-to: 6.4 Change-Id: Icfebfb351cb8dfb122795d20b37e2eac167a41bf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Support markdown in QTextEditMimeData; fix pasting trailing newlinesShawn Rutledge2022-06-241-0/+11
| | | | | | | | | | | | | | | | | | | - Since 4edcea762d9ce334c4c1a78234c90c118b81da87 the dropsite example shows markdown if available; and now it shows that when we do DnD of a selection from the richtext example, text/markdown is available. - If we artificially make html unavailable, copying and pasting between widget-based rich text editors uses markdown. In case markdown writer output contains unnecessary backticks due to monospace fonts getting used, the workaround from 1ad456c908467212bc30223a69eb7524b64b86e1 is applied. Pick-to: 6.4 Task-number: QTBUG-76105 Task-number: QTBUG-103484 Change-Id: Ie6ca4dbb450dbc36b3d09fd0df1ae5909aaebca7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>