Commit Graph

11545 Commits

Author SHA1 Message Date
Tor Arne Vestbø
b5f972361a Introduce QWindow::paintEvent with QPA plumbing
The explicit paint event on QtGui and QPA level allows us to untangle
the expose event, which today has at least 3 different meanings.

It also allows us to follow the platform more closely in its semantics
of when painting can happen. On some platforms a paint can come in
before a window is exposed, e.g. to prepare the first frame. On others
a paint can come in after a window has been de-exposed, to save a
snapshot of the window for use in an application switcher or similar.

The expose keeps its semantics of being a barrier signaling that the
application can now render at will, for example in a threaded render
loop.

There are two compatibility code paths in this patch:

  1. For platform plugins that do not yet report the PaintEvents
     capability, QtGui will synthesize paint events on the platform's
     behalf, based on the existing expose events coming from the platform.

  2. For applications that do not yet implement paintEvent, QtGui will
     send expose events instead, ensuring the same behavior as before.

For now none of the platform plugins deliver paint events natively,
so the first compatibility code path is always active.

Task-numnber: QTBUG-82676
Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 16:44:53 +02:00
Richard Moe Gustavsen
ed813c19fa macOS: rename 'macintosh' style to 'macos'
Change the name/key of the style to 'macos'. Besides the
name 'macintosh' being archaic, we also need this
change to avoid creating 'macintosh' style folders
in QtQuickControls, now that we plan to use QPlatformTheme
also there to resolve the style.

[ChangeLog][Widgets][QStyle] The 'macintosh' style
has been renamed to 'macos'.

Change-Id: I14b8a8b4dbd369e7a7d16b94e4ad27e501e7e8d0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-26 16:37:43 +02:00
Sona Kurazyan
9efe2a8603 Fix QFuture::waitForFinished to wait until QFuture is started
Currently QFuture::waitForFinished() exits as soon as the future is not
in the running state. If the user calls it before
QPromise::reportStarted() is called, it will exit immediately, because
nothing is running yet. Fix the behavior to wait for the finished state.

[ChangeLog][Important Behavior Changes][QtCore] Fixed the behavior of
QFuture::waitForFinished() to wait until the future is actually in the
finished state, instead of exiting as soon as it is not in the running
state. This prevents waitForFinished() from exiting immediately, if at
the moment of calling it the future is not started yet.

Task-number: QTBUG-84867
Change-Id: I12f5e95d8200cfffa5653b6aa566a625f8320ca8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-08-26 16:37:43 +02:00
Sona Kurazyan
7d35e31efb Add back QByteArray's relational operators taking QString
QString still has the overloads of relational operators taking
QByteArray. Add back QByteArray's relational operators taking
QString for symmetry. See also the comments of
d7ccd8cb45 for more details.

[ChangeLog][EDITORIAL] Remove the changelog about QString/QByteArray
operators being removed. They're back.

Change-Id: I22c95e727285cf8a5ef79b3a4f9d45cb66319252
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 14:37:43 +00:00
Alex Trotsenko
fe4b246446 Synchronize QEventDispatcherWin32::processEvents() with QCoreApplication
QCoreApplication has a special internal mechanism to control whether
the event dispatcher should block after delivering the posted events.

To handle queued connections in nested loops properly, we should use
that functionality.

Pick-to: 5.15
Fixes: QTBUG-85981
Change-Id: I124179a23b26a995cf95ed379e97bfa62c95f42a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-26 11:08:15 +03:00
Volker Hilsheimer
fab8933d5b Don't skip QFileDialog retranslatability test on macOS
The test explicitly asks for a non-native file dialog, which works on
macOS as well.

Change-Id: I964c6d98501b4207c2b6c2ce1df39f654c801a43
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-26 03:45:30 +02:00
Marcel Krems
8dd50ef206 Remove deprecated qGenericMatrix{To,From}Matrix4x4 functions
Change-Id: I3b43d48f5324f3a1f2fff8e22bb4f9563d3ea997
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 01:49:24 +02:00
Thiago Macieira
ad5a65b6a2 QStandardPaths/Unix: improve the XDG_RUNTIME_DIR creation/detection
First, use QT_MKDIR instead of QFileSystemEngine::createDirectory(), as
the latter can't create a directory with the right permissions. That
would allow an attacker to briefly obtain access to the runtime dir
between the mkdir() and chmod() system calls.

Second, make sure that if the target already exists that it is a
directory and not a symlink (even to a directory). If it is a symlink
that belongs to another user, it can be changed to point to another
place, which we won't like.

And as a bonus, we're printing more information to the user in case
something went wrong. Sample outputs:

 QStandardPaths: runtime directory '/root' is not owned by UID 1000, but a directory permissions 0700 owned by UID 0 GID 0

 QStandardPaths: runtime directory '/dev/null' is not a directory, but a character device, socket or FIFO permissions 0666 owned by UID 0 GID 0

 QStandardPaths: runtime directory '/etc/passwd' is not a directory, but a regular file permissions 0644 owned by UID 0 GID 0

 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-tjmaciei'
 QStandardPaths: runtime directory '/tmp/runtime-tjmaciei' is not a directory, but a symbolic link to a directory permissions 0755 owned by UID 1000 GID 100

Pick-to: 5.15 5.12 5.9
Change-Id: Iea47e0f8fc8b40378df7fffd16248b663794c613
Reviewed-by: David Faure <david.faure@kdab.com>
2020-08-25 16:13:44 -07:00
Volker Hilsheimer
872e37b2ff Implement QAbstractFileIconProvider to use theme and mime databases
This doesn't give useful defaults on all platforms; icon themes are not
provided on platforms other than Linux, and the mime database doesn't
always return user-friendly names based on file names.

However, both icon themes and the mime database can be customized by
application developers by shipping a data file side-by-side with the
application, without the need for reimplementing the provider class.

