This requires that the allocation functions return two pointers: the d
pointer and the pointer to the actual data.
Ported QArrayDataPointer & SimpleVector to the inlined size & data.
For now, the size and offset members are not yet removed from
QArrayData, to let QVector, QByteArray and QString compile unmodified.
Change-Id: I8489300976723d75b8fd5831427b1e2bba486196
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Same as copyAppend() but calls the move constructor
Change-Id: I7de033f80b0e4431b7f1ffff13f9399e39b5fee4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
It's a typedef meant to replace the "const T &" parameters (hence the
name). But it's actually just a T for POD types, so we don't create
references to them.
Change-Id: I10c746d5e852c957ec84319712597478c4dc872c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Instead of using the reference count to store whether the data is
sharable and whether the header is immutable, move the settings to the
flags member. This allows us to save one comparison per deref() or
needsDetach(). It also allows for the possibility of mutable data
pointed to by a static header.
Change-Id: Ie678a2ff2bb9bce73497cb6138b431c465b0f3bb
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The next change will stop using some values in the reference counter as
settings from the data.
Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The Mutable flag now contains the information on whether the data this
QArrayData points to is mutable. This decouples the mutability /
immutability setting from the allocation and from the type of data,
opening the way for mutable raw or foreign data.
There are still plenty of places in the source code that check the
size of the allocation when it actually wants d->isMutable(). Fixing
this will require reviewing all the code, so is left for later.
The needsDetach() function is moved to QArrayData and
de-constified. It returns true when a reallocation is necessary if the
data is to be modified.
Change-Id: I17e2bc5a3f6ef1f3eba8a205acd9852b95524f57
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This forces us to calculate the reallocation flags properly.
Change-Id: I3486b193ad6732df666fc9ddad96831c9fbe068c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Windows apparently has special code to deal with those addresses. If all
your network interfaces are up and have acquired addresses, then the
link-local network at 169.254.0.0/16 is unreachable. I had never caught
this because both my Windows VM and my bare metal Windows have inactive
interfaces (like the Bluetooth PAN one) and, when inactive, Windows
assigns a link-local address. But in the CI, the interface(s) were all
up and running, causing this issue.
Unix systems don't treat IPv4 link-local any differently, so they always
worked, so long as any interface was up and there had to be one to reach
the network test server.
This commit reworks the test to add test addresses based on the
addresses found on up & running interfaces (see tst_qudpsocket.cpp). For
IPv4, we flip the bits in the local portion of the address. For IPv6, we
add a node with an address I generated randomly (non-universal), with
the same scope.
Fixes: QTBUG-65667
Change-Id: I568dea4813b448fe9ba6fffd15dd9f482db34991
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
if the string pointed to by after is part of the QByteArray, we
were trying to protect against a use-after-free by copying
after. Unfortunately, it was not used later on in the code instead
of the original after.
Change-Id: I2f2263e4bb1855e802bba2fc08db34762c66887a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
These flags allow us to determine what type of data QArrayData is
carrying. There are currently only two supported types:
- raw data type: constructed via fromRawData or static data
- allocated data type: regular data done via heap allocation
The QArrayData object is usually allocated on the heap, unless its own
reference count is -1 (indicating static const QArrayData). Such
object should have a type of RawDataType, since we can't call free().
Add GrowsBackward for completeness as well as the StaticDataFlags
default for static data.
Change-Id: Icc915a468a2acf2eae91a94e82451f852d382c92
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
In almost all cases, use d->allocatedCapacity() or
d->constAllocatedCapacity() instead of d->alloc, since they do the
same thing (right now). In the future, the functions will be
changed. There is a separate const version because most const code
should not need to know the allocation size -- only mutating code
should need to know that
There are a few cases where d->alloc was replaced with a better
alternative, like d->size. The one case that remains in the code will
be replaced by a different test when it's available.
Change-Id: I48135469db4caf150f82df93fff42d2309b23719
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Instead of stealing one bit from the alloc field, let's use a full
32-bit for the flags. The first flag to be in the field is the
CapacityReserved (even though the allocate() function will store some
others there, not relevant for now).
This is done in preparation for the need for more flags necessary
anyway.
Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Rename to QArrayData::ArrayOptions in preparation for these flags
being in the array itself, instead of used just for allocating new
ones.
For that reason, rename QArrayData::Default to
DefaultAllocationFlags. And introduce QArray::DefaultRawFlags to mean
the flags needed for creating a raw (static) QArrayData.
Also rename QArrayData::Grow to GrowsForward, so we may add
GrowsBackward in the future.
Change-Id: I536d9b34124f775d53cf810f62d6b0eaada8daef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Just to simplify a few operations, like detecting when a QChar* or char*
coming from a QString or QByteArray, respectively, were null data.
While you're not supposed to dereference the pointer returned by
QVector::data() unless you know that the array is non-empty, that is
permitted for QString and QByteArray. That is, QString().constData()
must return a valid pointer to a null QChar.
Change-Id: I80b4b62f203dc841e5c99c20c51d92ca576e4bfe
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
ICC, GCC and Clang support __attribute__((malloc)) that tells them that
the function returns newly allocated memory which doesn't alias anything
else. Though technically we may return memory that has already been used
(the shared null or such), that should not be a problem.
Change-Id: Id3d5c7bf4d4c45069621ffff13f7f81f8b08ea3d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
GCC 4.9 and later support the __attribute__((alloc_align)) attributes
that indicate the alignment of the data. To make it work on GCC since
4.7 and Clang as of 3.6, we instead use __builtin_assume_aligned(). I
don't know which version of ICC first implemented this, but ICC 15 does
and it also reports itself as GCC 4.9.
Change-Id: I58bd914b9bdd0ed3349ba56fa78220ab06114852
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The test passed mostly by accident so far, as the created QByteArray
was shorter than what the test assumed.
Change-Id: I06858801d83a504eadc73ec2be281c88f8ffad5d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In prevision to Qt6 which is going to discourrage the use of the integer id,
add some missing API to the staticless QMetaType API:
- Add a way to construct a QMetaType from a type without calling qMetaTypeId:
QMetaType::fromType<T>()
- Add equality operators
- Add a QMetaType::name() function
- Add a default constructor (by adding a default parameter to the existing ctor)
Change-Id: I95487c1c31bdf0d773717daa9d5452cbced30673
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
As we assert on the size of the vector before accessing it, there is no
point in using the checked at() method over operator[]. Besides, if at()
throws, what are we going to do with the exception anyway.
Incidentally, this also works around a compiler bug causing binary
incompatibility in QtQml.
Change-Id: I460e7514429daecabc304eb2c5f96ed715008b0a
Fixes: QTBUG-80535
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Since I can't #include qobjectdefs from qnamespace because of circular dependency,
move the Qt macro in the qtmetamacros.h header.
Deprecate QObject::staticQtMetaObject since now one can just use Qt::staticMetaObject
Change-Id: I11982aa17c2afa2067486b113f8052672f3695eb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The throw() specification is no longer accepted in C++17 mode, so remove that.
Also pass the -std=c++1z to the compiler as Qt is going to require C++17 soon
Change-Id: I6d249e574d90cd1cf5c0ea595830d2db07681050
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
In some cases when editing the text (for example when removing the
selected text, or pasting a text block) the text cursor position is
updated, but its visual x position is not updated. This causes the next
cursor movements to start from a wrong position.
Force the update for those cases.
Fixes: QTBUG-78479
Change-Id: Ia496be62beec58660f5e1695e5aafae09c79684e
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
There were factual errors.
Important details were omitted.
The \sa blocks were haphazard and cluttered.
Change-Id: I76ceb00830c36699c48529b64808844faf09391e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Cite RFC 3339 as basis for allowing a space in place of the T, too.
The RFC mentions that ISO 8601 accepts t and z for T and Z, so test
for them case-insensitively. Add a test for this.
Change-Id: Iba700c8d74d485df154d27300aab7b1958e1ccef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
If milliseconds were followed by a space, the space was included in
the count of "digits" read as the fractional part; since we read (up
to) four digits (so that we round correctly if extras are given), a
harmless apce could cause scaling down by too large a power of ten.
Since QString::toInt() ignores leading space, we were also allowing
interior space at the start of the milliseconds, which we should not,
so catch that at the same time. Added tests, including one for the
rounding that's the reason for reading the extra digit, when present.
Fixes: QTBUG-80445
Change-Id: I606b29a94818a101f45c8b59a0f5d1f78893d78f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Although the relevant conditions are indeed likely, we don't want to
push the less likely branch into hard-to-load pages; they're not
anomalous conditions, merely ones with lower probability.
Change-Id: Icc12a921d38d8c398cd832964e9d57d7648698b2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QDateTime is a friend of QTimeZone, so can access its internals; but
it must check the zone is valid before doing so.
Expanded tst_QDateTime::invalid() and made it data-driven to catch the
failure cases.
Commented on a test-case that caught a mistake in my first attempt at
this, and on QDateTimeParser's surprising reliance on a quirk of
QDateTime::toMSecsSinceEpoch()'s behavior.
Fixes: QTBUG-80146
Change-Id: I24856e19ff9bf402152d17d71f83be84e366faad
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Some styles, notably QMacStyle, use different margins for widgets and
for windows. For these margins to be returned correctly, we have to
tell the style that we want them for a toplevel widget. This was
done correctly when laying out the dialog, but not when calculating the
sizeHint, leading to a default size of the dialog that was too small
to fit the text.
As a drive-by, change variable names in the sizeHint method to be a
bit more readable.
Change-Id: Ib4168c7be176fa816241ebcc5f9235db4a7f982f
Fixes: QTBUG-80272
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 13bbb1d9b9411e6eb65848efa8c0d481109b8868)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Move away from using 0 as pointer literal.
Done using clang-tidy. This is not complete as
run-clang-tidy can't handle all of qtbase in one go.
Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The dragging icon is created from the visible items in the
selection. It would be clipped to the parts visible in the
viewport. That meant that items on the edge could be rendered
illegible, even though they were part of what was being dragged.
Fix by dropping the horizontal clipping to the viewport. Items fully
outside the viewport are already filtered away, so this should at most
make a difference to the bottom and/or top items in the set.
Keep the vertical clipping, since items may easily be very wide, so an
unclipped icon would be unwieldy.
Done-With: Sona Kurazyan <sona.kurazyan@qt.io>
Fixes: QTBUG-77336
Change-Id: I2d29cb0ca69c1058635106aa0c67e9f7e140d1cd
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
QByteArray::fromBase64 was liberal in its input, simply skipping
over invalid characters. As a side-effect of this, it had
no error reporting, meaning it could not be used to convert
fromBase64 _and_ validate the input in one go.
Add more option flags to make fromBase64 strictly validate
its input. Since we want to know whether it has succeeded
or not, and the existing fromBase64 overloads do not
allow for that, introduce a new function that returns
an optional-like datatype.
While at it: base64 decoding can be done in-place; add an
rvalue overload to enable this use case.
[ChangeLog][QtCore][QByteArray] Added the new fromBase64Encoding
function.
[ChangeLog][QtCore][QByteArray] Added new flags to make
fromBase64 / fromBase64Encoding strictly validate their input,
instead of skipping over invalid characters.
Change-Id: I99cd5f2230f3d62970b28b4cb102913301da6ccd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Turn the Metrics widget into a QTabWidget and add a tab logging
all changed signals of QScreen.
This is useful when for example debugging issues with lock screens and
laptop hibernation.
Task-number: QTBUG-79248
Task-number: QTBUG-76902
Change-Id: Ie86789fe1514cb3333a5f3def7f613f217fa6802
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
When cloning a QTextDocument, the text fragment of the original document
is copied into the new one, which results into copying also the
formatting attributes. However, when the text document is empty, the
corresponding text fragment is also empty, so nothing is copied.
If we want to transfer the formatting attributes for an empty document,
we need to set them explicitly.
Fixes: QTBUG-80399
Change-Id: I382cd0821723436120af47c06ec7bfa849636307
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
We forgot to reset the flags when replacing the element, so we ended up
with an integer with HasByteData after:
testMap[0] = QStringLiteral("value");
testMap[0] = 42;
Fixes: QTBUG-80342
Change-Id: Ia2aa807ffa8a4c798425fffd15dabfa066ea84b0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
The application does not update its screens when there are
no windows on which a WM_DPICHANGE could be received. Add a
check for it to the tray window procedure and trigger an
update from there if no top levels are present.
Fixes: QTBUG-79248
Change-Id: I0b1c4db560662ecf2b473304942da373be6fdc73
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This is so that we can do simple changes to the docker images
in provisioning, without needing to update the tag here.
If a backwards-incompatible change in the docker images needs to be committed
in provisioning and here, it is possible because the images retain their old
unique SHA1 tag, in addition to being tagged as latest. See comment for more
details.
Requires the change in qt5 repository, with commit sha:
e4f9ac5607a329bae045567a339d36469bc4fff6
Task-number: QTBUG-79867
Change-Id: I1bc72edec62487530575d7e113a25afe16d09129
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This matches the default collection behavior of NSWindows.
Change-Id: I363ed211daf6c6c2e579eb11c7294ff509d53e91
Fixes: QTBUG-63829
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
We only read this for desktop environments that have traditionally used
these to set settings for other toolkits.
Fixes: QTBUG-80323
Change-Id: Ifa8c2682301e69c2770d3734115080a0e6b4e85c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
The call to data() on a non-const QString led to a detach(), which is
unexpected and unwanted from QString::lastIndexOf() const.
Found by looking at why QFileSystemEntry::fileName() was expensive, in
the hotspot profiler.
The solution is to instanciate QLastIndexOf with QStringView() rather
than QString(). I added a deleted QString overload to make sure nobody
ever instanciates it with a QString argument again.
Change-Id: I06a1b2f937425e83f0779eb215e099aef78c50a7
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When drawing a QMenu which is checkable but does not have an icon
somewhere, the width of the (possible) checkmark was not considered
during drawing and the text was drawn over the checkmark. Also the wrong
state was checked for drawing the checked icon (if one was given).
Fixes: QTBUG-80506
Task-number: QTBUG-78238
Change-Id: Icf8aa37aab424564054d3549defee93eb0d7c1a4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
QEvent::EnabledChange did not update the palette of the internal
QPlainTextEditControl which lead to a wrong text color when the
QPlainTextEdit was disabled e.g. due to a QGroupBox.
Fix it the same way it is done in QTextEdit - set the new palette also
to the internal control when QEvent::EnabledChange is received.
Fixes: QTBUG-80150
Change-Id: Icbeddf3d6cd4877a3d8d4a06b2da69383dd776d2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
QTextStream, reading a file with CR+LF newlines from an stdio FILE
handle that was opened without "b", will always return false in atEnd().
Changing the open mode from "r" to "rb" works around the issue.
Task-number: QTBUG-80443
Change-Id: Ib2eafc0c4c6a6d2bcaeea3036474549d2d9e1511
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
in qt5.15 you deprecated iterator &operator--() in qhash
but QDataStream needs it. (see writeAssociativeContainer)
So when we compile without deprecated method we can see:
qdatastream.h:333:9: error: no match for ‘operator--’ (operand type is ‘QHash<QString, QImage>::const_iterator’)
333 | --it;
| ^~~~
The current code is only
QHash<QString, QImage> m_images;
QDataStream stream(&file);
stream << m_images;
Change-Id: I12e61c0c60615455ac1eeff02969f155edb12e56
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
QHash::unite can silently turn a regular QHash into a multi hash,
something that is not intended here. Use a regular insert()
instead.
Change-Id: I9244a8553e84eed5367939019347b51491765ea0
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
As opposed to unite(), this inserts one hash into the other
without duplicating elements.
Change-Id: Ifc786c48f5dc3ab18c29782e73eac3c1a3ef8981
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
QDoubleValidator would accept "1,23" as valid in a locale which has ','
as a thousand separator. However, it should have been Intermediate
instead, as there is still one digit missing.
Fixes: QTBUG-75110
Change-Id: I6de90f0b6f1eae95dc8dfc8e5f9658e482e46db3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>