Commit Graph

5601 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov
df6ba4bc16 tst_qurluts46: Support \u escapes in the test data
These escapes were documented but not used until the version 15.0.0
of Unicode.

Task-number: QTBUG-106810
Change-Id: If48dcd80acf32989e3f47676ca3d41848a325c0e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-06 14:26:25 +02:00
Marc Mutz
df9d882d41 Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:

  auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.

<classes> are:

    // sequential:
    "QByteArray",
    "QList",
    "QQueue",
    "QStack",
    "QString",
    "QVarLengthArray",
    "QVector",
    // associative:
    "QHash",
    "QMultiHash",
    "QMap",
    "QMultiMap",
    "QSet",
    // Qt has no QMultiSet

Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-04 07:40:08 +02:00
Giuseppe D'Angelo
42b66bd809 QTaggedPointer: disable operator= with an empty initializer list
Given a QTaggedPointer, users may write

  taggedPtr = {};

to mean "reset it". This is error-prone: due to overload resolution,
this actually ends up calling QTaggedPointer<T>::operator=(T *),
which changes the pointer but *not* the tag, and not the implicitly
declared QTaggedPointer<T>:operator=(const QTaggedPointer<T> &)
which would reset both pointer and tag.

Given the idiomatic usage of {} is indeed to perform a full reset (cf.
std::exchange(obj, {}), std::take, etc.), work around this by disabling
the operator= overload for pointers in case an initializer list is
passed. In other words, make `={}` fall back to the implicitly
declared overload.

Note, this breaks some usages, such as

  taggedPtr = {rawPtr};

but at least we get a compile error for these, and they don't look
common at all.

[ChangeLog][QtCore][QTaggedPointer] The operator assignment
taking a raw pointer has been reimplemented in order to avoid
subtle issues when assigning `{}` to a QTaggedPointer. This will
cause code that assigns a braced-init-list to a QTaggedPointer object
to stop compiling (for instance, `tagPtr = {ptr}` is now ill-formed).

Change-Id: I5e572a9b0f119ddb2df17f1797934933dff2ba7b
Task-number: QTBUG-106070
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-29 16:18:55 +02:00
Edward Welbourne
18439a449f Support serializing time-zone fields in date-times more flexibly
[ChangeLog][QtCore][QDateTime] The 't' format character in a
toString() template can now be repeated to get alternatives to the
(unparseable) zone abbreviation. Thus 'tt' now gets the zone offset
without colon, [+-]hhmm; 'ttt' gets the same with colon, [+-]hh:mm,
and 'tttt' gets the zone name. Previously, each 't' was replaced by
another copy of the abbreviation.

Task-number: QTBUG-95966
Change-Id: Iccccd11f06fa732ed27c0e5d4e40a3d4b5f79f8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-29 14:42:56 +02:00
Edward Welbourne
0bc92c01e3 Support parsing time-zone specifiers more selectively
[ChangeLog][QtCore][QDateTime] The 't' format used in fromString() can
now be repeated to restrict parsing to particular forms. Thus 'tt' now
matches the [+-]hhmm offset format (no colon), 'ttt' the [+-]hh:mm
offset format (with colon), and 'tttt' matches an actual zone
name. When used singly, 't' still matches anything the parser knows
how to interpret as a zone specifier.

[ChangeLog][QtCore][QLocale] The 't' format in toDateTime() now has
repeated forms, as for QDateTime::fromString().

Task-number: QTBUG-95966
Change-Id: I73753145cb66a56bc25a5c2dd5cb051ba982fa2c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-29 14:42:55 +02:00
Thiago Macieira
1e625033be tst_QSharedMemory: remove mention of gravlaks.troll.no
It was our old, HP-UX machine on Itanium (ran on big-endian mode). We
don't support HP-UX any more; HP will still support the 11i v3 release
until 2025, but I doubt anyone wants to run any new software there. One
hopes that HP has long since fixed the issue, but I doubt it since the
last release is from 2007. Gravlaks probably ran HP-UX 11i v3.