Change-Id: Ie4b18ac1b861e2da64f01d1f209986b27fbe6bd5
Task-number: QTBUG-66177
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-26 01:13:19 +02:00
Andrei Golubev
afd34d74b8 Fix QPromise snippets: use QScopePointer instead of QPointer
Change-Id: I2b863e43eb227a80ded3422ca57bd5f5d4209858
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-08-26 01:12:50 +02:00
Giuseppe D'Angelo
049d8892ea QRegularExpression: do not assume QStringViews are NUL terminated
The convenience API used to look up the index of a named capturing
group expects NUL terminated strings. Therefore, we can't just
use it together with QStringViews, which may be not. Use the
non-convenience API instead.

Pick-to: 5.15
Change-Id: I25ca14de49b13ee1764525f8b19f2550c30c1afa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-25 23:09:09 +00:00
Lars Knoll
acbf9a858b Cleanup QTypeInfo
Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6.
Also remove sizeOf, it's unused, and we have QMetaType for that if
required.
Remove all typeinfo declaractions for trivial types, as the default
template covers them correctly nowadays.

Finally set up a better default for isPointer, and do some smaller
cleanups all over the place.

Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 01:03:22 +02:00
Volker Hilsheimer
b77a3f47c9 Rename confusingly named QFont/QPalette::resolve overloads
Having three methods with the same name doing different things is
unnecessarily confusing, so follow the standard naming convention in
Qt and call the getter of the resolve mask resolveMask, and the setter
setResolveMask. These methods were all documented as internal.

The publicly documented resolve() method that merges two fonts and
palettes based on the respective masks remains as it is, even though
'merge' would perhaps be a better name.

Change-Id: If90b1ad800834baccd1dbc38fc6b861540d6df6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-25 17:59:10 +02:00
Robert Loehning
c0d0949448 QLineF: Don't try calculating a unit vector when length is null
It's undefined and causes a division by zero.

Fixes: oss-fuzz-24561
Pick-to: 5.12 5.15
Change-Id: Idebaba4b286e3ab0ecb74825d203244958ce6aec
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-25 17:59:10 +02:00
Fabian Kosmale
f325bac02e tst_qobject: Enable build with CMake
Change-Id: Ia2b324d0e5aa88ea9a71bb040a740f359e11f2ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-25 09:13:46 +02:00
Mårten Nordheim
0871a7b5a2 tst_QNetworkDiskCache: fix setCookieHeader
It wouldn't grab the cached entry since it was not deemed
"fresh" (and would never be fresh because we didn't know when it
originated from or when it expired). But the test still passed because
the reply produced a "finished" signal which ended the loop, but the
"finished" signal was due to an error which was unchecked.

Change-Id: I6ad271aa621bdb4a48b74bc8fd64c7e2caa8f179
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-08-25 09:09:42 +02:00
Marcel Krems
fcc25b11bb QPrinterInfo: Remove deprecated methods
Change-Id: I5089bc23308a4348dc21122dfa000d5ca6e3938d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-25 06:48:28 +02:00
Shawn Rutledge
c7f7279969 Introduce QEvent::isPointerEvent()
This makes high-level event dispatching easier: for example in Qt Quick,
all pointer events should eventually be delivered to items in a similar way.

Implemented in a similar way as d1111632e2.

Change-Id: I2f0c4914bab228162f3b932dda8a88051ec2a4d7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-25 06:34:01 +02:00
Volker Hilsheimer
fb9ec8ad44 Move QFileSystemModel into QtGui
This requires a QAbstractFileIconProvider in QtGui, as the standard
QFileIconProvider depends on QStyle, and cannot be moved out of
QtWidgets.

QAbstractFileIconProvider returns strings for file types, but returns
no icons yet. Support for a default icon set might be added in a
follow-up commit.

Change-Id: Ib9d095cd612fdcf04db62f2e40709fcffe3dc2b7
Fixes: QTBUG-66177
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-25 06:33:44 +02:00
Karsten Heimrich
a735038376 Move QStateMachine from QtCore to QtScxml
Task-number: QTBUG-80316
Change-Id: I2ee74110fd55e94d86321d3b3dc5bb8297424ed4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-24 20:10:25 +02:00
Mårten Nordheim
43f01ec2e5 QByteDataBuffer: add readPointer functionality using QByteArrayView
While it could be done before it's nice to not have a custom "local"
struct or the size in an out-parameter.

Change-Id: Ie910f7060b1dadf037312d45e922f8e2deafe3ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 17:44:08 +02:00
Mårten Nordheim
467d215b32 Disable cipherstring-setting test for schannel
And put a note about it in the documentation

Change-Id: I29126e4a80f83c256190e03b8fe01f3c869fd46d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-24 17:43:39 +02:00
Mårten Nordheim
5283be1f73 tst_qnetworkreply: Extend httpConnectionCount to test HTTP/2 and TLS
HTTP/2 is only used initially before it transitions to using HTTP/1.1,
and in this case the amount of connections established should also
reach 6.

Change-Id: I300e171e46c846df1730c07469ea85a51cecfb63
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-24 17:43:30 +02:00
Alex Trotsenko
556a7e7318 QIODevicePrivate: rearrange class members
As this class is a subject of the library hook data, there must be a
solid understanding of the member's alignment and padding across
different architectures. By reordering the layout, this patch provides
a clearer way of adding new members to the class.

Bump the TypeInformationVersion field in qtHookData, to notify the
Qt Creator developers that the offset of QFilePrivate::fileName was
changed and dumpers should be adapted.

Change-Id: Ied8b69bdeb9da50ff05aba2107bc75509674b18e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 14:50:56 +03:00
Alex Trotsenko
b3310426b6 tst_QLocalSocket: fix wrong slot name
Suppress the warning:

