Commit Graph

11584 Commits

Author SHA1 Message Date
Lars Knoll
638df6138e Remove operators allowing assignment of a binding to a property
These look rather weird, an explicit property.setBinding() call
is simply better in this case, and also more aligned with the API
we can offer in QObject.

Change-Id: Ifb00fd47a75e6b3bc94e34bf49e4f13249565bfe
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:28 +02:00
Lars Knoll
e6988d4d0b Remove QNotifiedProperty and Q_PRIVATE_QPROPERTY
And all related functionality. This is being replaced by
Q_BINDABLE_PROPERTY and Q_OBJECT_BINDABLE_PROPERTY in the
next few commits. The new infrastructure coming will play
nicer along with the existing property system.

Commented out some autotests, that will get reimplemented
with the updated infrastructure.

Change-Id: I50c30bd4d5c6c6b6471f8eb93870e27d86f5a009
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:27 +02:00
Lars Knoll
e638e8a28d Cleanups: Rename some classes
Rename QPropertyBase to QPropertyBindingData, as it contains the
data related to bindings. The new name fits better, as the data
can now also live somewhere else than the data strored in the
property.

Change-Id: I489efb86ad2e0bad2740c9d1aa74506fe103d343
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:27 +02:00
Lars Knoll
331c106bdb Remove the special handling of QProperty<bool>
Since we will be storing property data differently in most cases,
having this special case would create too many additional complications.

Change-Id: I27042b0730559bb375d8e3c07324398403a9885d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:27 +02:00
Fabian Kosmale
733d890430 Add operator-> and operator*() to QProperty
Enable the arrow operator for all types that could have members, so
that one can e.g. write myStringProperty->size() instead of having to
use the less convenient myStringProperty.value().size().

Also cleaned up the rvalue ref overloads to be
disabled for basic types. For those we now also
return by value, for more complex types we
return a const reference.

Change-Id: If6a75898dc0a097f57052488f0af0cd7166b3393
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:27 +02:00
Giuseppe D'Angelo
11b8c46d2a QObject: add a single shot connection flag
If one needed to listen to a signal just once, one had to
store the QMetaObject::Connection object returned by connect()
and use it to disconnect the slot after the first signal
activation.

This has led to a proliferation of using wrappers (and enough
TMP); they usually look like this:

1) create a shared_ptr<QMO::Connection>, allocating its payload;
2) create a lambda, capturing the shared_ptr by value;
3) in the lambda, disconnect the connection (through the shared_ptr),
   and call the actual slot;
4) connect the signal to the lambda, storing the returned
   QMO::Connection into the shared_ptr.

This is expensive, error prone for newcomers, and tricky to
support as a general facility inside one's projects.
We can do better, just support single shot connections right
in QObject.

[ChangeLog][QtCore][QObject] Added the Qt::SingleShotConnection
flag. When a connection is established with this flag set,
the slot is going to be activated at most once; when the signal
is emitted, the connection gets automatically broken by Qt.

Change-Id: I5f5feeae7f76c9c3d6323d841efba81c8f98ce7e
Fixes: QTBUG-44219
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-09-01 17:59:36 +02:00
Andreas Hartmetz
7406949858 Doc fix: disconnect with receiver also works for context objects
One could guess it by assuming that disconnecting for a destroyed
receiver and disconnect() with given receiver use the same
implementation, but without closely knowing the implementation a
reader of the documentation can't know for sure.

Also add a test to prove that what the new documentation says is
really true.

Also remove an unnecessary negation in the preceding sentence.

Change-Id: I9d24442bb1a4646b89f969bad1a4d0e1eafa7534
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 13:35:39 +02:00
Ulf Hermann
4fbb2f66d6 Add a QMetaSequence interface
This is in line with QMetaType and will be used to implement a mutable
QSequentialIterable. Later on, a QMetaAssociation will be added as
well, to implement a mutable QAssociativeIterable.

The code here represents the minimal set of functionality needed to have
a practical sequential container. The functionality is not completely
orthogonal. In particular, the index based operations could be
implemented in terms of iterator-based operations.

