summaryrefslogtreecommitdiffstats
path: root/src/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Fix documentation warnings for QJni* classesTopi Reinio2021-05-056-42/+82
| | | | | | Pick-to: 6.1 Change-Id: Iab836fbdf649f1b3b60e88d32266361299ac4bb2 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix assertion on matchingLocales(Abhkazian, Any, Any)Edward Welbourne2021-05-051-3/+3
| | | | | | | | | CLDR v39 has no locales for Abkhazian, so the locale_index[] entry for it actually indexes the last entry before the next language up the enum. This has m_language_id less than Abkhazian. Change-Id: If8b88f30476a981b3ee00ff8760a46ede0b7aab7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix set*Field JNI template callsAssam Boudjelthia2021-05-051-6/+6
| | | | | | | | | | | The calls were trying to pass a JNIEnv* from a QJniEnvironment using conversion operator which was removed, and weren't detected since they are templates and were missing tests. This fix that and add test cases for setField() and setStaticField() calls. Pick-to: 6.1 Change-Id: I6e1e6b7f557bbc664248ad364c48d63f58b70756 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add new app permissions API under QCoreApplicationAssam Boudjelthia2021-05-0511-4/+827
| | | | | | | | | | | | | | | | | | | | | The API allows users to request and check the status of various permissions. A predefined enum class of the common permission types on different platforms is used to allow requesting permission with a common code. Platform specific permissions are defined only on their relevant platform. For permissions that are not predefined, they can be requested via a string variant of this API. This adds the Android implementation only. [ChangeLog][QtCore] Add new API for handling app permissions with an initial implementation for Android. Task-number: QTBUG-90498 Change-Id: I3bc98c6ab2dceeea3ee8edec20a332ed8f56ad4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QAbstractProxyModel: port to new property systemIvan Solovev2021-05-043-6/+96
| | | | | | | | | | | | | | The biggest trick here is the getter (QAbstractProxyModel::sourceModel), which is returning nullptr, while internally using a global staticEmptyModel() instance. This lead to inconsistency while binding to a proxy model without source model. The bound object would point to staticEmptyModel() instance, while sourceModel() getter returns nullptr. To solve this issue a custom QBindableInterface is implemented. Task-number: QTBUG-85520 Change-Id: I597df891c7e425d51b55f50ccbacabdfe935cbac Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Tweak naming of QT_OVERLOADED_MACRO variantsTor Arne Vestbø2021-05-044-20/+20
| | | | | | | | Add a _ suffix before the number of arguments, to improve readability of the argument-specific functions. Change-Id: I1dfc4f381450825dd143ece524bb10e117c09971 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Ensure setDateTime clears status also when shortEdward Welbourne2021-05-041-1/+3
| | | | | | | | | | | Previously, if multiplication overflowed when trying to set the date and time of a formerly short-form QDateTime, its status didn't get set to reflect the failed validity check. Added a test that now correctly detects that it's produced an invalid date-time on overflow, where previously it produced a wrong valid date-time. Change-Id: Id46ca34d1e32e9b9b0630f3723cefd1c13b5761e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Delete less-than operator for QKeyCombinationVolker Hilsheimer2021-05-041-0/+2
| | | | | | | | | | | | | | | | | | QMetaType relies on QTypeTraits to identify whether a type provides operator<. Due to the the deprecated implicit conversion to int, this results in several screens of deprecation warnings when using QKeyCombination in a signal parameter or as a property type. QKeyCombination has no ordering semantics (is Alt+F5 larger than Control+Up?), so delete the operator. [ChangeLog][QtCore][QKeyCombination] Potentially source-incompatible change: the less-than operator for QKeyCombination has been deleted. Code relying on the deprecated implicit conversion to int will no longer compile. Use QKeyCombination::toCombined explicitly. Change-Id: Ic8522b88d68063f74b5a5582c51aee8e18982331 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QUntypedBindable: Allow controlled access to internalsFabian Kosmale2021-05-042-0/+14
| | | | | | | | | | In declarative, we need direct access to the bindable's pointers. Enable this via a internal only helper struct in qproperty_p.h. Change-Id: I56e4622f570ff08f85f1161af608658ea510671e Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add QUntypedBindable::metaType functionFabian Kosmale2021-05-032-4/+31
| | | | | | | | | | | | | | | This enables checking the metaType of a QUntypedBindable in the public interface. In addition, work around an oversight that can only be fully addressed in Qt 7: The metatype function pointer does not take a QUntypedPropertyData * parameter. However, we need this functionality for an efficient QBindable proxy implementation in declarative (which is needed to implement interceptors there). To work-aronud this in Qt 6, reuse the value getter and turn it into a metatype getter if the value pointer is flagged. Change-Id: Ia3cce08ea761fce57bce59e02212525b996f2fee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Q(Untyped)Bindable: Print warnings when operations failFabian Kosmale2021-05-032-6/+75
| | | | | | | | | Instead of silently failing, we now print an explanatory warning to aid with debugging. Task-number: QTBUG-89512 Change-Id: I36dd2ce452af12d0523c19286919095e366bd390 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJniObject: add callStatic[Object]Method overloads for jmethodIDIvan Solovev2021-05-032-0/+80
| | | | | | | | | | | | This patch extends the QJniObject::callStatic[Object]Method functions with the overload which accepts a jmethodID parameter. This can be convenient when the method id is already cached and you do not want to query the method by its name and signature. Task-number: QTBUG-92952 Change-Id: Ib0852a5a27da2a244ac63112784751ef9e32cfa5 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QJniEnvironment: extend APIIvan Solovev2021-05-032-5/+73
| | | | | | | | | | | | | | This patch adds some convenience methods to QJniEnvironment API: * an overload of registerNativeMethods() that accepts jclass instead of const char *className. * a findMethod() function is added to query a methodID of a static or nonstatic method by its name and signature. Task-number: QTBUG-92952 Change-Id: Ib1bc892decea97e625c4822888b6183af6edd6dc Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QFlags::setFlag: don't go through Int, go through QFlags itselfGiuseppe D'Angelo2021-05-031-1/+1
| | | | | | | | Avoid a "detour" outside QFlags' type safety: operator~ is defined on QFlags already, use that one. Change-Id: Iedd07d1652b8f92e3881298ceafcd5c761346bb0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCoreApplication::applicationFilePath: add ELF auxval supportThiago Macieira2021-05-021-4/+21
| | | | | | | | | | | This implements getting the executable file name for FreeBSD. Linux has a similar functionality (but called AT_EXECFN), but the /proc/self/exe trick is actually better: it returns a full canonical path instead of the argument passed to execve(), and it follows a rename of the executable. Change-Id: I7a386ad4f0cb4e2ba629fffd16789acda415213f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QFlags: streamline some macrosGiuseppe D'Angelo2021-05-021-10/+6
| | | | | | | | | | | | There's little point at keeping the separate Q_DECLARE_INCOMPATIBLE_FLAGS macro, only to invoke it exactly once (from the expansion of Q_DECLARE_OPERATORS_FOR_FLAGS). Besides, Q_DECLARE_OPERATORS_FOR_FLAGS already had some "incompatible" operators in its expansion (the deleted arithmetic ones), so adding the "incompatible" ones in there is consistent. Change-Id: I591d57af8eec5b03ecaa7a3b0de23a967b13f7a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlags: remove the doc-only declaration of copy operationsGiuseppe D'Angelo2021-05-021-4/+0
| | | | | | | qdoc is now able to recognize the special members automatically. Change-Id: I773d94d9e622e67340f3acdbe8bff66143ee1aaa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlags: kill Q_NO_TYPESAFE_FLAGSGiuseppe D'Angelo2021-05-021-13/+0
| | | | | | | The macro is undocumented and unused. Change-Id: I5c09f4e0e2d41e13d2678e2936e0d0e39ed69639 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: code tidiesGiuseppe D'Angelo2021-05-021-9/+9
| | | | | | | | | Change some casts of enumeration/flag types from int to uint. In fact, the enumerations (and flags) in question are *defined* to be backed by unsigned int. Change-Id: I757ded61a26fe979deeaa1e5a524478102960ffe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRandom: enable a check also on MSVCGiuseppe D'Angelo2021-05-021-7/+2
| | | | | | | | We require MSVC 2019 these days, so we can actually check for constexpr initialization. Change-Id: Idc14b785d51c8baaa0bca0ec7dd2e8a85a7e2092 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRandom: drop a usage of std::is_literal_typeGiuseppe D'Angelo2021-05-021-1/+0
| | | | | | | | | It's deprecated/removed, and indeed doesn't check anything that it's not also already being checked by the previous line. Change-Id: Ic80ca43f390dd989ced69f196efa7313069e7c6d Pick-to: 5.15 6.0 6.1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: disable the AES based one on the bootstrap libraryThiago Macieira2021-05-011-2/+2
| | | | | | | | | | | | | | The bootstrap library doesn't need it. All bootstrapped tools are expected to produce deterministic output, given the enforced seed of 0: #ifdef QT_BOOTSTRAPPED // the seed is always 0 in bootstrapped mode (no seed generation code), // so help the compiler do dead code elimination seed = 0; #endif Change-Id: I755911ae7d0341f49039fffd167afc934ff1c9e1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add _qt_internal_wrap_tool_command to replace QT_TOOL_PATH_SETUP_COMMANDAlexey Edelev2021-04-301-0/+24
| | | | | | | | | | | | | | | | | | | QT_TOOL_PATH_SETUP_COMMAND is used in COMMAND list when call add_custom_command/add_custom_target. This is necessary to setup the necessary environment for the tool to run correctly. This approach is weak according to CMake documentation: "If more than one COMMAND is specified they will be executed in order, but not necessarily composed into a stateful shell or batch script." This change introduces the _qt_internal_wrap_tool_command function that uses a wrapping script that setups necessary environment for the tool and runs it in a single shell. The script is generated by the _qt_generate_tool_command_wrapper function. Change-Id: Id5270b91619b607a0c1e3a19b8c706edec43f388 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Port QVariantAnimation to the new property systemSona Kurazyan2021-04-303-6/+35
| | | | | | | | | | | | | | Skipped startValue/endValue properties, since they are computed and writable, which is not supported at the moment. Skipped currentValue, since its setter might be called inside the getter, which is not recommended. Task-number: QTBUG-85520 Change-Id: I1f872b4fcc7227ed91b6915891bbc66019151826 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QSFPM: fix filterCaseSensitivityChanged signal emission logicIvan Solovev2021-04-301-0/+4
| | | | | | | | | | | | | | | | | | This patch amends bcbbbdb2d640c059c19e9337c7418b83b1b7e4ea. It fixes the logic of filterCaseSensitivityChanged signal emission. The call to QRegularExpression overload of setFilterRegularExpression could change the filterCaseSensitivity, but the signal was never emitted. [ChangeLog][QtCore][QSortFilterProxyModel] A call to QRegularExpression overload of setFilterRegularExpression now emits a filterCaseSensitivityChanged signal, if required. Pick-to: 6.0 Pick-to: 6.1 Change-Id: Id4ef04227c1f8ed98153fa5107ec3fbe4c0c77fb Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* fix: Optimize the performance of the inotify file system monitoring program。Gong Heng2021-04-301-1/+1
| | | | | | | | | | | | | | When the ioctl() functions is executed correctly, the value of buffSize may be 0. In this situation, there is no need to execute the following code. This modification can solve two benefits: 1. The readFromInotify function runs frequently, and this modification can improve the efficiency of the program. 2. When the buffSize is equal to 0, "read(inotifyFd, buffer.data(), buffSize)" function will be stuck.(I have encountered this kind of problem) Pick-to: 5.15 6.0 6.1 Change-Id: I9f85491ec91e336b4a1bec5c99b911835c5c06a5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QCoreApplication::applicationFilePath: remove redundant cleanPathThiago Macieira2021-04-301-2/+0
| | | | | | | QFileInfo::canonicalFilePath below cleans the path anyway. Change-Id: I7a386ad4f0cb4e2ba629fffd1678fc6f39ddf74a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QCoreApplication::applicationFilePath: don't check for existence twiceThiago Macieira2021-04-291-17/+7
| | | | | | | | | | | A file that doesn't exist can't have a canonical path, so we don't need to check fi.exists() before calling fi.canonicalFilePath(). Also avoids a TOCTOU mistake: if the exists() returned true, we would store whatever canonicalFilePath() returned, even an empty string (which can also happen if realpath(3) fails for some reason). Change-Id: I7a386ad4f0cb4e2ba629fffd16789aaa8367e641 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QCoreApplication::applicationFilePath: simplify by merging some codeThiago Macieira2021-04-291-16/+14
| | | | | | | | | | | And by introducing a local qAppFileName() for non-Windows and non-Mac. This merges the simplification that each OS does to the obtained file path to a common procedure, removing differences in behavior. Previously, some would get the canonical file path and some wouldn't. Change-Id: I6cdea00671e8479b9c50fffd167899036eaaa23e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QCoreApplication::applicationDirPath/Linux: use /proc/selfThiago Macieira2021-04-291-1/+1
| | | | | | | | | | | There's no need to format our PID there if /proc/self exists and is a link to the current process. Drive-by replace with QStringLiteral, since we won't do any formatting anyway. Change-Id: I7a386ad4f0cb4e2ba629fffd1678fbf0a484ea69 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Use a more forgiving threshold for qFuzzyIsNull(qfloat16)Edward Welbourne2021-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis of problems with the new test for qFuzzyIsNull() revealed that, where its version for double uses approximately 4500 * epsilon and for float used 84 * epsilon as threshold, the qfloat16 version's value was barely more than epsilon, with the result that the test had to use a different value than the threshold to pass. (Converting the threshold from float to qfloat16 and back made it bigger; in effect, the threshold value was not <= itself.) Furthermore, comparison with qFuzzyCompare() implied a value of 1/102.5 should be used, roughly 10 * epsilon, for consistency. When 1/102.5 is rounded to three significant digits (the precision we use in QTest::toString(), for example), to give 0.00976f as threshold, we get a value that, after conversion to qfloat16 and back to float, does give a result <= what we started with. So change qFuzzyIsNull() and its test to use this as qfloat16's threshold value. [ChangeLog][QtCore][QFloat16] The qfloat16 threshold value for qFuzzyIsNull() has changed from 1e-3 to 9.76e-3, almost a factor of ten increase, for consistency with qFuzzyCompare()'s tolerance. Values between these would previously have had qFuzzyIsNull(f) false despite qFuzzyCompre(f, 1+f) being true. Change-Id: I35816dce78da34a3e2339c8bc42d5bd03714a3f6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add tests for qFuzzyIsNull() to tst_QNumeric and tst_QFloat16Edward Welbourne2021-04-291-8/+8
| | | | | | | | | | | | | They were missing. I also wanted to verify that it's true for sub-normal values. At the same time, relocate qfloat16's implementation of qFuzzyIsNull() to between those of qFuzzyCompare() and qIsNull(), since its apparent absence initially confused me. Change-Id: I9637c0070e754d16744c76fc9f846596257c6a63 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert early return from QTimeZone on invalid IDEdward Welbourne2021-04-291-3/+0
| | | | | | | | | | | | | | This reverts commit ec8808c3020abbc436f1a2d90fecf3245fd6417b but retains its test, as the problem it fixed is now solved by having the TZ backend validate the ID it's passed, so that it now only accepts valid POSIX zone-descriptions and valid IANA IDs. The former were being excluded by this check. Amended a POSIX test to fail with the check in place; it passes now. Change-Id: I0d5e8c6e0a315ac2509f3d23bebb52aede8f79d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Robert Löhning <robert.loehning@qt.io>
* Handle invalid system zone case when falling back from time_t functionsEdward Welbourne2021-04-291-26/+30
| | | | | | | | | | | | | | Ammends commit 530e0bd469e6859269c2d1a792b8ce819fbff389, in which I added a QTimeZone-based fall-back for handling of conversions between local time and UTC when outside the range supported by time_t-based functions. That replaced prior kludges, when feature timezone is enabled; however, even with feature timezone, it's possible for the system zone to be invalid. So retain the old kludges also as fall-back for when the system zone is invalid, as well as when we have no timezones to fall back on. Change-Id: Ie2b8af7f1a87d7b0e39cc5ac0c04b04d574f84b5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix mix-guided use of const reference variableEdward Welbourne2021-04-291-1/+1
| | | | | | | | It needs to be a mutable value variable to be std::move()d. Pick-to: 6.1 5.15 Change-Id: I9d78b2975f8964e7a7eb06771b0069d9b9e6661e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix namespace error of std::source_location under C++20Zhang Xiang2021-04-291-2/+6
| | | | | | | | | | | | | | | | | | | | With C++20 standard, src/corelib/kernel/qproperty.h of Qt Base cannot be compiled at line 100: QPropertyBindingSourceLocation( const std::experimental::source_location &cppLocation ) The reason is that source_location has been merged into namespace std since C++20, and the header file has also been change from <experimental/source_location> to <source_location>. The problem can be avoided by define a constant. Fixes: QTBUG-93270 Change-Id: I46b4daac6ea20f9623b43746880500d41396afb2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix comparison between nullptr and QWeakPointerVille Voutilainen2021-04-281-3/+9
| | | | | | | | | | | | | | | | | The comparison between nullptr and QWeakPointer was just bogus and ill-formed. The INTEGRITY compiler catches that even if nothing tries to use the comparison. It is an ill-formed, no diagnostic required case of a function template never being able to produce a valid specialization. And while we're at it, this patch makes the result of comparing a nullptr to a QWeakPointer or vice versa the same as asking .isNull() from the weak pointer, because it seems mind-boggling if those are not the same operation. Task-number: QTBUG-93093 Change-Id: I0cc80e795c9af2be1b76de05157aa458ef260f2e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port QPropertyAnimation::targetObject to bindable propertiesAndreas Buhr2021-04-283-31/+58
| | | | | | | | | | | | | | | | | | This is one of the more complicated ports. The target object was represented by two variables in the past: A raw pointer and a QPointer. The QPointer is checked in some cases to check whether the target object still exists. This patch introduces a targetObjectDestroyed() slot and connects it to the destroyed(QObject*) signal of the target object. In this slot, the animation is stopped. The checks become obsolete thereby and it is sufficient to represent the target Object in one raw pointer. This raw pointer becomes a bindable property. Fixes: QTBUG-92992 Change-Id: I7e2ddb5d8aed007400fe74bea1becf7bdfbf2563 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Doc: Remove mention of no longer supported formatPaul Wicking2021-04-271-3/+1
| | | | | | | Pick-to: 6.0 6.1 Fixes: QTBUG-92826 Change-Id: I35950523e41ceaa1ddc59782c4b527707289013b Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Compile resource objects of the static library using same optionsAlexey Edelev2021-04-271-0/+53
| | | | | | | | | | | | | | | | | Introduce the function that appends the specified properties of the one target to the another. It's possible to copy the standard property set that affects a compilation only or pass some specific properties that need to copy. You may also control the visibily of properties that need to copy by passing the PRIVATE_ONLY or INTERFACE_ONLY option. The function is used to compile the resource targets with the same property set as the main target. Also link the Qt::Platform interface library to collect platform specific properties. Pick-to: 6.1 Change-Id: I727fd0a4bc52c4f5128f28ce796d7a5f3005bb30 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Create link from property overview documentation to bindable propertiesAndreas Buhr2021-04-271-1/+2
| | | | | Change-Id: I906d304b3e04a96da5d90e1baa46776bd3debbc9 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Port QAbstractAnimation to the new property systemSona Kurazyan2021-04-273-15/+97
| | | | | | | Task-number: QTBUG-85520 Change-Id: I2710c314b8c32b03fccb826fd78482ee7095fdda Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port of QItemSelectionModel::model to new property systemAndreas Buhr2021-04-273-24/+86
| | | | | | | | | | The property 'model' is ported to a bindable property. The properties hasSelection, selection, selectedIndexes, and currentIndex are left for later patches. Task-number: QTBUG-85520 Change-Id: Ia424ce99fc80c3d807c634c21d161a3ad94b27d2 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Check POSIX rules during QTzTimeZone creationEdward Welbourne2021-04-272-15/+65
| | | | | | | | | | | | | | | | | | | | | Previously, an apparent POSIX rule would be saved and any defects in it would only be discovered when trying to use it to generate transitions. Instead, check that it has the right form during the initial parsing of its data. In the process, since checking for DST in the process is trivial, implement a long-standing TODO to cache hasDaylightTime()'s answer. The array it scanned was in any case being scanned during construction, so detecting DST in init()'s scan is trivial; and its failure to check the POSIX rule mean it failed to notice when zones entirely specified by a POSIX rule have DST. Adapt a test using a POSIX-only rule to verify it does know the zone has DST; it did not, before this change. Change-Id: I690c013d3331600f7348dae61c35d41e5599da70 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of a POSIX zone rule describing permanent DSTEdward Welbourne2021-04-271-17/+44
| | | | | | | | | | | | | | | | | | | | | | | | | The description necessarily has fake transitions at start and end of the year, potentially outside the year. These transitions should not be reported by QTzTimeZonePrivate as transitions, although its data() must find a "transition" whose data it can use (as in the permanent standard time case, which could potentially be represented the same way, although there's a saner way to do so, that the code already handles) to report the zone's properties. In the process, fix (and make more straightforward) the convoluted decision-making code that was deciding which transitions to include in the returned list. It was assuming invalidMSecs() would be set as the atMSecsSinceEpoch of a transition, although this is computed in a way that makes that value most unlikely, even when the result is invalid. It also rather confusingly mixed < 0 tests as tests for overflow with the one < 0 test that's about ignoring DST before 1970. Also added comments to clarify some of what's going on there. Expanded a recently-added test of a permanent DST zone to verify this now works correctly. Change-Id: Ia8d98f433fb1e479dba5479220a62196c30f0244 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correct the parsing of POSIX rule day-of-year fieldsEdward Welbourne2021-04-271-8/+11
| | | | | | | | | | | | | | | | | There are two formats for such fields: one with a J prefix on a number in the range 1 to 365, the other with no prefix and a range from 0 to 365. The code mistakenly treated the latter as if its range were from 1 to 366. The J-form doesn't count Feb 29th, so March always starts on day 60; the code tried to take that into account, but adjusted in the wrong direction (and this mislead me, in a recent partial fix, into a fence-post error). Add a test-case based on the Africa/Casablanca POSIX rule seen on RHEL 8.2, which tripped over the off-by-one error without a J prefix. This incidentally also tests the J case. Change-Id: I692ca511e5c960f91a6c21073d3b2f037f5e445f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove links to QRegularExpression#Wildcard matchingVolker Hilsheimer2021-04-271-6/+3
| | | | | | | | The topic existed for QRegExp but is not relevant in QRegularExpression. Pick-to: 6.1 Change-Id: Ife9d42b5b03163cfefff19725409a3feac1cddb2 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Change QList's insert() and emplace() to always invalidate [pos, end())Andrei Golubev2021-04-271-107/+114
| | | | | | | | | | | | | | | | | Drop the "move left if pos <= size / 2" path in favor of reference stability of insert and emplace operations Leave the insert(0, ...) and emplace(0, ...) as special cases for prepend optimization as invalidating [begin, end()) practically means that we can reallocate behind the scenes Doing this also simplifies the code a bit Task-number: QTBUG-93019 Change-Id: I7c248f96d687e94a6a38f81ade901619ff2b4733 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 5e76c2acff2c70f2893306b16aeba230f3d6114a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Do not shift the data pointer when removing all elements from QListAndrei Golubev2021-04-271-5/+7
| | | | | | | | | | | Because leaving the pointer untouched is a much more expected behavior The tests for this (and not only) logic can be found in the following commit Change-Id: Iec9eec9bbce04c9fd90cb6be9627c135cd989b7f Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 38bba2a87c6c5c2b8100870add6d0d7ad559e669) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Resurrect data moves in QListAndrei Golubev2021-04-276-83/+307
| | | | | | | | | | | | | | | | | Use the data moves to readjust the free space in the QList, which ultimately fixes the out-of-memory issues caused by cases like: forever { list.prepend(list.back()); list.removeLast(); } Task-number: QTBUG-91801 Task-number: QTBUG-91360 Task-number: QTBUG-93019 Change-Id: Iacff69cbf36b8b5b176bb2663df635ec972c875c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit a0253f5f0249024580050e4ec22d50cb139ef8d9)