QObject::connect: No such slot LocalSocket::slotError(QLocalSocket ...

Pick-to: 5.15
Change-Id: Ia08505ebc85d4070582c7ddaae8b581d394dbb80
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-08-24 14:50:56 +03:00
Marcel Krems
41a716ebbf QSqlite: Don't crash after binding too many placeholders
When you bind more values than the query has placeholders,
indexes will be empty which causes an out-of-bounds access in indexes.first.

We can't check the parameter count because of multiple placeholders with the same name,
so we check if the name is null.

Tested with SQLite and PostgreSQL

Pick-to: 5.15
Change-Id: Id5d4bd15d7ed16603f47b87d6e0bf811a20157d8
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-08-24 13:50:55 +02:00
Shawn Rutledge
38806273e5 Remove QEventPoint::event() in favor of device()
event()->device() was the most common use case anyway.

The idea that the "parent" of a QEventPoint is the QPointerEvent
interferes with the ability to copy and move event objects: the parent
pointers are dangling unless we use the QPointerEvent subclass
destructors to set the points' parents to null.  Since there is no move
constructor, even returning a QEventPoint from a function by value
results in destroying the temporary instance and copying it to the
caller's space.  So the parent pointer is often useless, unless we do
even more work to maintain it when the event moves.

If we optimize to avoid copying QEventPoints too much (and perhaps
enable exposing _mutable_ points to QML) by storing reusable instances in
QPointingDevice (which is the current plan), then the actual parent will
no longer be the event.  Events are usually stack-allocated, thus
temporary and intended to be movable.

Change-Id: I24b648dcc046fc79d2401c781f1fda6cb00f47b0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-24 13:50:55 +02:00
Lars Knoll
e7e7540aec Deprecate int based convert/canConvert
Better to provide the correct meta type to convert to.

Change-Id: I8e0d46e4ba482186201c157e302c03874bd38e7b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:19:18 +02:00
Lars Knoll
1697fbdf05 Deprecate the static int based API in QMetaType
And remove one of the type id to name mapping that still
existed in QMetaType. QMetaTypeInterface can provide that,
so there's no need to have a second copy of the data.

qMetaTypeTypeInternal() can still map all the names of all
builtin types to ids. That functionality is for now still
required by moc and can't be removed yet.

Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-24 00:19:05 +02:00
Lars Knoll
92b3767632 Remove refcounting of QMetaTypeInterface
It's only used for dynamic types in DBUS and QML, where we control
things good enough to be able to handle the lifetime of those
interfaces there.

Change-Id: Ia7f8970d17a85b195db85fcdc2d8f1febd8753f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:18:58 +02:00
Lars Knoll
9c501b0670 Remove an unused enum value and document another one
Change-Id: If9fed4f20242d789c1251b8798d7378d2d6911a6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:18:45 +02:00
Lars Knoll
c7ce1bc05c Move conversions to and from *Iterables into QMetaType
Those were not yet supported by QMetaType.

Change-Id: I9f85476049f200e35939ac58ef7e8b4e7cbe0b77
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-24 00:18:31 +02:00
Lars Knoll
9d36032370 Implement QMetaType::canConvert() and use it in QVariant
Use the fact that we return the conversion function as a lambda
to find out reliably whether a conversion between two types
can be done.

This requires some minor adjustments to our tests:

* Nothing can convert to an unknown type and vice versa
* Adjust results to the fact that we don't convert from char
  to QString anymore (where the old method was incorrect)
* QStringList->QString requires some adjustments, as we only
  convert if the string list has exactly one element. For now
  we return true in canConvert(), but the conversion behavior
  in this case is something we should rethink, as it is very
  surprising.

Change-Id: I3f5f87ee9cb99d690f5a7d13b13d6a6313d8038e
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-24 00:18:24 +02:00
Lars Knoll
fefb1c1362 Move enum conversions over into QMetaType
Take the opportunity to properly handle the underlying type
(size and signed vs unsigned).

Change-Id: I0cb8cf40acac6de03c24ed3fe570db68268952c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:17:50 +02:00
Lars Knoll
4ccf76ff53 Start porting conversions over from QVariant to QMetaType
This will ensure full symmetry in what QVariant and
QMetaType support. With this done, QVariant will become
simply a container that can hold any QMetaType with fully
symmetric functionality between both.

Change-Id: I796d4368a2bc0f08cf4f70f4465ed6a0e07bdd76
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-24 00:17:33 +02:00
Lars Knoll
524edc7363 Clean up QVariant::Private::Data
Remove all the internal members of the union. Instead replace
it with raw storage (uchar[]) aligned to max_align_t.

Place all accesses to the internal members with get<> methods
for consistency.

Change-Id: Icebf46b90c9375aa6ea0b5913b2132608e8c223d
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-24 00:17:05 +02:00
Lars Knoll
a701b0ed30 Fix compiler warnings in autotest
Change-Id: I891b31fa86c6e0e8bcbfb6e6760e093d33598b47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:17:05 +02:00
Lars Knoll
76e8e8e9c8 Always use the variants internal space if possible
There's no point in storing small types with an external
refcount, even if they aren't movable. Simply copying
the type should be faster in pretty much all cases, while
this uses less memory.

Change-Id: I127474f8e3c5fa042f530684f9d5bfccbba134ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:17:04 +02:00
Lars Knoll
0daa9dbfc4 Generate less code when creating QMetaTypeInterfaces
There is no need to generate wrapper functions for equals,
lessThan or debugStream for pointer types, as those can
easily be handled by a few lines of code in QMetaType itself.

Change-Id: If79b3bc3a629249c1d17c9e592202f08b59f80ef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:17:04 +02:00
Lars Knoll
bd64f9397a Refactor Q*Iterable
Refactor the methods retrieving data in Q*Iterable so
that we don't return pointers with unclear ownership. Instead,
copy the data into a out pointer provided by the caller.

This also means there is no need for the metatype flags
anymore and we can remove those.

Change-Id: I517de23a8ccfd608585ca00403aca0df2955f14b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-24 00:17:04 +02:00
Lars Knoll
49f2253be3 Cleanups in the Iterable classes
Store a QMetaType, not a meta type id in the classes.

Change-Id: If27a60512a46fa029cc914d65b8cad7f89d7f3b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:17:04 +02:00
Lars Knoll
6d95ffe996 Cleanups in QSequentialIterable
Remove the old revision of the interface, this is not
required with Qt 6 anymore, as everything is being
recompiled anyway.

Change-Id: I66070c4dc6b5e2a6d22f5a9ebea7688ed38333fe
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-08-24 00:17:04 +02:00
Lars Knoll
ed8acbeb7c Automatically register data/debug stream operations in QMetaType
And remove the old manual registration code for those operators.

Add some special handling for long/ulong, as these types could be
streamed as a QVariant so far, but are not directly streamable
through QDataStream.

[ChangeLog][QtCore][QMetaType] The QMetaType::registerStreamOperators()
and QMetaType::registerDebugStreamOperator() methods have been
removed. The streaming operators for a type are now automatically
registered together with the type registration.  This implies that the
operators should be visible wherever the type is visible and being used.

[ChangeLog][Behavior Incompatible Changes] Because the QDataStream and
QDebug serialization operators are automatically registered with
QMetaType, the declarations of those functions must be present at any
point where the type is used with QMetaType and QVariant.

Change-Id: I4a0732651b20319af4a8397ff90b848ca4580d99
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-24 00:17:03 +02:00
Marc Mutz
e2be114f64 [trivial] tst_qstringapisymmetry: remove remnants of from() experiment
Reduce the scopes so that also the result of 1-arg-sliced() can be
called 'sliced'.

Change-Id: Ie156f76838f8650d6926d3c198007aaf12f90734
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-23 10:38:16 +02:00
Marc Mutz
60dd5451a2 Port QLatin1String to qsizetype and add narrow-contract substring functions
QLatin1String::mid() etc were changed from narrow to wide contract,
but the narrow-contract replacements weren't added. This blocks using
the narrow-contract functions in QStringTokenizer.

As a drive-by, Q_REQUIRED_RESULT -> [[nodiscard]] and Q_DECL_CONSTEXPR
-> constexpr. Also centralize most Q_ASSERT()s in a single function,
verify(), in an attempt to reduce the amount of string data generated
from the asserts in assertive builds.

[ChangeLog][QtCore][QLatin1String] Added from(), sliced(), first(n),
last(n) functions.

[ChangeLog][QtCore][QLatin1String] size_type/size() is now qsizetype
(was: int). This makes QLatin1String(ptr, 0) ambiguous now between the
(ptr, ptr) and (ptr, qsizetype) constructors.

Change-Id: Ie195f66ae1974eb0752c058aa9f3b0853ed92477
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-23 10:38:01 +02:00
Edward Welbourne
14f3f419b0 Fix crash on serializing default-constructed QTimeZone
The serialization code neglected to check against null.  Sinze zones
are saved either by IANA ID or in our special OffsetFromUtc format,
representing an invalid zone by a string that cannot possibly be a
valid IANA ID will do.

Fixes: QTBUG-86019
Pick-to: 5.15
Pick-to: 5.12
Change-Id: I6882026403d00f8b254aab34c645f1cf8f9fcc2d
Reviewed-by: Taylor Braun-Jones <taylor@braun-jones.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-23 09:55:29 +02:00
Marcel Krems
9a921d78e8 Fix CaseSensitivity handling for QRegularExpression in QSortFilterProxyModel
setFilterRegExp retains the caseSensitivity() while setFilterRegularExpression did not.
Change setFilterRegularExpression to also retain the case sensitivity.

Fixes: QTBUG-83313
Pick-to: 5.15
Change-Id: I46f494d320aee99d50612f01f63558c693276989
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-08-23 02:35:37 +02:00
Tor Arne Vestbø
6ece7dd09a Fix warnings in tst_moc
Change-Id: I4cbc851e59febdc533c02fb4b95d2924348086b4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 01:18:13 +02:00
Andy Shaw
7ec818e74a Interbase: Fix tests when running against Firebird
Change-Id: Ibfcf6b557aed3b0cd2e0ece5cf122819a1acc0c1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-23 00:22:04 +02:00
Andy Shaw
37c68503cb QFont: Extend the string description to include the missing elements
This extends to/fromString to include style strategy, capitalization,
letter and word spacing and stretch. QFont::fromString() keeps
compatibility with strings from earlier versions as well.

Fixes: QTBUG-67687
Change-Id: I5e95a58f1cd850214af2a7d8906a214facd4e661
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-08-22 22:21:35 +00:00
Edward Welbourne
16e546e32f Properly deprecate Qt::MidButton in favor of Qt::MiddleButton
MidButton had its // ### Qt 5: remove me
upgraded to Qt 6 at 5.0; but it dates back to 4.7.0

Replace the many remaining uses of MidButton with MiddleButton in the
process.

Pick-to: 5.15
Change-Id: Idc1b1b1816673dfdb344d703d101febc823a76ff
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-22 21:47:36 +02:00
Alex Trotsenko
a41c61fb2d QIODevice: implement a "zero-copy" strategy for buffered writes
It works as follows:

  - user calls write(const QByteArray &);
  - this function keeps a pointer to the chunk and calls a regular
    write(data, len);
  - write(data, len) calls a virtual writeData();
  - subclass calls a new QIODevicePrivate::write();
  - QIODevicePrivate::write() makes a shallow copy of
    the byte array.

Proposed solution is fully compatible with existing subclasses.
By replacing a call to d->writeBuffer.append() with d->write(),
subclasses can improve their performance.

Bump the TypeInformationVersion field in qtHookData, to notify the
Qt Creator developers that the offset of QFilePrivate::fileName was
changed and dumpers should be adapted.

Change-Id: I24713386cc74a9f37e5223c617e4b1ba97f968dc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-08-20 18:24:15 +03:00
Karsten Heimrich
2766322de3 Move QStringRef and remains to Qt5Compat
Export some private functions from QUtf8 to resolve
undefined symbols in Qt5Compat after moving QStringRef.

Task-number: QTBUG-84437
Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-20 00:58:13 +02:00
Fabian Kosmale
a2cec17407 QMetaType: specialize typenameHelper for std::pair
The string representation of std::pair<T1,T2> is now always
"std::pair<T1,T2>". This is in line with how we translate QPair,
avoiding typename mismatches that would previoulsy occur, because the
full name of pair on libc++ was "std::__1::pair".

Fixes: QTBUG-84924
Change-Id: Ia6c044a7327d69e4b4f4a31496c6b2408d85ebb9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-19 19:17:46 +02:00
Cristian Adam
ddf8b2770c tst_qplainttextedit: Do not use paste() method with no clipboard
On QNX the test fails to build because there is no clipboard feature
and the code is using the paste() method which doesn't exist.

Task-number: QTBUG-83202
Change-Id: Ie070ec8850b528e122e954074a1a0a3c78a14248
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 12:46:10 +02:00
Jarek Kobus
765f503b1e QtConcurrent: Introduce runWithPromise()
The differences to run() method:
1. The passed function should have additional
   argument QPromise<T> &, declared as a first argument.
2. The return value of the function must be void.
   Result reporting should be done through
   passed QPromise<T> &promise argument.
3. By default, runWithPromise() doesn't support functors
   with overloaded operator()().
   In case of overloaded functors the user
   needs to explicitly specify the result type
   as a template parameter passed to runWithPromise,
   like:

   struct Functor {
       void operator()(QPromise<int> &) { }
       void operator()(QPromise<double> &) { }
   };

   Functor f;

   runWithPromise<double>(f); // this will select the 2nd overload

Task-number: QTBUG-84702
Change-Id: Ie40d466938d316fc46eb7690e6ae0ce1c6c6d649
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-19 12:46:10 +02:00
Giuseppe D'Angelo
2ba1d540e6 QMultiMap: fix remove(Key, T) when key/value belong to the map
Just like any other container, it's legitimate for the user to
pass key/values belonging to the same container.
Q(Multi)Map::remove(Key) are already safe (either they call
erase() directly on std::(multi)map, where it does the right thing,
or they skip elements while detaching).
However, QMultiMap::remove(Key, T) wasn't safe in this regard
(the implementation is hand rolled), so take copies before start
erasing.

Change-Id: I87767d608b83216a6ff264fb6c8f145fdb5934f8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-19 01:45:19 +02:00
Andrei Golubev
4bf8e82d41 Add QArrayDataPointer::freeSpace*() functions
Added functions that tell how much free space is available at the
beginning and at the end of the storage

Updated preconditions of operations to use freeSpace* functions

Also, changed casts uint(this->size) to size_t(this->size)

Task-number: QTBUG-84320
Change-Id: Iad94c1060a00f62068da9d1327e332a00d4f4109
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-18 12:55:38 +02:00
Andrei Golubev
56f1208f9e Separate exception safety primitives from operations
Refactored certain bits of qarraydataops.h: picked exception-related
building blocks and put them into one place, (somewhat) documented
the usage, added tests

Personally, the existing code seemed rather complicated to analyze
(and do mental experiments for corner cases), especially when staring
at the whole thing for a while or "returning back" from some other work
and I still have my doubts that everything works correctly. Testing the
building blocks that are used should:
a) increase trust into existing code (provided the usage is correct)
b) give more use cases of how to use the building blocks, which in turn
   would allow to compare and contrast tests vs implementation

