Instead of detaching when the string is shared, or if the the insertion
would cause a reallocation, create a new string and copy characters to
it as needed, then swap it with "this" string. This is more efficient
than detaching which would copy the whole string before inserting, as
some characters would be copied multiple times.
Use detachAndGrow(), otherwise QStringBuilder unitests fail:
PASS : tst_QStringBuilder1::initTestCase()
FAIL! : tst_QStringBuilder1::scenario() 'prepends < max_prepends' returned FALSE. ()
Loc: [tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp(61)]
PASS : tst_QStringBuilder1::cleanupTestCase()
The issue is that now when inserting, if the string is going to
reallocated, we create a new string, so the freeSpaceAtBegin()
optimization doesn't work the same way.
void checkItWorksWithFreeSpaceAtBegin(const String &chunk, const Separator &separator)
{
// GIVEN: a String with freeSpaceAtBegin() and less than chunk.size() freeSpaceAtEnd()
String str;
int prepends = 0;
const int max_prepends = 10;
while (str.data_ptr().freeSpaceAtBegin() < chunk.size() && prepends++ < max_prepends)
str.prepend(chunk);
QVERIFY(prepends < max_prepends);
...
...
each str.prepend() would have reallocated.
[ChangeLog][QtCore][QString] Calling insert() on a currently shared
string is now done more efficiently.
Task-number: QTBUG-106186
Change-Id: I07ce8d6bde50919fdc587433e624ace9cee05be8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
A side-effect of this change is that now almost all insert() overloads
will have the prepend-optimization as the QADP grows at the beginning if
inserting at index 0.
Change-Id: I49c0471ddb02cbbe61a13977650f0993e80040fa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Namely insert(qsizetype i, QLatin1StringView) and insert(qsizetype,
const QChar *, qsizetype).
Instead of using d->insert(), tell d.detachAndGrow() to grow at the
beginning if inserting at index 0.
The next commit will split the common code between these two overloads
to a static helper. (Done in multiple steps to make it easier for me to
see what is being changed, and easier to git bisect if needed ...etc).
Change-Id: Idf939df10cca49cb13b66a36b3cf155561630959
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
If the object is shared, instead of detaching, copy characters from
"this" to a new object except for the chacters that would be erased,
this is more efficient than detaching (which would copy the whole data
then erase).
- Extend tst_QString::removeIf() to catch a corner-case (that I saw
with tst_QByteArray::removeIf()).
- Add q_uninitialized_remove_copy_if, which works like
std::remove_copy_if but for uninitialized memory like
q_uninitialized_relocate_n (but copies rather than relocates/moves).
With the same static_assert from q_relocate_overlap_n that the type
destructor is non-throwing.
Added q_uninitialized_remove_copy_if in this commit rather than a
separate one so that it's unittested by its usage in eraseIf().
[ChangeLog][QtCore][QString, QByteArray] Removing characters from a
currently shared string or byte array is now done more efficiently
Task-number: QTBUG-106181
Task-number: QTBUG-106183
Change-Id: Icc0ed31633cef71d482b97e0d2d20d763163d383
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
"GLOB_RECURSE" files in the QT_ANDROID_PACKAGE_SOURCE_DIR directory
if it's specified and expose them to IDE.
Fixes: QTBUG-110810
Pick-to: 6.5
Change-Id: I3c4d4fdf0dff8965fd277672ef9d77453839b4cb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reset the _qt_expects_finalization flag after the qt6_finalize_target
call. Otherwise the dependent functionality will still expect the
finalization.
Change-Id: Ieb10d1ee7b3156443e010f916d68da5f2e5779b6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Consider a Qt target created in a subdirectory and a call to
qt6_generate_deploy_app_script(target) in the parent directory.
Once qt6_generate_deploy_script (called by
qt6_generate_deploy_app_script) is run, the target has already been
finalized. However, qt6_generate_deploy_script needs to run before
finalization, because:
- qt6_generate_deploy_script marks the target as to be deployed
- the finalizer generates plugins information only if the target was
marked to be deployed
Fix this in qt6_generate_deploy_script by checking whether the target
was already finalized. In that case, generate the plugin deployment
information right away.
Pick-to: 6.5
Fixes: QTBUG-109741
Change-Id: Idf60f9e21f038c1a33843177d9299230857ee70b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This is needed for tracing android devices.
Pick-to: 6.5
Change-Id: Ic04e15b43b426bdb1232e671acb4163165eab666
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Not all touch points are changed as per emscripten event, so we
do not need to remove or add them to the touch event
Fixes: QTBUG-110941
Pick-to: 6.5
Change-Id: I4799ef0c05750a36361836698eb83e5bf844ece8
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
The former is much safer to use in the presence of overloaded operator
new, and forms a tiny step towards a fully C++20-constexpr QVLA in the
future.
Pick-to: 6.5
Change-Id: If1b31c06296a60c39f1c9f9da523e208ecb1248b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
If -unity-build-batch-size is not given, we default to CMake's default
which is 8. In QtSetup.cmake, we explicitly set the default to avoid
having it set to OFF in case it is missing, just to make sure that we
don't get any unintended behavior.
Task-number: QTBUG-109394
Change-Id: I19849e9baa507b64fb23847c740e20a7adc61b8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
It's not a very well written example, using (largely unneed) hacks to
implement what it does. It's also misleading - the syntaxhighlighter
example is a better showcase for building a useful code editor.
Move it to manual tests.
Fixes: QTBUG-111025
Pick-to: 6.5
Change-Id: I405d41688235bf3e9a08373e716769f26d02fec6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
The example follows bad and outdated practices:
- running time consuming and I/O heavy workload in the GUI thread
- calling processEvents to keep the UI responsive
- showing results only at the end of a search rather than continuously
Perhaps this example can be rewritten at some point to apply modern
practices (at least use a thread and emit signals), but it seems
to have low overall educational value.
Moving it to be a manual test for now.
Fixes: QTBUG-111002
Pick-to: 6.5
Change-Id: Id630fd4599096448ea4f96bcbf977b11a039796f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The example is 90% boiler plate for subclassing QFrame and providing
a bit of GUI to change the size of the label using sliders. The
interesting bit is a block of 25 lines of code, so turn those into a
snippet and add that to the QTextLayout overview documentation.
Fixes: QTBUG-111011
Pick-to: 6.5
Change-Id: I6e97b2ea47b553c8d998ad185cfac006721ef7ee
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
- The following commands accepts NO_UNITY_BUILD, and
NO_UNITY_BUILD_SOURCES arguments to opt out of the unity build, and
to exclude some source files from unity build, respectively.
- qt_internal_add_executable
- qt_internal_add_module
- qt_internal_add_plugin
- qt_internal_add_tool
- qt_internal_extend_target
- qt_internal_add_common_qt_library_helper
- qt_internal_add_cmake_library
- qt_internal_add_simd_part
- Unity build is disabled by default in these:
- qt_internal_add_test
- qt_internal_add_test_helper
- qt_internal_add_benchmark
- qt_internal_add_3rdparty_library
- qt_update_ignore_pch_source also excludes the files from unity_build
Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I5d0e7df633738310a015142a6c73fbb78b6c3467
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
A QVariant(QString) was not convertible to an enum not registered with
Q_ENUM() which worked fine in Qt5.
The same problem exists for QVariant(enum) to QString.
Fix it by not bailing out when no metatype for the enum was found and
try to convert it to a qlonglong instead (which is then correctly
converted to the enum type).
Fixes: QTBUG-109744
Pick-to: 6.5 6.4
Change-Id: Ie7bb016a860455b69508f0f46b36474c9c294f3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Implemented assign() methods for QVarLengthArray to align
with the criteria of std::vector, addressing the previously
missing functionality.
Reference:
https://en.cppreference.com/w/cpp/container/vector/assign
[ChangeLog][QtCore][QVarLengthArray] Added assign().
Fixes: QTBUG-106200
Change-Id: If671069808ff561b0f4c77b6c7f7aca360a0c663
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The declarations with default parameters cause
conflicts in CMake Unity (Jumbo) builds.
Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Icf48193498d70dfacadf1b2499cb3359169f72c0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Otherwise leads to QHash being unable to find it upon usage:
qtbase/src/corelib/tools/qhash.h(64): error C2338: static_assert failed: 'The key type must have a qHash overload or a std::hash specialization'
qtbase/src/corelib/tools/qhash.h(665): note: see reference to function template instantiation 'size_t qt::QHashPrivate::calculateHash<D3D12_SAMPLER_DESC>(const T &,size_t)' being compiled
Since we rely on ADL for qHash the qHash overload should live in the
same scope as the original type.
Change-Id: I701447c49076980a1aed47d64ba8ac3358cf8b1c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
On Mac there's no concept of menu bar alt+key shortcuts. Therefore we
cannot expect users on Mac, even when in a web application, to be
familiar with those. Additionally, alt+key combinations yield special
characters on Mac so that is the behavior we should support in WASM apps
on Mac.
To disable the menu bar item shortcuts, a new platform style hint
UnderlineShortcut was created. Shortcut grabbing was disabled exactly
the same as on regular Mac builds, i.e. through
qt_set_sequence_auto_mnemonic.
Task-number: QTBUG-76587
Change-Id: Ice6ed123c01e46b58d6d2c3e639813161b5a9a40
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
\internal needs to be on its own line, otherwise qdoc doesn't know what
\a means.
Pick-to: 6.5
Change-Id: Ie7bd2fd779540b8d7ea92f9d1dd94e73a771d2b6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Includes should be ordered from most specific to most general. This
means that project-specific includes always come before Qt includes.
This example didn't follow that guideline. Fix.
Amends 88e8094f18.
Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Iafdae9dd8e70ff99882c4344a023a21d15fa3c54
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
A QString is not a full representation of a Level, so the
Level(QString) ctor should be explicit.
Pick-to: 6.5 6.4 6.2 5.15
Task-number: QTBUG-108857
Change-Id: I24b705139e61c4aaf59cb0aad3b536013e0d07df
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Grouped property updates have been ported to make use of the
non-recursive variant, and thus the last remaining user of recursive
notify() is gone.
Change-Id: I617db0dedc66555152a9b43514d9d8658d528f2c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This fixes a use-after-free in QPropertyDelayedNotifications::notify.
Before this patch, evaluateBindings or a notify from a property index
might have caused the originalBindingData to become reallocated.
However, at that point, we've already restored the original bindingData
in evaluateBindings, so we won't track updates, and thus won't adjust
originalBindingStatus, which will then point to already freed data.
To remedy this, we no longer do the notification with data fetched from
originalBindingData, but instead use the information we have in the
proxyData.
We also need to enure that referenced bindings do not get deleted; for
that we keep the PendingBindingObserverList alive for the whole duration
of the endPropertyUpdateGroup.
As we now have the PendingBindingObserverList, we use it for the
notification logic, and only notify change handlers in
QPropertyDelayedNotifications::notify. That will allow a follow-up
cleanup of QPropertyObserverPointer::notify, and aligns the logic for
grouped updates with the logic for "nornal", non-grouped updates.
Amends f1b1773d0a.
Task-number: QTBUG-110899
Pick-to: 6.5 6.4 6.2
Change-Id: Iae826e620d9614b7df39d86d8a28c48c8a5c4881
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
That use case for the class never materialized, and it was actually
meant for internal use. However, we put it into the public header, so
we cannot remove it (and while undocumented, someone actually used it at
some point, compare e4d62651c2).
Mark it as deprecated instead so that it can be finally be removed in Qt
7.
Change-Id: I058c5831a44610121fbec6eaddebd8b33d4a16c9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Based on header review comments, make the internal constructor private
and declare classes that need it as friends.
QFlag-ify the HandlerScope enum, as it is a list of flags, and adjust
code accordingly.
Pick-to: 6.5
Change-Id: I1d8843265e49e696d463e9eea8306f4dbae75c78
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
qt_ntfs_permission_lookup is a global, non-atomic variable which
could cause problems in case of multiple threads. Introduce a
new atomic variable to handle permission lookups but instead of
manual incrementation/decrementation, implement a class to manage
the variable.
Since the atomic variable is not directly available to the user,
implement helper functions to increase/decrease/check the status
of the variable.
Task-number: QTBUG-105804
Change-Id: If6cbcdd653c7f50ad9853a5c309e24fdeb520788
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Introduce the qt-cmake-create script. The script generates the simple
CMakeLists.txt based on the source files located in the current or
specified directory. The initial version can generate a CMake code for
the following file types:
- .c .cc .cpp .cxx .h .hh .hxx .hpp - generates the qt_add_executable
call with prerequisites.
- .qml .js .mjs - generates the qt_add_qml_module call with
prerequisites.
- .ui - adds the found ui files to the existing executable. Requires
C++ files be present in the directory too.
- .qrc - generates the qt_add_resources call and adds the resources
to the existing executable. Requires C++ files be present in the
directory too.
- .proto - generates qt_add_protobuf call with prerequisites.
The QtInitProject.cmake script contains the 'handle_type' function that
allows extending the script capabilities and establish simple relation
chains between the file types.
Note: The initial implementation doesn't deal with sub-directories, so
all files from sub-directories will be added to and handled in the
top-level CMakeLists.txt file. This can be extended by user request.
Task-number: QTBUG-104388
Change-Id: I5abd9e07da109e867ff95986572ed2bf02ef9d3d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
In addition to being an iconic part of Qt's history, wiggly is also
widely used for verifying on embedded hardware.
Change-Id: Ica86626d98ade2570eebe787860293380c21f96a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Includes should be ordered from most specific to most general. This
means that project-specific includes always come before Qt includes.
This example didn't follow that guideline. Fix.
Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I42727ff8bdef5336368cde349cbcb8d10bb6289f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The compiler does that for us. This makes the enum look like an enum
again. A non-flags enum shouldn't have intializers of the form 0xNNNN,
as that makes it looks like flags.
Found in API review.
Pick-to: 6.5
Change-Id: If49e94cdad719b7dc9e8a7b17f6883dc789e62d6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
The new implementation has the following advantages compared to
the old one:
0. Qt's default activation behavior is not changed, this patch only
improves how we forcely activate the window.
1. Account for the special case that the foreground window maybe hangs.
2. Truly bring the window to front if the window is hidden or minimized.
3. Use early return to save many indentation.
Change-Id: If51ad943fbc9771ebdddfa0e49732b12566ca2b6
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
They're completely superseded by standard traits, and there are no more
users in-tree. I'm not hiding them behind a QT_DEPRECATED_SINCE,
because these are private APIs, so there's no source compatibility
guarantees here. I'm also using [[deprecated]] directly to avoid
an extra inclusion after the QtGlobal split.
Change-Id: If649e52ffe51c5eba1c51da25b6fe0621a0b17b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The adaptor is a server-side implementation that must exist anyway and
is called by the QtDBus runtime. We don't want warning on the server
side because it must call those methods to implement the client API.
Since we have the XML introspection saved in a class property anyway,
the runtime won't be inspecting the method tags to see if
Q_DECL_DEPRECATED is there, to add to the XML (which it isn't
generating).
Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17416596135d26ca
Reviewed-by: David Faure <david.faure@kdab.com>
Commit 93dad2bf91 (6.0) changed
Q_DECL_DEPRECATED to use the [[deprecated]] attribute, which must appear
before inline and other keywords.
To keep it next to Q_NOREPLY, I also moved the "inline" into the next
string.
Added missing tests for both.
Pick-to: 6.2 6.4 6.5
Fixes: QTBUG-110979
Change-Id: I9671dee8ceb64aa9b9cafffd1741656e86f40453
Reviewed-by: David Faure <david.faure@kdab.com>
When the main executable is built with a pre-macOS 11 SDK, the macOS
kernel and system libraries will enable a compatibility mode for
reporting the system version, reporting 10.16 instead of 11/12/13 etc.
This happens at at such a low level that even manually reading the
version from /System/Library/CoreServices/SystemVersion.plist is
intercepted.
Working around this by temporarily setting the SYSTEM_VERSION_COMPAT
environment variable is unfortunately not possible, as it's only read
on process creation/initialization.
The same goes for the kern.system_version_compat sysctl, as once it's
set it can not be changed back to its original value, and it's not
clear whether this sysctl should even be touched.
As long as we have no reliable way of reading the actual current
operating system version, we need to bail out of the deployment
target verification, to avoid false negatives where a plugin or
library, built with a deployment target of say 11.0, is loaded
into an application built with a pre-11.0 SDK, but running on
macOS 11+.
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I9c757a276726175c5dda694ffc1b88f1681d00fb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
And add the macOS specific key.
Pick-to: 6.5
Change-Id: I1e0446a1927ef530322388417b9300ae287752c3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
This addresses two different issues:
- Firstly, we were casting the resolved binding data pointer to
QPropertyProxyBindingData, instead of the d_ptr of
QPropertyBindingData. Fix this by introducing a helper function,
and consistently using it to access the proxy data.
- Secondly, we were not resetting the originalBindingData when the
pointed to object was destoyed. Fix that, too.
Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-110899
Change-Id: I7691c9df5cc26e761f6b0e5f16d152f7f2183208
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
SQLGetData was called with a nullptr for the output buffer to determine
the buffer length which is not allowed. Fix it by passing a valid buffer
with a buffer size of 0.
Fixes: QTBUG-70362
Fixes: QTBUG-110803
Change-Id: I4d547383100714901a4e2ca3b4777326cfab12fe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Optimize the QVarLengthArray usage by passing the prealloc size and
directly initializing the allocated memory instead using a memset
where needed.
Change-Id: I61c6f9387fae63ae0c62ee1e87d3b3a7430369b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Change fromSQLTCHAR() to honor the fact that we know the size of
SQLTCHAR during compile time.
Change-Id: I1cebf2550be7228980083703e143c7577e8ad377
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>