There are a couple other left-overs of ".troll.no" in the repository,
the majority of which are URL manipulation in tst_qurl.cpp and in
tst_qnetworkcookie.cpp, then the certificates for fluke.troll.no (valid
until 2035) and aspiriniks.troll.no (expired in 2009, but we don't need
it for validity).

Change-Id: I810d70e579eb4e2c8e45fffd1719122747d7b85a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-28 15:56:45 -07:00
Arno Rehn
7a7051b58f QMetaType: Support custom unary converters with optional<To> return type
To indicate success of a conversion, the public API has previously only
supported registering member functions of the form To (From::*)(bool *).
When adding custom converters for types that cannot be modified, this is
usually not a possibility.
As an alternative, this patch adds support for std::optional in the
UnaryFunction overload of QMetaType::registerConverter. If the returned
optional has no value, the conversion is considered failed.

Task-number: QTBUG-92902
Change-Id: Ibac52d2cb9b5a2457081b4bebb0def1f03e3c55d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-09-27 20:59:21 +02:00
Ville Voutilainen
e08f05ac6e QDebug: Support standard strings and string views directly
[ChangeLog][QtCore][QDebug] QDebug now supports printing
std::strings and std::string_views (and their wide, u16, and
u32 variants) directly.

Task-number: QTBUG-96878
Change-Id: I7baf4fe688bfff50580b1cee9417af13949374cc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-27 14:12:11 +03:00
Øystein Heskestad
d8387fc538 Reduce foldCasing of the needle in Boyer-Moore QString searches
Before searching, foldCase the first up to 256 characters, and use this
buffer to compare against the haystack. If the needle is larger than the
buffer, compare the rest of the needle against the rest of the haystack
for every potential match. The buffer is placed on the stack and must be
refolded for each search, but this change does not break the API.

This is faster than the old implementation, except if the needle is long
and it is found near the beginning of the haystack, or if the needle is
long and it is not found in a short haystack where few comparisons are
done and hence few case foldings were needed in the old implementation.

Benchmarking using tst_bench_qstringtokenizer tokenize_qstring_qstring
shows an improvement for the the total testcase and usually for each
individual test.

Fixes: QTBUG-100239
Change-Id: Ie61342eb5c19f32de3c1ba0a51dbb0db503bdf3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-22 18:05:44 +02:00
Mårten Nordheim
c633f4644c tst_QHash: Fix outdated rehash test
Inserting the same key repeatedly with QMultiHash will not
test rehashing behavior because in Qt6 those entries all
end up in a linked list.

Pick-to: 6.4
Change-Id: I78c45eed0f35a13af6d6da75d7189a6933750f13
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-22 17:34:51 +02:00
Sona Kurazyan
24dedaeaa1 QFuture: fix handling of cancelled continuation chain
To support cancellation of continuations attached via the parent future,
for each future returned by a continuation we store a pointer to its
parent (i.e. future the continuation is attached to). Later, before
executing a continuation, we go through chain of parents and check if
any of them is cancelled. However, if one of the parents is destroyed
while the chain is executing, the next continuations' parent pointers
will become invalid. So storing the parent pointers isn't safe.

This commit changes the logic of handling the cancelled continuation
chain in the following way:

- Instead of storing a parent pointer in the continuation future's data,
  we do the opposite: we store a pointer to continuation's future in the
  parent.
- When a future is cancelled, we mark all continuation futures in the
  chain with a flag indicating that the chain is cancelled.