Task-number: QTBUG-84320
Change-Id: I313a1d1817577507fe07a5b9b7d2c90b0969b490
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-18 12:55:38 +02:00
Andrei Golubev
5247af96e3 Refine precoditions and logic of array operations
Updated insert() methods:
* Refined Q_ASSERT() checks
* Fixed implementation issues (some of which resulted in
  actual crashes)
* Allowed to insert at the end. This is safe as far as I can
  tell and actually would allow to simplify considerable chunks
  of code (mainly, copyAppend versions to just return
  insert at the end)

Updated tests accordingly

Change-Id: I0ba33ae5034ce8d5ff95b753894e95d71ba00257
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-18 12:55:38 +02:00
Andrei Golubev
48911869cb Extend array operations tests with extra cases
Extended existing tests with QArrayData's allocation options

Added extra tests on array operations covering append, insert,
emplace, erase and truncate. "Raw" QArrayDataPointer is used instead of
test-specific SimpleVector to check the behavior without some custom
logic in-between

The change targets future updates to array operations in the light of
prepend optimization: as the array operations would become more complex,
these tests should give a much better coverage (specifically due to
likely non-trivial implementation details and optimizations)

Task-number: QTBUG-84320
Change-Id: I6581e2cb48f81b82ee5052d1dcea3da2819df47a
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-18 12:55:38 +02:00
Paul Lemire
6a2c89c043 rhi: sanityCheckGraphicsPipeline handle no vertex attributes
It is a valid use case to have a vertex shader with no
vertex attributes. Using gl_VertexID or gl_InstanceID
is enough to generate vertex data out of thin air.

