Because the local `seed` variable shadowed the member one, this test
was run for each QFETCH_GLOBAL with the same data and seed. That
doesn't make sense, so make the test use the member variable `seed`,
as all other tests already do.
Since zero is one of the seeds coming from QFETCH_GLOBAL, drop the
seedless calls to qHash(), too.
Amends 64bfc927b0.
Pick-to: 6.6 6.5 6.2
Change-Id: I1e22ec0b38341264bcf2d5c26146cbbcab6e0749
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The old code only tested with seed = 0 and seed = 1045982819, the
latter being a "random number", which, however, fits into
32-bits. Since Qt 6.0 increased the seed from uint to size_t, amend
the test to actually test a seed value with some of the upper half of
bits set, too, also in 64-bit mode.
While we're at it, also test with each seed's bits flipped for extra
coverage.
Remove a static assertion that prevented testing seeds with the MSB
set.
Pick-to: 6.6 6.5 6.2
Change-Id: I5ed6ffb5cabaaead0eb9c01f994d15dcbc622509
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Since showing the native popup on macOS is blocking and processes events
the QComboBox might get destroyed while the popup is open. Guard against
this by using QPointer and returning early (dismissing the scope guard
that would otherwise reset the menu's parent, writing to freed memory).
The problem is then that the native popup remains visible, as the
destructor of QComboBox calls cleanupNativeCombobox which destroys the
platform menu (i.e. the QCocoaMenu instance), but that doesn't dismiss()
the popup. Add a call to dismiss() to the QCocoaMenu destructor to make
sure that destroying the menu closes it first.
Fixes: QTBUG-116155
Pick-to: 6.6 6.5
Change-Id: If0ac19796603667f4c8e80c302710dc4c9aded50
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
We might be drawing glyphs outside the main thread, which triggers
the main thread checker for our access to NSApplication from
qt_mac_applicationIsInDarkMode().
Change the CoreText font engine to pull out this information from
the theme instead, and teach the theme to only updates its color
scheme on the main thread.
Pick-to: 6.6
Change-Id: I02be713d9705c6e0c21107db7f7de039182f601d
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
The change was needed because std::fill_n(), which takes it, does not
handle enum type on VxWorks. As it was anonymous with only one member,
it could be changed to static constexpr int.
Task-number: QTBUG-115777
Change-Id: I7cb4d267ad21f6b963d851e30bc91042fbf5c15a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The NSAlert messageText and informativeText properties only allow
plain NSString, so we need to opt out of the native dialog if the
user has requested rich text for any of these properties.
Fixes: QTBUG-116757
Change-Id: I3fd44ec94adad1dda1ed4dede46450a8a525d35f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
The default minimum date and maximum date for QCalendarWidget are not
the 'earliest and last dates' that QDate class can handle. Instead,
minimumDate is initialized to November 25, 4714 BCE (first Julian day),
and maximumDate to December 31, 9999 CE.
Pick-to: 5.15 6.2 6.5 6.6
Change-Id: Ice9289853a7e825ff2b31567efb81cdfb7d678a1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Fix "non-void function does not return a value in all
control paths" warning.
Change-Id: Idc58319b2704895ec56decabbdad67ffbf633ad7
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Enable using them in a const context, for instance when
calling "const" native API.
Change-Id: I0b3fe33ab7fabf4bda8565d4de88bb21367d356e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
processWindowScreenChangedEvent() returns early if the
screen for the (top-level) window has already been updated,
for instance by a call to handleScreenRemoved(). This was
preventing us from updating the DPR and window geometry.
Move the code a slot connected to QWindow::screenChange,
which gets emitted for all windows (also child windows),
whenever the screen changes.
Pick-to: 6.6
Fixes: QTBUG-116232
Change-Id: I44701fd001ab1fd54efe9c8451c6a58cfc0b285f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
We check for a valid event dispatcher when waking up,
but there was no check after processing queued events,
and processEvents() would continue with a stale this
pointer if one of the queued events happened to delete
the application object.
Fix this by checking if this is still a valid pointer
after processing events.
Fixes: QTBUG-116330
Pick-to: 6.6 6.5
Change-Id: Ic4d91298986847e6095ce9daea51a4b974106c06
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
operator=(~) and assign(~) share similar names but, until now, have not
shared the same functionality. This patch introduces the usage of
QList::assign() within the non-sharing assignment operator to
effectively boost efficiency by reusing the available capacity.
Task-number: QTBUG-106201
Change-Id: I01a0511af336f2f410158a07d91e5759c8ff46db
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit reverts 2d77051f9d.
When requesting an allocation of size 0, we will actually get
a nullptr.
qarraydata.cpp:
~~~
if (capacity == 0) {
*dptr = nullptr;
return nullptr;
}
This will let the Q_CHECK_PTR trigger falsely. Such an occurrence was
initially detected during the cmake_automoc_parser build-step.
Found-by: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-106196
Pick-to: 6.6
Change-Id: Icb68c5dd518c9623119a61d5c4fdcff43dc4ac5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- don't use QMap::values, just iterate over QMap directly
- use const methods to avoid implicit detatch
While touching code, use isEmpty() to check container instead of size() with 0
Change-Id: I300b5f123f339dc92a4f932bd0b356f31ead3589
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
QStaticLatin1StringMatcher is a static templated Latin-1 Boyer-Moore
string matcher which can be case sensitive or not. It should be used
when the needle is known at compile time so there is no run-time
overhead when generating the skip table.
The convenience functions qMakeStaticCaseSensitiveLatin1StringMatcher
and qMakeStaticCaseInsensitiveLatin1StringMatcher should be used to
construct the matcher objects.
Green Hills Optimizing Compilers are currently not supported.
[ChangeLog][QtCore] Added QStaticLatin1StringMatcher, which can be used
to create a static constexpr string matcher for Latin-1 content.
Task-number: QTBUG-100236
Change-Id: I8b8eed1e88e152f29cbf8d36d83e410fafc5ca2c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
The id -1 is the one of a default-constructed QHostInfo (invalid).
It's also returned by various codepaths to mean a lookup failure.
Attemping to abort its lookup should simply be ignored.
Change-Id: I0413dd248a890f57195e4f5b5baea011b6737102
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The latest XDG spec (0.8) defines XDG_STATE_HOME that does not exist
in QStandardPaths::StandardLocation.
Some Linux distributions clean XDG_CACHE_HOME on restart which makes
XDG_STATE_HOME useful as a path for saving application state.
This commit adds StateLocation and GenericStateLocation to serve as a
StandardLocation for XDG_STATE_HOME for all platforms.
This commit also updates docs and tests to fit the new changes.
[ChangeLog][QStandardPaths] Added StateLocation &
GenericStateLocation to StandardLocation
Change-Id: I470602466c37f085062cc64d15ea243711728fa5
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QWidget::setVisible is virtual, and called via hide() by both the
QDialog and the QWidget destructor. A dialog that becomes invisible
when getting destroyed will at most execute the QDialog override.
Subclassing QDialog and overriding setVisible() to update the state
of the native platform dialog will not work, unless we explicitly
call hide() in the respective subclass's destructor.
Since e0bb9e81ab, QDialogPrivate::setVisible is
also virtual, and gets called by QDialog::setVisible. So the clean
solution is to move the implementation of the native dialog status
update into an override of QDialogPrivate::setVisible.
Add test that verifies that the transient parent of the dialog
becomes inactive when the (native) dialog shows (and skip if that
fails), and then becomes active again when the (native) dialog is
closed through the destructor of the Q*Dialog class. The test of
QFileDialog has to be skipped on Android for the same reason as the
widgetlessNativeDialog.
Fixes: QTBUG-116277
Pick-to: 6.6 6.5
Change-Id: Ie3f93980d8653b8d933bf70aac3ef90de606f0ef
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This allows us to control whether to run this particular test in ASan
mode or with specific loggers or not. Adding the expected log output for
tst_silent for other loggers is left as an exercise to the reader.
Change-Id: Ifa1111900d6945ea8e05fffd177f1548c8c8e714
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This reverts commit f20adcde30. The
implementation had the right idea, but this is not expected to work
reliably in C++. It's jumping out of several frames without cleaning
them out properly and our ASan-based memory leak-checker has started
complaining (the next commit will move this test elsewhere).
==19313==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 258 byte(s) in 1 object(s) allocated from:
#0 0x7ffa505c8e48 in __interceptor_malloc (/usr/lib64/libasan.so.5+0x109e48)
#1 0x7ffa4f2d7ff9 (/home/qt/work/install/lib/libQt6Core.so.6+0x896ff9)
#2 0x7ffa4f2d834d in QArrayData::allocate(QArrayData**, long long, long long, long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x89734d)
#3 0x7ffa4f23b700 (/home/qt/work/install/lib/libQt6Core.so.6+0x7fa700)
#4 0x7ffa4f1f6cc8 in QString::reallocData(long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b5cc8)
#5 0x7ffa4f1f68a7 in QString::resize(long long) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b58a7)
#6 0x7ffa4f2092ff (/home/qt/work/install/lib/libQt6Core.so.6+0x7c82ff)
#7 0x7ffa4f209e09 in QString::vasprintf(char const*, __va_list_tag*) (/home/qt/work/install/lib/libQt6Core.so.6+0x7c8e09)
#8 0x7ffa4ed0d83d (/home/qt/work/install/lib/libQt6Core.so.6+0x2cc83d)
#9 0x7ffa4ed114a9 in QMessageLogger::fatal(char const*, ...) const (/home/qt/work/install/lib/libQt6Core.so.6+0x2d04a9)
#10 0x5641d2604c40 in tst_Silent::messages() /home/qt/work/qt/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp:77
#11 0x5641d26050fb in tst_Silent::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/testlib/selftests/silent/silent_autogen/include/tst_silent.moc:118
The restoration of the signal handler (which QtTest now has) is also
wrong: this needed to use sigaction() instead.
Change-Id: Ifa1111900d6945ea8e05fffd177f14fbc09a1d7d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
They can (it's just very, very unusual).
Fixes: QTBUG-116695
Pick-to: 6.5 6.6
Change-Id: I2b24e1d3cad44897906efffd178178f1542e67f2
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Signals are blocked explicitly, so the modelReset signal that would
normally make the view update the accessibility framework does not work.
Update accessibility explicitly.
Pick-to: 6.5 6.6
Fixes: QTBUG-114423
Change-Id: Iba6f0b9dfb258e85111326184d7899bf0570a5c1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Fix a potential nullptr access in
QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed() on accessing to
QAbstractNetworkCache::data(). It is not yet clear in what cases
cached data can be null, especially if metaData is present,
but we have user reports of such crashes.
Amends a6776de0c7
Fixes: QTBUG-116788
Pick-to: 6.2 6.5 6.6
Change-Id: I548065c6f809d9d45db6dd785c28acbdc77621e2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Nothing in those files uses QPair; and a local build finished fine without them.
Task-number: QTBUG-115841
Change-Id: I669cfecaa9129bce6b31e464826287f138b159db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
An assert that checks in debug mode is morally equivalent to an
assumption/contract in release mode. Rechecking that an assumption is
true is pointless (it's true by definition), so the code for the case
the check fails is effectively "dead".
Right now Q_ASSERT(x) doesn't turn into Q_ASSUME(x) because some
compilers still have poor codegen (and basically emit a check, even in
release mode). With C++23's [[assume(x)]] we may reconsider that. As
soon as we do it, this code is no longer theoretically dead but
practically dead.
Refactor the code so that the check is done unconditionally, and
if it fails, we assert (in debug mode). In release, we protect users
from a broken backend (which may cause an endless loop of user code
re-requesting the same permission, so it's worth avoiding it).
Change-Id: If0e70e7d88a585ce16ec4838ba7be747652d8155
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Having a context object is the common case, so it's worth optimizing
for it. Remove the routing through a metacall event, which isn't needed,
in favor of a simple queued invokeMethod. Also, always provide a context
object when calling the slot, even if one wasn't provided by the user;
simply use the "sender" object, that is, the internal QObject that is
activating the slot. (This way we match the semantics context-less
connect() overload, which uses the sender object as a context.)
Change-Id: I72051fc48cbda5729145557f15cec4693ffde6ce
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
It makes sense (in my opinion) to have the top-level CMakeLists.txt
to include and call certain commands that should be controlled by
qtbase, to avoid submodule update difficulties when we want to do
changes in qtbase that shouldn't concern the top-level file.
Create cmake/QtBaseTopLevelHelpers.cmake and move some pre-existing
code from the top-level CMakeLists.txt into separate functions that
are defined in qtbase.
This file will be included in the top-level one and said commands will
be called there.
This also prepares for qt_print_build_instructions not call
qt_internal_qt_configure_end anymore, because it will be called
by the top-level project.
Pick-to: 6.6
Change-Id: I1fe3490001cf441d742c64b2ef1f267cd4362f6a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Before this change, the dirty feature code only checked for
differences between FEATURE_foo and QT_FEATURE_foo, without taking
into account modified INPUT_foo values that might passed via the
configure script.
This led to issues in certain scenarios when reconfiguring with the
configure script.
For example configuring with -gui / -DINPUT_gui=ON and then with
-no-gui / -DINPUT_gui=OFF would fail saying
'Feature "widgets": Forcing to "ON" breaks its condition'
This happens because the widgets feature depends on gui being
available, but because INPUT_gui modifications don't trigger the dirty
feature re-eval code, we don't recompute the value of widgets.
Extract the code that takes into account the INPUT_foo variables into
a separate function, and use it both when computing feature values and
also when detecting dirty features.
This means any non-matching INPUT_foo variables will now also trigger
dirty feature checking.
Use the same function to replace the duplicate code we have to early
initialize the developer-build, no-prefix and pkg-config features.
Pick-to: 6.6
Task-number: QTBUG-112957
Change-Id: I775cf70b48291a659b0fecf7cb9570ec12735bca
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
To be able to reconfigure Qt with modified feature values using the
configure script, and take into account INPUT_foo values, we need to
ignore FEATURE_foo values. But we can't always ignore FEATURE_foo
values, because users might want to toggle them by editing
CMakeCache.txt or using an IDE.
What we can do is tell CMake we are configuring via the configure
script, in which case we can mostly be sure that any passed
INPUT_foo values should have higher priority than pre-cached
FEATURE_foo values.
We also need to remove all the cached INPUT_foo variables after they
have been used for feature computation, so that subsequent
reconfigurations where an INPUT_foo is not passed anymore, doesn't
cause a feature to accidentally reuse the previous (stale) value.
Pass -DQT_INTERNAL_CALLED_FROM_CONFIGURE=TRUE to CMake when configuring
via the configure script, and use that as a marker to make INPUT_foo
values have a higher priority.
This needs to be done centrally in qt_evaluate_feature and also in a
few more locations where we check INPUT_ values, like the developer
build and pkgconfig features.
Because QT_INTERNAL_CALLED_FROM_CONFIGURE would become a cached
variable, we want to remove it at the end of the configuration phase,
so that future 'cmake .' reconfigurations are not considered to be done
via configure.
To do that, we unset it right at the end of
qt_build_repo_end in a per-repo build, and in the final
qt_print_build_instructions call in a top-level build.
The latter needs a cleaner fix in follow up commits in qt5.git and
qtbase.
Pick-to: 6.6
Task-number: QTBUG-112957
Change-Id: I3fd338092041ef09e3f5a4dfbaf61da5deea0514
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Previously if Qt was configured with -developer-build, configure
would pass to CMake -DINPUT_developer_build=ON, which will ensure that
both FEATURE_developer_build and QT_FEATURE_developer_build are set to
ON.
Then if somebody tries to toggle FEATURE_developer_build to OFF in
the CMakeCache.txt and rerun cmake, the feature will bounce back to ON,
due to the code in QtSetup.cmake that doesn't take into account if
FEATURE_developer_build is already defined, and thus reset it based
on the value that is cached in INPUT_developer_build.
Change the checks for INPUT_developer_build and INPUT_no_prefix,
to take into account the defined-ness of their
FEATURE_ counterparts.
If they are defined, ignore the INPUT_ values.
This allows toggling the FEATURE_ variables and also aligns with
the INPUT_ handling behavior that we have in qt_evaluate_feature which
ignores INPUT_ values once the FEATURE_ is defined.
While this aligns the behavior with other features, there is still a
problem.
If you first configure without -developer-build,
and FEATURE_developer_build is set OFF, and then reconfigure with
-developer-build, because FEATURE_developer_build is already defined,
the INPUT_developer_build=ON is ignored.
This is a problem for other features as well and will be handled in a
follow up change.
Pick-to: 6.6
Task-number: QTBUG-112957
Change-Id: I4f31157b0e7963e4d43e28062a585e939ceea0c1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Before this change, if a user toggled a FEATURE_foo variable, we only
recomputed the value for dependent features who's CONDITION would break
with the new value. If the CONDITION was not broken, the dependent
feature value would remain unchanged.
For example if FEATURE_developer_build was OFF, and the user
toggled it to ON, the FEATURE_private_tests value would remain OFF,
because OFF is a valid value for private_tests' CONDITION.
But we would like FEATURE_private_tests to become ON if we toggled
FEATURE_developer_build to ON.
To address this case, we need to recompute features who's dependent
feature values have changed.
The algorithm introduced by this change is:
- keep track of initial dirty features, aka track when FEATURE_foo is
different from QT_FEATURE_foo. We expect FEATURE_foo to be the
variable that a user toggles in the cache file or an IDE.
- when evaluating feature values, collect feature dependencies from
the various expressions given to options like CONDITION, AUTODETECT
- if any feature dependency is marked dirty, reset the feature value
to its auto-computed value and mark the reset feature as dirty
- repeat for all feature evaluations
Because feature evaluation is eagerly recursive, we will successfully
reset all features that need resetting.
To ensure against unforeseen breakages, allow disabling this behavior
by configuring with -DQT_NO_FEATURE_AUTO_RESET=ON
Adjust some of the messages to contain more details.
Note that the pre-existing behavior of resetting feature values when
the condition can't be satisfied, stays. For example if
FEATURE_developer_build is OFF and FEATURE_private_tests is manually
toggled to ON, it will reset to OFF
because its condition can't be satisfied (developer_build is still
OFF).
Amends 61943aefd6
[ChangeLog][Build System] The build system will now try to recompute
configure features when dependent feature values are toggled by the
user.
Pick-to: 6.6
Fixes: QTBUG-96936
Task-number: QTBUG-85962
Task-number: QTBUG-112957
Task-number: QTBUG-116209
Change-Id: Ib627f3675df8a3b08f4936cdc9c51f2d6e15f58c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
It makes more sense for it to live next to the other feature code.
Pick-to: 6.6
Task-number: QTBUG-96936
Task-number: QTBUG-85962
Task-number: QTBUG-112957
Task-number: QTBUG-116209
Change-Id: I8438e6fce9deaa5e709e4b0e2e1ea4eb0600a89a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
... by using valueBypassingBindings() when accessing the properties
from the setters.
Also adjust initModel() to use the raw pointers instead of accessing
the property when comparing the value and doing all connections.
This change is safe, because initModel() is a private method that is
only called from the constructors of the class and the setter.
Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I6ecde571aeed74077099c6bf8f66736ba14d29f8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>