Task-number: QTBUG-81716
Change-Id: Ibd41eb7db248a774673c701549d9a03cbf2e48b6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 13:35:39 +02:00
Giuseppe D'Angelo
c1454d07cf Take the right lock before using a connection's receiver
When a signal/slot connection is activated, a lock on the receiver
object is taken (to be sure it doesn't get destroyed).
The path for blocking queued connections however took the lock on
the sender by accident, fix that.

Pick-to: 5.15 5.12
Change-Id: I8cd938a50eca2bf71e7bfb86768ee0c8431afdfa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 02:48:40 +02:00
Marc Mutz
2c9529e158 Long live Q{Any,Utf8}StringView!
We need to add these two classes at the same time, because
QAnyStringView makes all QUtf8StringView relational operators moot. We
might want to add some later, esp. for UTF-8/UTf-8 comparisons, to
avoid the pessimization that we can't early-out on size() mismatch in
QAnyStringView equality operators, but that's an optimization, not a
correctness issue, and can be fixed in a source-compatible way even
after Qt 6 is released.

To deal with the char8_t problem in C++20, make QUtf8StringView a
class template out of which two UTF-8 views can be instantiated: the
Qt 7 version, which depends on C++20 char8_t as value_type, and the Qt
6 version where value_type is a char. Use inline namespaces to map the
QUtf8StringView identifier to one or the other, depending on the C++
version used to compile the user code. The inline namespace names must
needs be a bit ugly, as their inline'ness depends on __cpp_char8_t. If
we simply used q_v1/q_v2 we'd be blocking these names for Qt inline
namespaces forever, because it's likely that inline'ness of other
users of inline namespaces in Qt depends on things other than
__cpp_char8_t. While inline'ness of namespaces is, theoretically
speaking, a compile-time-only property, at least Clang warns about
mixed use of inline on a given namespace, so we need to bite the
bullet here. This is also the reason for the QT_BEGIN_..._NAMESPACE
macros: GCC is ok with the first declaration making a namespace
inline, while Clang warns upon re-opening an inline namespace as a
non-inline one.

[ChangeLog][QtCore][QUtf8StringView] New class.

[ChangeLog][QtCore][QAnyStringView] New class.

Change-Id: Ia7179760fca0e0b67d52f5accb0a62e389b17913
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-31 22:57:49 +02:00
Peng Wenhao
f0ae973244 Qpagedpaintdevice: Use marginsF instead of internal struct margins
resolve remaining Qt6 TODOs

Change-Id: Iad659a09ddfe136bdc545bc0635b4c695540c58b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-01 04:57:48 +08:00
Tor Arne Vestbø
90358f6042 Deprecate and remove uses of AA_DisableHighDpiScaling
Change-Id: Ibadce68775858c524b998aacad310905ba2c2e8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-31 19:14:55 +02:00
Tor Arne Vestbø
2dc46c0902 Deprecate and remove all uses of AA_UseHighDpiPixmaps
High-DPI pixmaps are always enabled, and cannot be disabled.

Change-Id: I01a006b404e5431582b64ef812974c1c022b39ae
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-31 14:29:01 +02:00
Edward Welbourne
e40320c552 QWeakPointer: purge deprecated API
Since 5.0: assignment/construction from QObject pointer
Since 5.14: data() to recover the packaged pointer

Change-Id: I5d6ab561ce39bc0d9d3e5035eb2ca38139cd76b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-31 10:32:39 +02:00
Laszlo Agocs
9390edb119 rhi: Work around qsizetype fallout in manual tests
Change-Id: I9f0e210caacc6eefe5ed1ee6fa97574ad5e9edcc
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-08-30 17:45:01 +02:00
Edward Welbourne
78cf89c07d Use checked string iteration in case conversions
The Unicode table code can only be safely called on valid code-points.
So code that calls it must only pass it valid Unicode data. The string
iterator's Unchecked Unchecked methods only provide this guarantee
when the string being iterated is guaranteed to be valid UTF-16; while
client code should only use QString, QStringView and friends on valid
UTF-16 data, we have no way to be sure they have respected that.

So take the few extra cycles to actually check validity in the course
of iterating strings, when the resulting code-points are to be passed
to the Unicode table look-ups. Add tests that case mapping doesn't
access Unicode tables out of range (it'll trigger the new assertion).
Added some comments to qchar.h that helped me understand surrogates.

Change-Id: Iec2c3106bf1a875bdaa1d622f6cf94d7007e281e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-29 18:15:27 +02:00
Marcel Krems
ab5e444c8f Remove remaining traces of deprecated QtMsgHandler
Change-Id: I28aecb444eb9bc9e26e6ff8998904dbf28419f25
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-29 16:24:21 +02:00
Andrei Golubev
a2b1b0292d Prepend optimize QString
Added prepend optimization to QString

Task-number: QTBUG-84320
Change-Id: Iaa8df790a10c56ecceb06f7143718fb94874ce76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-29 14:20:06 +02:00
Morten Johan Sørvig
319462559f Port tst_qiconhighdpi to the new QIcon::pixmap() API
Port the high-dpi icon test to use the new pixmap()
API which takes the target devicePixelRatio as an argument.

This means we can run the fromTheme test at dpr = {1,2,3},
instead of at the current global devicePixelRatio only.

Task-number: QTBUG-85885
Change-Id: Iec7b21e04ed760e48964307d2048eaec1976ffe2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-29 10:02:47 +02:00
Tor Arne Vestbø
9d2b43de19 Use build-system to declare tests that are low-DPI
Change-Id: I6da7204683b3c46232cfc542ed5e28131a82e87d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-28 22:16:53 +02:00
Edward Welbourne
86ebe46f59 Make QTranslator::load() insist that its return value be checked
Add Q_REQUIRED_RESULT to force callers to check the return; the
QTranslator object is unusable if load() fails.
Check the result in QTranslator's own test.

Task-number: QTBUG-85700
Change-Id: I07509c76470cc87626190670665cd3162bfb17e7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-28 21:26:21 +02:00
Edward Welbourne
26547c296b Purge qalgorithm.h of deprecated API
A large slice of it has been deprecated since 5.2.

Reflowed a doc paragraph pointed out, in the deprecation commit, as
having been left ragged by its edits.

Note: qSwap() is documented as \deprecated but not marked, where it's
defined, as deprecated.

Change-Id: Iaff10ac0c4c38e5b85f10eca4eedeab861f09959
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 21:22:32 +02:00
Tor Arne Vestbø
dce106c77c High-DPI: Remove usage of Qt::AA_EnableHighDpiScaling
This attribute is now on by default.

Change-Id: I7c9d2e3445d204d3450758673048d514bc9c850c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-28 20:08:43 +02:00
Tor Arne Vestbø
92a32e050f Remove QMacNativeWidget and QMacCocoaViewContainer
The functionality should be available via QWidget::winId(),
and QWidget::createWindowContainer() + QWindow::fromWinId().

Any bugs in this area should be fixed by improving the general
wrapping APIs.

Fixes: QTBUG-83254
Change-Id: I86584a4a8138d17d65a50da39efd58039f10da91
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-28 14:16:52 +02:00
Tor Arne Vestbø
756d7facf6 Fix tst_QHighDpiScaling::scale
Without an override for logicalDpi() the base class implementation
would use the geometry of the screen to figure out the DPI, and end
up with ~100, which combined with a 96DPI base logical DPI would
give a wrong scale factor.

Change-Id: I68aecce44d2ee672c7b707dfe5444af8f551e961
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-28 13:00:05 +02:00
Tor Arne Vestbø
70def4341a Avoid inifinite recursion call in tst_Compiler::cxx11_noexcept
warning: all paths through this function will call itself [-Winfinite-recursion]

Change-Id: I70008710a7448ffd532bb6c3acb488fe439cb807
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 09:43:14 +00:00
Tor Arne Vestbø
6ab6571f24 Remove tst_QGL
It was left out of the build in f08038fca7
but not removed. It doesn't make sense to keep it, as the classes it
tests have been removed.

Change-Id: Ic36a066eb092d8b9b40c645de649af9dcaab4ff2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-08-28 11:43:11 +02:00
Jonas Karlsson
3558704ed5 Use OpenType font weights
Task-number: QTBUG-42248
Change-Id: Icdb301b27d6699c2b842c4563fbef9df73c23cbc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-08-28 07:26:54 +02:00
Marcel Krems
257285553f Use qsizetype in QRegularExpression
PCRE2 already uses size_t which we can now make full use of.

Change-Id: Icb5efd5c6ef27f2e31a9780bf62f5671ddc603cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 02:22:10 +02:00
Fabian Kosmale
4d5a048d96 Improve connect: Use existing metatypes if possible
As there is now a chance that a QMetaMethod already contains the
metatypes for its arguments, we can just query it directly (and use the
fallback to name lookup logic that already exists there).
This also allows us to avoid creating a QList of names, and only
requires us to do a name lookup in case the connection actually fails.

Change-Id: Idda30bc4b538a94476ae6c533776c22340f0030d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 00:41:00 +02:00
Mårten Nordheim
f7f79483e7 Remove QFtp sources etc. in favor of alternate distribution
While we initially wanted to just disable the functionality the way it
is currently built forces people to do a full build of Qt just to enable
it. Instead of doing this half-measure let's just remove the code
completely from QtBase and rather prepare QtNetwork to handle being a
plugin that can be compiled at any time.

Task-number: QTBUG-80340
Change-Id: I19155c8c167cf932088f01b2a9706d0e7ab792d1
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-08-27 18:58:21 +02:00
Lars Knoll
84f3690947 Make QUUid constructors from string like types explicit
I don't think we want to have implicit conversion
from a const char * or a QByteArray to a QUuid.

Change-Id: Idfe7450ce15b89e295aa7af7ccf1fc94f5acd4f9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-27 18:58:21 +02:00
Lars Knoll
50661a9558 Change QByteArray to handle large arrays
Use qsizetype throughout.

Change-Id: I787af7fcfa17e1be87decb64c41c609cc24be117
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-27 18:58:20 +02:00
Andrei Golubev
4a56a5f6cf Support GrowsBackwards prepend in QList
Restored previously deleted logic of setting GrowsBackwards flag for
prepend-like cases. This should be sufficient to fully enable prepend
optimization

Fixed QList::emplace to not use implementation detail logic. Updated
tests to cover changed behavior and its correctness

Task-number: QTBUG-84320
Change-Id: I4aadab0647fe436140b7bb5cf71309f6887e36ab
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-27 18:58:20 +02:00
Andrei Golubev
f9bb3aa5ce Add prepend optimization to QCommonArrayOps
Introduced prepend optimization logic to QCommonArrayOps.
Trying to rely on original QList behavior

Task-number: QTBUG-84320
Change-Id: I46e6797b4edad804a3e3edb58307c9e96990fe01
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-27 18:58:20 +02:00
Andrei Golubev
e35d0ae0cc Support GrowsBackwards flag in QArrayDataPointer
Introduced allocation function in QArrayDataPointer with
interface similar to QArrayData::allocate that supports growing
strategies. This func is used instead of the original in cases
when prepend-aware storage is needed. Tried to follow Qt5 QList
policy in terms of space reservation

Updated QPodArrayOps::reallocate to be aware of growing
shenanigans. It doesn't look like a perfect solution but it is
rather close and similar to what Qt6 QList is doing when not
growing (e.g. reserve/squeeze)

Added initial QCommonArrayOps with helper function that tells
when reallocation is preferable over just using the insert-like
operation. This comes up later on when GrowsBackwards policy is
properly supported in operations

Essentially, 2/3 main data management blocks for prepend optimization
are introduced here. The last one being a generalized data move that
is done instead of reallocation when existing free space is not enough

Task-number: QTBUG-84320
Change-Id: I9a2bac62ad600613a6d7c5348325e0e54aadb73d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-27 18:58:20 +02:00
Edward Welbourne
7883bf7304 Mark some Qt namespace enum members properly as deprecated
A comment is not good enough, Some of the enum members were even still
in use, or mentioned in documentation.

WA_ContentsPropagated, WA_WState_DND and WA_ForceAcceptDrops have been
deprecated since 4.5.1; and at least the last has been an \omitvalue
in the docs for even longer.  (WA_ShowModal and WA_GroupLeader have
been similarly marked, but are in use, see QTBUG-85816.)

Push back to 5.15.1 in order to be able to remove these at Qt 6.

Pick-to: 5.15.1
Change-Id: I6ea3839767e5f5158b0fed508f65798470191908
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-27 13:05:42 +00:00
Morten Johan Sørvig
ffde7e8995 QIcon: Add pixmap() overload which take devicePixelRatio
Add new QIcon::pixmap() overload:

  QPixmap pixmap(const QSize &size, qreal devicePixelRatio, ...)

This function replaces the existing pixmap() function which
take a QWindow pointer, and should be more convenient in use.

Task-number: QTBUG-85885
Change-Id: Ie4ca96a266d9278864678dc61bdfc2836cabdb93
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-08-27 12:13:08 +02:00
Volker Hilsheimer
c501e09efa Replace QAbstractItemView::viewOptions with initViewItemOption
viewOptions returned a QStyleOptionViewItem object. Such a method
can never support newer versions of the option structure.

Most styleable QWidget classes provide a virtual method
initStyleOption that initializes the option object passed in as a
pointer, e.g QFrame, QAbstractSpinBox, or QComboBox.

Follow that API convention, but name it initViewItemOption, as the
QStyleOptionViewItem struct contains information about the item as
well as the widget itelf.

This is a source incompatible change that will go unnoticed unless
existing subclasses mark their overrides as 'override', or call
the removed QAbstractItemView::viewOption virtual function.

[ChangeLog][QtWidgets][QAbstractItemView] The virtual viewOptions
method that previously returned a QStyleOptionViewItem object has
been renamed to initViewItemOption, and initializes a
QStyleOptionViewItem object that's passed in through a pointer.

Change-Id: Ie058702aed42d77274fa3c4abb43ba302e57e348
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-08-26 18:02:58 +02:00
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