Change-Id: If7689914624a84723923fd2d7aef355bda592e24
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-08-18 07:58:50 +02:00
Laszlo Agocs
81159cf3f7 rhi: Enable msaatexture manual test on OpenGL
...now that a recent path enables MultisampleTextures for ES >= 3.1 and
GL 3.x and up.

Just need to make sure the .qsb contains something for OpenGL as well.

While we are at it, make updated .qsb files for all the commonly used
shaders since what we had before was version 4. Bump them to version 5.

Change-Id: If2040f4894e6360d1ebd5daf7e698508e5e6e42e
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-08-17 18:20:36 +02:00
Volker Hilsheimer
c54a5b8380 Introduce QWidget::setScreen
Follows the QWindow semantics, and is a replacement for creating
a QWidget with a QDesktopScreenWidget as the parent.

We can now remove much of the special handling of QDesktopWidget and
the Qt::Desktop window type, and get rid of QDesktopScreenWidget.

Add a manual test that allows local testing. Our CI environments
only have a single screen, and no multi-head display server setup
which is the primary case where QWidget::setScreen is interesting.
For the more common case of a virtual desktop, QWidget::setScreen
has no real impact (just as QWindow::setScreen doesn't).

Change-Id: Id0099e069d316741bacd8c795c396ccad37be297
Fixes: QTBUG-85483
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-17 15:08:39 +02:00
Lars Knoll
5076ce54be Fix compiler warning about implict cast to double
Change-Id: I80497efedebed9579882d31d3eda13bd88c80c94
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-16 14:54:17 +02:00
Lars Knoll
9fb2db1ccc Fix test with cmake build
Change-Id: I9153296dbd687abb65464638fd519d466f600e84
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-16 11:53:29 +02:00
Lars Knoll
3ef8ec2ee1 Constrain the data stream operators for containers
Check that we can successfully instantiate the data
stream operator for a container before we actually try.

This is required so we can automate registration of debug
stream operators with QMetaType.

Change-Id: Ib100a5242470d7fc8067058cc4d81af2fa9354b0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-15 14:43:30 +02:00
Lars Knoll
8ad9e81694 Constrain the debug stream operators for containers
Check that we can successfully instantiate the debug
stream operator for a container before we actually try.

This is required so we can automate registration of debug
stream operators with QMetaType.

Change-Id: I3943e7a443751d250c33b2ca1b9cf29207cfe6c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-15 14:43:23 +02:00
Lars Knoll
67f04fa060 Deprecate QVariant::Type uses in QSqlField
Add metaType()/setMetaType() methods to be used instead
of the type() methods taking a QVariant::Type.

Change-Id: Ieaba35b73f8061cd83288dd6b50d58322db3c7ed
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-15 10:56:33 +02:00
Lars Knoll
8929c0a355 Remove QVariant(int type, void *data, ...) constructor
It was marked internal anyway. Use the constructor taking a
QMetaType instead.

Change-Id: I15b9cd0911aac063a0f0fe0352fa2c84b7f7c691
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-15 10:56:29 +02:00
Allan Sandfeld Jensen
6f0df02d00 Replace Qt CONSTEXPR defines with constexpr
Both normal and relaxed constexpr are required by our new minimum of
C++17.

Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-14 15:52:58 +02:00
Mårten Nordheim
d40f88e8d2 QDecompressHelper: Introduce zstd support
Also take this opportunity to reshuffle the content-encodings in the
intended ordering since the ordering is used to signify priority.

Task-number: QTBUG-83269
Change-Id: I022eecf1ba03b54dbd9c98a9d63d05fb05fd2124
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-14 13:17:11 +02:00
Edward Welbourne
9ee554ac1d qglobal.h: remove deprecated global functions
Since 5.0 - qMalloc(), qFree(), qRealloc(), qMemCopy(), qMemSet()
Since 5.15 - qsrand(), qrand()

Change-Id: I74fa3d17b05521271c3dc563fc85a5b133289ce3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-14 09:59:36 +02:00
Allan Sandfeld Jensen
d4a73d4255 Another round of using noexcept instead of pre-C++11 defines
A few new files were added with old-school defines.

Change-Id: Ieb2c71e094e55102f3f39fb9551823f36863f5f4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-08-13 19:58:40 +02:00
Frederik Gladhorn
d12afeff40 Set default redirect policy to NoLessSafeRedirectPolicy
Not following redirects is not a feature, but just a hastle for everyone.

The main issue with switching this default is that applications that
actually do manual redirect handling will break in various ways.

FollowRedirectsAttribute was removed as it no longer serves any
purpose beyond duplicating the default value.

[ChangeLog][Network] QNetworkAccessManager now follows redirects by
default with the NoLessSafeRedirectPolicy.
[ChangeLog][Potentially Source-Incompatible Changes]
QNetworkRequest::FollowRedirectsAttribute was removed and has been
superseded by QNetworkRequest::RedirectsPolicyAttribute

Fixes: QTBUG-85901
Change-Id: Ic5b776180a4b84ac4fc895158bb5a66a3c91a042
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-13 19:58:19 +02:00
Sona Kurazyan
1df02b5f98 Fix conversions to JSON from QVariant
After reimplementing Qt JSON support on top of CBOR, there were
unintended behavior changes when converting QVariant{, List, Map} to
QJson{Value, Array, List} due to reusing the code for converting
QVariant* types to CBOR types, and from CBOR types to corresponding JSON
types. In particular, conversions from QVariant containing QByteArray to
JSON has been affected: according to RFC 7049, when converting from
CBOR to JSON, raw byte array data must be encoded in base64url when
converting to a JSON string. As a result QVariant* types containing
QByteArray data ended up base64url-encoded when converted to JSON,
instead of converting using QString::fromUtf8() as before.

There were also differences when converting QRegularExpression.

Reverted the behavior changes by adding a flag to internal methods for
converting CBOR to JSON, to distinguish whether the conversion is done
from QVariant* or CBOR types. These methods now will fall back to the old
behavior, if the conversion is done using QJson*::fromVariant*().

Additionally fixed QJsonValue::fromVariant conversion for NaN and
infinities: they should always convert to QJsonValue::Null. This works
correctly when converting from variant to QJsonArray/QJsonObject, but has
been wrong for QJsonValue.

Added more tests to verify the expected behavior.

[ChangeLog][Important Behavior Changes] Restored pre-5.15.0 behavior
when converting from QVariant* to QJson* types. Unforeseen consequences
of changes in 5.15.0 caused QByteArray data to be base64url-encoded; the
handling of QRegularExpression was also unintentionally changed. These
conversions are now reverted to the prior behavior. Additionally fixed
QJsonValue::fromVariant conversions for NaN and infinities: they should
always convert to QJsonValue::Null.

Fixes: QTBUG-84739
Change-Id: Iaee667d00e5363906eedbb67948b7b39c9d0bc78
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-13 19:36:58 +02:00
Lars Knoll
048debe8f9 Restrict QVariant::isNull() behavior
isNull() would forward to the contained type and check that type's
isNull() method for some of the builtin types. Remove that behavior
and only return true in isNull(), if the variant is invalid, doesn't
contain data or contains a null pointer.

In addition, implement more consistent behavior when constructing
a QVariant using the internal API taking a copy from a void *.
isNull() should return true in both cases. This mainly changes behavior
for some corner cases and when using our internal API.

[ChangeLog][Important Behavior Changes] QVariant::isNull()
no longer returns true when the variant contains an object of some
type with an isNull() method, that returns true for the object;
QVariant::isNull() now only returns true when the variant contains
no object or a null pointer.

Change-Id: I3125041c4f8f8618a04aa375aa0a56b19c02dcf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-13 08:48:32 +02:00
Lars Knoll
4a69cd7f72 Restrict comparison of variants
Comparing two variants will not try to convert the types
of the variant anymore. Exceptions are when both types are
numeric types or one type is numeric and the other one a
QString. The exceptions are there to keep compatibility with
C++ and to not completely break QSettings (which needs automatic
conversions from QString to numeric types).

[ChangeLog][Important Behavior Changes] Comparing two
variants in Qt 6 will not try attempt any type conversions before
comparing the variants anymore. Instead variants of different type
will not compare equal, with two exceptions: If both types are numeric
types they will get compared according to C++ type promotion rules. If
one type is a QString and the other type a numeric type, a conversion
from the string to the numeric tpye will be attempted.

Fixes: QTBUG-84636
Change-Id: I0cdd0b7259a525a41679fb6761f1e37e1d5b257f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-13 08:48:19 +02:00
Lars Knoll
50c96c17b6 Use the new support for comparisons in QMetaType for QVariant
Remove the compare method in the QVariant::Handler struct. Rely
on the generic support provided by QMetaType instead.

[ChangeLog][Important Behavior Changes][QVariant] QVariant will now use builtin support in
QMetaType to compare its content. This implies a behavioral change
for some graphical types like QPixmap, QImage and QIcon that will
never compare equal in Qt 6 (as they do not have a comparison
operator).

Change-Id: I30a6e7116c89124d11ed9052537cecc23f78116e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-08-13 08:48:03 +02:00
Thiago Macieira
99ce02f692 QCborValue: add support for QCOMPARE string output
Change-Id: Ibdc95e9af7bd456a94ecfffd16066c47ea9766d0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-08-12 21:05:06 -07:00
Ulf Hermann
3e25d09b08 QDecompressHelper: Change order of encodings
Before the introduction of QDecompressHelper gzip was preferred over
deflate. The change seems to be accidental. Amends commit
7b76379a89.

Change-Id: I70f33d551912465d63f49ea3db1ac3575d19a92d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-08-12 08:27:09 +00:00
Thiago Macieira
e790af0e0a QJsonDocument: fix comparison of valid vs default
[ChangeLog][QtCore][QJsonDocument] Fixed a bug that caused
QJsonDocument's equality operator to crash if one of the operands was
default-constructed and the other wasn't.

Pick-to: 5.15
Fixes: QTBUG-85969
Change-Id: I5e00996d7f4b4a10bc98fffd1629f835f570ef6b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-11 13:00:47 -07:00
Laszlo Agocs
a99cee1c7b Remove old CBOR-based format from QShader
We only support version 4 and 5 in Qt 6.0. 1 and 2 are already gone
(due to being based on binary JSON), now we remove 3 as well.

Task-number: QTBUG-81346
Change-Id: I3627dcc0587f1e36f11e93edf7172889e911d64e
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-08-11 13:45:09 +02:00
Edward Welbourne
fed97b9264 Sort out the overflow cases in tst_QDateTime
Use the actual minimum value, rather than minus the maximum, and adapt
the overflow expectations so that they're correct west of Greenwich as
well as east.

Change-Id: I7a5f4510db0fdea3855b5b2bd4c4a86882030efd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-11 11:21:46 +02:00
Edward Welbourne
72d14fe32f Fix handling of last second in 1969
Due to a limitation of mktime(), we would have declared it invalid.
Tidied up qt_mktime() slightly in the process.

Change-Id: I25469e314afee6e0394e564bc69a98883005d4ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-11 11:20:43 +02:00
Fabian Kosmale
7b3a2f5e3d cmake support for tst_moc
We use qt_wrap_cpp instead of AUTOMOC so that we can easily find the
json files.
Getting autorcc to run only after json file has been generated was
deemed too tricky.  Therefore the test is slightly modified to check for
the json files in its directory instead of the resource, if the qrc file
does not exist.

Change-Id: Id1aabb117c8bab3ff81156da1f66d64e796bf18b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-10 12:59:46 +02:00
Edward Welbourne
fe6a1d34dc QFileInfo: purge deprecated API
Since 5.10: created()
Since 5.13: readLink()

Change-Id: I9722f81750dd92315a67a1c38df41a95ae63e0db
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-07 17:44:51 +02:00
Edward Welbourne
5a682b04ce Purge QResource of some deprecated API
Removed isCompressed(), deprecated since 5.15, and (since 5.13)
addSearchPath() and searchPath().

Change-Id: I4b6fb8077c02bbe322334e474eaf0a2a7caf0004
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-07 17:44:13 +02:00
Edward Welbourne
7ce27430a7 tst_QStringConverter: fix some deprecation warnings
QString's fromUtf16() prefers char16_t data over ushort.

Change-Id: Ib20c5afa09ceabb4e91fe434b6a057edb4739a53
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-07 17:44:01 +02:00
Giuseppe D'Angelo
3f6afac6b1 QPolygon: streamline constructors and special member functions
Employ RO0; inherit the constructors from the base class; and
do some code tidies as a drive by.

The inherited constructors bring in goodies like initializer_list
support.

Change-Id: Ia00a3f9b0ccbf182bf837bc65ba2305110c8dc60
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-07 15:01:26 +02:00
Mårten Nordheim
ad1a5bf63f QDecompressHelper: Add brotli support
Task-number: QTBUG-83269
Change-Id: If23b098ee76a4892e4c2c6ce5c635688d8d9138d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-06 20:56:42 +02:00
Alexandru Croitor
92ee9bd6b8 CMake: Properly handle CONFIG += thread aka Threads::Threads
mkspecs/features/qt.prf adds a dependency on the system threading
library if the Qt Core thread feature is enabled. Because qt.prf is
loaded by any public or internal Qt project, it's essentially a public
dependency for any Qt consumer.

To mimic that in CMake, we check if the thread feature is enabled, and
and set the Threads::Threads library as a dependency of Qt6::Platform,
which is a public target used by all Qt modules and plugins and Qt
consumers.

We also need to create a Qt6Dependencies.cmake file so we
find_package(Threads) every time find_package(Qt6) is called.

For the .prl files to be usable, we have to filter out some
CMake implementation specific directory separator tokens
'CMAKE_DIRECTORY_ID_SEP' aka '::@', which are added because we call
target_link_libraries() with a target created in a different scope
(I think).

As a result of this change, we shouldn't have to hardcode
Threads::Threads in other projects, because it's now a global public
dependency.

Task-number: QTBUG-85801
Task-number: QTBUG-85877
Change-Id: Ib5d662c43b28e63f7da49d3bd77d0ad751220b31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:15:39 +02:00
Giuseppe D'Angelo
4fc539bd84 QMap: fix insert() rvalue overloads
Receiving an rvalue still requires to check whether the parameter
is detached, otherwise we can't steal its backing std::map.

Change-Id: Ie88dbf39fd777112ad7bb20a46d5c2d65be8eb3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-06 19:15:39 +02:00
Giuseppe D'Angelo
14090760a8 Long Live QMap as a refcounted std::map!
... and QMultiMap as std::multimap.

Just use the implementation from the STL; we can't really claim that
our code is much better than STL's, or does things any differently
(de facto they're both red-black trees).

Decouple QMultiMap from QMap, by making it NOT inherit from
QMap any longer. This completes the deprecation started in 5.15:
QMap now does not store duplicated keys any more.

Something to establish is where to put the
QExplictlySharedDataPointer replcement that is in there as an
ad-hoc solution. There's a number of patches in-flight by Marc
that try to introduce the same (or very similar) functionality.

Miscellanea changes to the Q(Multi)Map code itself:

* consistently use size_type instead of int;
* pass iterators by value;
* drop QT_STRICT_ITERATORS;
* iterators implictly convert to const_iterators, and APIs
  take const_iterators;
* iterators are just bidirectional and not random access;
* added noexcept where it makes sense;
* "inline" dropped (churn);
* qMapLessThanKey dropped (undocumented, 0 hits in Qt, 1 hit in KDE);
* operator== on Q(Multi)Map requires operator== on the key type
  (we're checking for equality, not equivalence!).

Very few breakages occur in qtbase.

[ChangeLog][Potentially Source-Incompatible Changes] QMap does not
support multiple equivalent keys any more. Any related functionality
has been removed from QMap, following the deprecation that happened
in Qt 5.15. Use QMultiMap for this use case.

[ChangeLog][Potentially Source-Incompatible Changes] QMap and
QMultiMap iterators random-access API have been removed. Note that
the iterators have always been just bidirectional; moving
an iterator by N positions can still be achieved using std::next
or std::advance, at the same cost as before (O(N)).

[ChangeLog][Potentially Source-Incompatible Changes] QMultiMap does
not inherit from QMap any more. Amongst other things, this means
that iterators on a QMultiMap now belong to the QMultiMap class
(and not to the QMap class); new Java iterators have been added.

Change-Id: I5a0fe9b020f92c21b37065a1defff783b5d2b7a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-06 19:15:39 +02:00
Eskil Abrahamsen Blomfeldt
76068d0114 Make QFontDatabase member functions static
QFontDatabase is a singleton and all instances would share
a single, mutex-protected global data pointer. But some functions
were implemented as non-static functions. This caused a lot
of code on the form

	QFontDatabase().families(...)

since there was no static access. Other functions were implemented
as static.

To consolidate, we make all functions static. This should be
source-compatible, but not binary compatible.

[ChangeLog][QtGui][Fonts] Some functions in QFontDatabase were in
principle static, but previously not implemented as such. All
member functions have now been made static, so that constructing
objects of QFontDatabase is no longer necessary to access certain
functionality.

Fixes: QTBUG-83284
Change-Id: Ifd8c15016281c71f631b53387402c942cd9c43f6
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2020-08-06 11:43:24 +02:00
Shawn Rutledge
6d6ed64d6c Add QPointerEvent::is[Press|Update|Release]Event accessors
QQuickPointerEvent had them, so despite how trivial they look,
it's very convenient to keep using them in QQuickWindow rather than
duplicating these kinds of checks in various places, and for multiple
event types too.

Change-Id: I32ad8110fd2361e69de50a679ddbdb2a2db7ecee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-06 10:23:56 +02:00
Thiago Macieira
45838673df Implement UTF-16 to UTF-8 case-insensitive compare and make public
Change-Id: Ied637aece2a7427b8a2dfffd16116cf3645c6359
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-05 21:51:24 -07:00
Mårten Nordheim
7b76379a89 Make use of QDecompressHelper for HTTP downloads
Changes are not too big for now. Just replaces use of the previous
calls to the zlib decompression function. And initialize
QDecompressHelper when we know the content-encoding.

Task-number: QTBUG-83269
Change-Id: I41358feaef2e7ac5f48f14e3f95ec094e0c110b7
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-05 17:19:10 +02:00
Morten Johan Sørvig
00f2d1a09b Establish baseline for QIcon test on dpr > 1
After enabling Qt::AA_UseHighDpiPixmaps, QIcon::pixmap()
now returns pixmaps larger than the requested size on
devicePixelRatio > 1 screens.

Adapt tests to account for this changed behavior.
Skip tests where it’s unclear what the the expected
behavior is, or where the test logic does not apply
to dpr > 1.

This gives a clearer indication of where we are
(39 passed, 0 failed, 9 skipped), and enables using
the qicon test to catch regressions also when running
at dpr > 1.

Remove the "lowdpi" testcase flags from the qmake and
cmake project files.

Change-Id: Ia7ce722ae356fc496a91b54e9f5d590d13b9df62
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-05 11:23:07 +02:00
Mårten Nordheim
07b008425a Privately introducing QDecompressHelper for network purposes
To support streaming decompression in QNAM.
Will also be used to refactor existing decompression code in QNAM.

Task-number: QTBUG-83269
Change-Id: Iecf3e359734163f15686c949f75d41fa4794a00e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-05 09:17:11 +02:00