- To guarantee that the pointers to continuation future's data don't
  become invalid, we clean the continuation (that stores a copy of its
  future's data and keeps it alive) only when the associated promise
  is destructed, instead of cleaning it after the continuation is run.

Fixes: QTBUG-105182
Fixes: QTBUG-106083
Pick-to: 6.2 6.3 6.4
Change-Id: I48afa98152672c0fc737112be4ca3b1b42f6ed30
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-21 01:18:31 +02:00
Johannes Kauffmann
2ce2992f5e tst_qprocess: remove unused loop counter
Change-Id: I1eece5a676cfa02fff27be01f25b07ddd82c40d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-20 19:09:31 +02:00
Thiago Macieira
864fbd6582 tst_QFile::setPermissions/Unix: test both chmod() and fchmod()
On Unix, we have the fchmod(2) system call that changes the permissions
of an open file descriptor. This commit adds a test for that, by not
closing the QFile before setPermissions().

Pick-to: 6.4
Change-Id: If5d5ef6220874ae8858efffd171255b9f20ed501
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-16 08:37:50 -07:00
Thiago Macieira
0193b4d219 tst_QFile::setPermissions: add QScopeGuard to remove temporary file
Pick-to: 6.4
Change-Id: If5d5ef6220874ae8858efffd17125580b5943cc2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-16 08:37:50 -07:00
Thiago Macieira
4b997d1851 QFileDevice: clear cached permissions on setPermission()
In theory, if we succeed, the permissions should be what we set, but
let's not make that assumption. And if we failed, it might be because
the file disappeared or something else, so re-stat()ing the file is a
good idea.

Pick-to: 6.4
Fixes: QTBUG-7211
Change-Id: If5d5ef6220874ae8858efffd171255506b7bbee0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-16 08:37:49 -07:00
Konrad Kujawa
ec2af0a9df Remove preprocessor conditionals for chrono include
__has_include(<chrono>) is always true, because C++11 chrono include
is required since 6.0.

Pick-to: 6.4 6.3 6.2
Change-Id: I50cb92571bf4f1f86e2f3f2b5f486dd3c3f30f4a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-16 08:09:05 +02:00
Mårten Nordheim
7447d73327 tst_QLocale: use fenv everywhere
And remove the platform-specific code.
fenv is available since c++11.

Change-Id: Ia5540be93b54117d4b5e9c7579100039c151dcc5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-15 23:41:51 +02:00
Allan Sandfeld Jensen
dc2927be4d Disable bad tests relying on wrong behavior
These tested results are all wrong and caused by internal overflows.

Note the behavior can not be fixed either as it involves moving an
already maximized QRect, which can not be done without overflow.

Change-Id: If35db68102889012c56eb149fe49bc48954d3422
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-09-15 12:07:02 +02:00
Edward Welbourne
6d10ecc699 Tidy up tst_QTimeZone
Its debug member can be set where it's declared, making the
constructor redundant.

Change-Id: Ic1195108766a6a86c3392a5bcf7f197ea31e8068
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-14 17:46:39 +02:00
Yuhang Zhao
40523b68c1 QWinRegistryKey: refactor
Refactor QWinRegistryKey to make it more modern and more
usable from outside.

Adjust the test for QWinRegistryKey to test the new functions,
merged with the original test.

Will port raw registry accessing code in QtBase to use this
class in follow-up commits. This change is the first step.

The long term goal is to port QSettings registry code to
this class instead of using raw Win32 APIs, however, there's
much more registry code in QSettings and migrate them to this
class needs a large refactor, so jsut leave it for now. Will
fix it in some future commit.

Change-Id: Iada2adb41b4d58e1b658ff6870a4b31ace479d43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-14 09:31:41 +08:00
Edward Welbourne
411b17150e Make time parsing accept zz as equivalent to z
Expand a test to cover millsecond format variants more thoroughly,
including a test for the new usage of zz. This applies to parsing the
complement to commit 0a36a7c1db173089c25ea09029505a589a1c59e5's change
to serialization. Fixed minor glitch in the serialization's doc, too.

[ChangeLog][QtCore][QDateTime] When parsing a datetime, the 'zz'
format specifier is now equivalent to 'z', as for serialization.

Change-Id: I1c5700064738d9c92d5e8ce10bff8050131e190f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-13 17:10:04 +02:00
Linus Jahn
cd37a773ca QCryptographicHash: Add getter for algorithm()
This can be helpful when you calculate multiple hashes, store them in a
vector and you want to know which result belongs to which algorithm.

[ChangeLog][QtCore][QCryptographicHash] Added getter algorithm().

Change-Id: Ifcf78536f215619a6e2e3035a95598327d0ed733
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-12 20:47:24 +02:00
Linus Jahn
358248b495 Make QCryptographicHash move constructible
This adds a move constructor, a move assignment operator and a swap
function to QCryptographicHash. This can (to name one example) be useful
when you want to store multiple hashes in a vector.

[ChangeLog][QtCore][QCryptographicHash] Added move constructor, move
assignment operator and swap() function.

Change-Id: Id54594fa69104ec25ad78581f962a021e85531c2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-09-12 18:47:23 +00:00
Mikolaj Boc
1d401e34ac Compile guard tests in corelib/kernel that need threading support
Some tests in corelib/kernel need threading support, but they are not
guarded against compilation if Qt is built without threading.
Such tests have been disabled in this case.

Change-Id: I2f5dc9582f2a59b6af2a9e56638b045dca06193d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-09-11 19:36:49 +02:00
Edward Welbourne
6a14ad4993 Perform uiLanguages() likely-adjusted processing purely on IDs
The collection of translations available to us need not have anything
to do with whether CLDR has matching data, so preserve the system UI
language list's entries as they are, rather than forcing them through
the QLocale constructor's exercise of likely sub-tag rules.

Instead, simply parse the given locale tags to QLocaleId instances and
use these in the likely-subtag processing to determine what other
entries to add to the list in addition to those supplied by the
operating system. Since going via QLocale did usually supply a
territory, that was included in the BCP 47 name, it's now possible for
the given entry to lack the language_territory name, so be sure to add
that if missing.

This incidentally reduces heap traffic and saves a fair deal of hidden
likely-subtag processing in calls to the constructor and bcp47Name().

Expand testing of QLocale::uiLanguages(), both plain and system.  In
the process, cross-link the two closely-related tests, move a comment
on one's _data() to the other's, where it really belongs, and add
reporting of the actual lists on failure. Enable MySystemLocale to
remember the requested locale's ID, before likely sub-tag processing,
so that we can make query() report results for language, script and
territory as requested, to ensure the fake system locale really does
match what was requested. The new german-britain test failed without
it, because there is no de-GB locale in CLDR.

Task-number: QTBUG-99531
Change-Id: Ide041577772c442a4413e3b9a590e11140c48f49
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-07 15:29:39 +02:00
Edward Welbourne
ebe9aca900 Simplify system locale management
Have QSystemLocale manage a stack, so that tests can install an
over-ride for the actual system-specific one reliably and restore the
system-specific one when finished. Leave the QSystemLocaleSingleton
out of the stack, all the same. In the process, mark the QDoc comments
for QSystemLocale all as \internal, since this is not public API.

Change-Id: I8faed49780215e42f32be10cf936c32bb46105bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-07 15:29:39 +02:00
Edward Welbourne
753bfdf6a1 Work round macOS's omission of en_DE from its own uiLanguages()
When the system locale is en_DE, macOS seems to think we should use
en_GB as the right translation. While that probably is a sensible
choice in the absence of an en_DE translation, we should definitely
use the en_DE translation if available, especially if en_GB isn't
available (which lead to a fall-back to de_DE, given later entries in
macOS's list). So prepend the system locale's own pcp47Name() if it
(isn't the C locale and) is missing from what we would otherwise have
used for uiLanguages(), after likely sub-tag perturbations.

Add a test simulating (some approximation to) what macOS was doing
that would have caught this case; and add a scope-guard reporter to
the test to report what shows up when lists don't match.

Fixes: QTBUG-104930
Pick-to: 6.4 6.4.0 6.3 6.2 5.15
Change-Id: I116234708067e1717d9157aebc84da76e04a9f38
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-07 13:29:39 +00:00
Mårten Nordheim
070446d5eb tst_qlocale: only restore the fp control masks we change
Certain masks are not supported outside 32-bit x86, and will assert on
x64.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-106000
Change-Id: Ic9f58e5a19c1db3309edeb5ec529e7a78c929665
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-09-07 13:15:27 +00:00
Alexey Edelev
33a12988e2 Guard windows-specific includes with Q_OS_WIN
Change-Id: I0a7c605c55c815c7220024f302f511e302005ab9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-07 14:39:25 +02:00
Mårten Nordheim
c76f7cbbcb QTextStream: Fix logical error in setEncoding
We only want to enable writing BOM if we have _not_ started
writing.

Fixes: QTBUG-106279
Pick-to: 6.2 6.3.2 6.4 6.4.0
Change-Id: Ibcbc101b931615fddb2507f01307bf9619772d7b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-07 01:09:31 +02:00
Volker Hilsheimer
bf3500a631 Fix cmake warnings from using deprecated PUBLIC_LIBRARIES
Pick-to: 6.4
Change-Id: I8d4f0d9e98edc4e06dda9f58e62197572b4cbdbc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-05 18:29:10 +02:00
Volker Hilsheimer
3b91bab465 Fix compiler warning: don't copy in ranged-for loop
Change-Id: If21f4e34324f33300009a427fb81e23ab49d4ad0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-09-03 19:10:42 +02:00
Mikolaj Boc
8e307a6cf9 Don't batch qmetaobject_compat
Batching the tests leads to one of the tests tst_qmetaobject and
tst_qmetaobject_compat not being registered in the batch. Attempts to
batch those together fail as batch test name is defined per-source,
which, in this rare case, is the same across the two targets.

Change-Id: I356931feabc004c39ba0b6863b5f64e06d739a58
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-02 19:22:32 +00:00
Thiago Macieira
0380dd5051 QMetaObject: pass the QMetaTypes in variadic invoke/newInstance
[ChangeLog][QtCore][Meta Object] QMetaMethod::invoke(),
QMetaObject::invokeMethod(), and QMetaObject::newInstance() are no
longer limited to 10 arguments.

[ChangeLog][QtCore][Meta Object] The use of the Q_ARG macro is no longer
necessary when using QMetaMethod::invoke(), QMetaObject::invokeMethod(),
and QMetaObject::newInstance(). Types may now be passed
directly. Similarly, Q_RETURN_ARG can be replaced by the free function
qReturnArg().

[ChangeLog][Potentially Source-Incompatible Changes]
QMetaMethod::invoke(), QMetaObject::invokeMethod(), and
QMetaObject::newInstance() no longer support passing forward-declared
types in the argument list (it was possible to pass them by
const-ref). From Qt 6.5 onwards, all types in the argument list must be
fully defined.

[ChangeLog][Potentially Source-Incompatible Changes] Attempting to use
the internal types QArgument, QReturnArgument, QGenericArgument, or
QGenericReturnArgument directly with QMetaMethod::invoke(),
QMetaObject::invokeMethod() or QMetaObject::newInstance() may fail to
compile. Those are internal types that were never meant to be used
directly and will be removed in Qt 7. If really necessary, ensure all
arguments passed to those functions are directly using those classes and
not mixed with Q_ARG and Q_RETURN_ARG. Implementations of bindings to
other languages should contact the Qt development mailing list to
discuss options.

Change-Id: I36b24183fbd041179f2ffffd1701e3e8e47e0fba
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-09-01 21:29:04 -03:00
Eirik Aavitsland
54aa7e75b8 QVariant: fix conversions of Q_ENUM that are QFlags<> to string
The doc of QMetaEnum::valueToKey() says to use ::valueToKeys() instead
for flag types.

Pick-to: 6.4
Change-Id: I48e5ba47324137f2ce2710f1d876e93e7c562e9f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-01 20:48:49 +02:00
Marc Mutz
812a0d3125 QAnyStringView: construct from any T implicitly convertible to QString/QByteArray
This includes QDBusReply, QProperty, and QStringBuilder expressions.

The new constructor subsumes the QStringBuilder case without requiring
jumping though hoops to delay the definition of the ctor the way we
had to for the explicit QStringBuilder constructor, so remove the
explicit QStringBuilder one again.

[ChangeLog][QtCore][QAnyStringView] Can now be constructed from
anything that implicitly converts to either QString or QByteArray.

Fixes: QTBUG-105389
Change-Id: I0e584dd3e20d591381609a3329ef47cec7356ecc
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-09-01 15:51:48 +02:00
Sona Kurazyan
50b05e3e2a Move qVersion() from qglobal.h to qlibraryinfo.h
Since qVersion() might be called also from C code, disable the parts of
qlibraryinfo.h that are relevant only for C++ code if __cplusplus is not
defined.

[ChangeLog][Potentially Source-Incompatible Changes] qVersion() is
moved from qglobal.h to qlibraryinfo.h, '#include <QtCore/QLibraryInfo>'
needs to be added where it's used.

Task-number: QTBUG-99313
Change-Id: I3363ef3fa4073114e5151cb3a2a1e8282ad42a4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-09-01 13:26:30 +02:00
Sona Kurazyan
b077c419ea Move QMacAutoReleasePool from qglobal.h to qcore_mac_p.h
And include qcore_mac_p.h where needed.

Task-number: QTBUG-99313
Change-Id: Idb1b005f1b5938e8cf329ae06ffaf0d249874db2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-09-01 13:26:30 +02:00
Thiago Macieira
f123212880 RCC: fix zlib compression when --no-zstd was specified
Since we had code to default to zstd as the default algorithm instead of
"Best", we ended up not compressing anything.

[ChangeLog][rcc] Fixed a bug that caused rcc not to compress files with
any compression algorithm if the --no-zstd option was present.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-106012
Change-Id: Ic6547f8247454b47baa8fffd170fddae429f82d2
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-08-31 16:55:00 -03:00
Alexandru Croitor
cd4a3a1dc7 CMake: Fix tst_qlibrary to work on macOS with debug builds
The test expects the helper libraries to contain the .dylib suffix
rather than .so.

Replace glob copying of the libraries (which depends on the underlying
shell) with manual copy calls.
This also ensures the libraries don't contain a _debug postfix in the
file name even in a debug build, which would break the tests.

Amends f8c1909320
Amends 1dff26dd95

Change-Id: I20361c33c4a1b9dd4b5273fcdb8cc79c9f266327
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-31 14:12:00 +02:00
Thiago Macieira
fe92b08065 QMetaObject: add a new, variadic invoke/invokeMethod/newInstance
[ChangeLog][QtCore][Meta Objects] The QMetaObject::invokeMethod() taking
a method name by string, QMetaObject::newInstance(), and
QMetaMethod::invoke() now support more than 10 arguments.

[ChangeLog][QtCore][Meta Objects] The use of the Q_ARG and Q_RETURN_ARG
macros is now optional with QMetaObject::invokeMethod(),
QMetaObject::newInstance(), and QMetaMethod::invoke(): the type name
will be obtained from the C++ type (the same as QMetaType). The function
qReturnArg() can be used in place of the Q_RETURN_ARG macro. The macros
are still useful in rare conditions where the type was typedef'ed from
its original name.

Change-Id: I36b24183fbd041179f2ffffd17022a2b48c7639b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-08-30 22:29:07 -03:00
Ivan Solovev
2e69ef6af9 Rest of QtBase tests: port away from deprecated methods
Small changes to fix builds with
QT_DISABLE_DEPRECATED_UP_TO >= 0x060500

Task-number: QTBUG-104858
Change-Id: Ia531a3cee97f13827e36b3d63f28eed879fe9a40
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-30 22:46:35 +02:00
Ivan Solovev
95542b386a tst_qobject: port away from deprecated methods
The patch includes the following replacements:
* QMetaType::type("name") -> QMetaType::fromType<Type>().id()
* QMetaProperty::type() -> QMetaProperty::typeId()
* QVariant::Type -> QMetaType::Type
* qRegisterMetaType<T>("name") -> qResigeterMetaType<T>()
* The static QMetaType::{load,save} methods are replaced with
  non-static versions
* Replace QCOMPARE(property.type(), QVariant::UserType) with
  QCOMPARE_GT(property.typeId(), QMetaType::User), because the
  deprecated type() method was treating each custom type
  (id >= QVariant::UserType) as QVariant::UserType, while the
  typeId() method simply returns the actual id.

As a drive-by: remove unneeded QMetaType registration tests
as we have tst_QMetaType to check it.

Task-number: QTBUG-104858
Change-Id: Ia08e002efdf07ff83366a5193164dba96a956f9a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-30 22:46:35 +02:00
Ivan Solovev
ad12d779cc tst_qvariant: port away from deprecated methods
The most common changes are:
* guard the tests for deprecated APIs with QT_DEPRECATED_SINCE
* QVariant(QVariant::Type) ctor -> QVariant(QMetaType) ctor
* QVariant::type() -> QVariant::typeId()
* QVariant::canConvert(int) -> QVariant::canConvert(QMetaType)
* QVariant::convert(int) -> QVariant::convert(QMetaType)
* QVariant::Type -> QMetaType::Type

Task-number: QTBUG-104858
Change-Id: I00584acb24d29b461faa1115f8f8d36a0b443883
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-30 22:46:34 +02:00
Ivan Solovev
91eec59b87 tst_qmetatype: port away from deprecated calls
The most common changes are:
* Replace QMetaType::type("name") with QMetaType::fromName("name").id()
  or QMetaType::fromType<Type>().id()
* QMetaType::typeName(int) -> QMetaType(int).name()
* QMetaType::typeFlags(int) -> QMetaType(int).flags()
* QMetaType::metaObjectForType(int) -> QMetaType(int).metaObject()
* The static QMetaType::{load,save} methods are replaced with
  non-static versions
* The static QMetaType::{create,destroy,construct, destruct} methods
  are guarded by QT_DEPRECATED_SINCE calls. The tests are also
  extended with non-static calls where they were missing. Fixed
  potential memory-leaks in these tests.

Add separate unit-tests for deprecated APIs and guard them with
QT_DEPRECATED_SINCE

As a drive-by: use nullptr instead of 0 in some places

Task-number: QTBUG-104858
Change-Id: I4b0cdd29bc197c186b835002372240aae3098c33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-30 22:46:34 +02:00
Thiago Macieira
db64694b4c tst_qlibrary.cpp: remove extraneous _data function
The test function itself is MIA.

Change-Id: Ie4bb662dcb274440ab8bfffd170a06fde5c1cd51
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-08-30 15:56:46 -03:00
Thiago Macieira
98e21f0979 QVariant: fix conversions of string keys to Q_ENUM that are QFlags<>
Since Qt 6.0, QMetaType stores the name obtained from the C++ compiler,
which means we know a type like Qt::Alignment by its proper, full name
of QFlags<Qt::AlignmentFlag>. However, the meta object records only the
bare name of the enumeration, not the full flags.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-105932
Fixes: QTBUG-96185
Change-Id: Ic6547f8247454b47baa8fffd170eab977e306377
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-08-30 18:56:46 +00:00
Tor Arne Vestbø
1bc7e9e77b Add QComHelper class for dealing with COM on Windows
Unifies our approach to calling CoInitializeEx and CoUninitialize,
removing a lot of boilerplate in the process, and also fixes a few
bugs where we would incorrectly balance our calls to CoInitializeEx
and CoUninitialize.

The optimistic approach of qfilesystemengine_win.cpp of calling
CoCreateInstance without initializing the COM library explicitly
has been removed, as calling CoInitializeEx should be a noop in
the situation where it's already been loaded.

Change-Id: I9e2ec101678c2ebb9946504b5e8034e58f1bb56a
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-08-29 15:39:34 +02:00
Thiago Macieira
f039147165 tst_QMap: avoid tripping MSVC debug-mode iterator assertions
It does a check to ensure you aren't comparing outside the container.

Fixes: QTBUG-106001
Pick-to: 6.2 6.3 6.4
Change-Id: Ic6547f8247454b47baa8fffd170eef346b7f4f24
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-08-28 11:04:14 -03:00
Ivan Solovev
88974b0a3e tst_qscopedpointer: port away from deprecated APIs
The QScopedPointer::take() call in comparison() test was used to
avoid a double-deletion error, because the test is creating two
QScopedPointer instances referencing the same memory.

Avoid the take() call by providing a custom DummyDeleter and
managing the memory by the extarnal std::unique_ptr.

As the test now has no test-cases for QScopedPointer::take()
calls, create a new test for this deprecated API, and guard
it with QT_DEPRECATED_SINCE checks.

Task-number: QTBUG-104858
Change-Id: Iecc28d44d76c9ce5835e6b1a1df7db30e2a9ca25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-27 02:07:54 +02:00