Commit Graph

54058 Commits

Author SHA1 Message Date
Marc Mutz
59600a514b QTest: de-inline QVERIFY_THROWS_EXCEPTION message formatting
Extract Method QTest::qCaught() to take the string handling out of the
header. This should help a bit in speeding up compilation of large
unit test files (provided they use QVERIFY_THROWS_EXCEPTION), although
I have no data to support that.

Since we changed the error message, update the selftest accordingly.

Change-Id: Id4a3c8c34d5df8d0c7a861106d269097f4a6de5c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 09:57:59 +01:00
Yuhang Zhao
405adf3348 Win32: Enable large address aware explicitly
Large address aware is enabled by default in 64-bit
compilers, but not 32-bit compilers. But Qt users
may build 32-bit Qt themself, in this case large
address aware is disabled in fact, and it may cause
some issues. So we pass /LARGEADDRESSAWARE to the
linker unconditionally to make sure large address
aware is enabled for both 32-bit and 64-bit builds.

Microsoft Docs:
https://docs.microsoft.com/en-us/cpp/build/reference/largeaddressaware-handle-large-addresses?view=msvc-170

Change-Id: Idb2603d9ba0ba9ef4477ce1c3174b7c7e8ba76f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-26 16:42:53 +08:00
Volker Hilsheimer
77de4a9bb4 Fix and complete style sheet support for QToolButton
Amends 2b2e7b2ac5, which rewrote the
rendering to remove the conflation of menu arrows and arrow icons, but
introduced double rendering of the arrow icons if only the border was
styled.

Add a baseline test for style sheets, with a test function for
QToolButton configured in various ways and styled with different style
sheets.
The new test case includes a Qt 5 build system so that we can compare Qt
5.15 with Qt 6.

Fixes: QTBUG-98286
Pick-to: 6.2 6.2.2
Change-Id: I09cdc829c1a7e7913df4c3768dbe44b6dba4778b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-26 09:36:07 +01:00
Yuhang Zhao
00ea6f58da d3d11rhi: remove leftover of pre-win10 code
Amends commit 1e085b9e15

Task-number: QTBUG-84432
Pick-to: 6.2
Change-Id: Id48fb6c2a9c7d24f1525975c6c154dbc323bbc25
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-26 13:06:24 +08:00
Mitch Curtis
efb283fb7f Add QTest::failOnWarning
This solves the long-standing problem of not being able to easily
fail a test when a certain warning is output.

[ChangeLog][QtTest] Added QTest::failOnWarning. When called in a test
function, any warning that matches the given pattern will cause a test
failure. The test will continue execution when a failure is added.
All patterns are cleared at the end of each test function.

Fixes: QTBUG-70029
Change-Id: I5763f8d4acf1cee8178be43a503619fbfb0f4f36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 04:47:24 +01:00
Marc Mutz
1edf153a6b Long live QVERIFY_THROWS_EXCEPTION!
Use variable args macros to swallow any extra commas in the
expression. To use this, the type of the exception has to be first.
Use Eddy's suggestion for a new name to avoid breaking the old macro.

[ChangeLog][QtTest] Added QVERIFY_THROWS_EXCEPTION, replacing
QVERIFY_EXCEPTION_THROWN, which has therefore been deprecated.

Change-Id: I16825c35bae0631c5fad5a9a3ace4d6edc067f83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 04:44:26 +01:00
Ievgenii Meshcheriakov
b9be035c62 QTemporaryDir: Set directory permissions at the time of creation
Use new QDir::mkdir() method to set directory permissions at the time
of its creation on systems that support this feature. This removes the
time window when the created directory is potentially accessible to
everybody.

Task-number: QTBUG-79750
Change-Id: I82afee7f0708bfdcc9b3b3978af9a2aef1b8672d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-26 03:39:33 +01:00
Ievgenii Meshcheriakov
174af05400 QDir: Add support for setting directory permissions to mkdir()
This patch adds an overload of the QDir::mkdir() method that
accepts permissions. This allows setting of the directory
permissions at the time of its creation.

[ChangeLog][QtCore][QDir] Added QDir::mdkir() overload that
accepts permissions argument.

Task-number: QTBUG-79750
Change-Id: Ic9db723b94ff0d2da6e0b819ac2e5d1f9a4e2049
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 03:39:33 +01:00
Giuseppe D'Angelo
8c9875893b Q(Multi)Map: prevent dangling key/value after detach()
Q(Multi)Map mutating functions that take reference to a key and/or a
value (e.g. insert(), take(), etc.) must make sure that those references
are still valid -- that is, that the referred objects are still alive --
after the detach() call done inside those functions.

In fact, if the key/value are references into *this, one must take extra
steps in order to preserve them across the detach().

Consider the scenario where one has two shallow copies of QMap, each
accessed by a different thread, and each thread calls a mutating
function on its copy, using a reference into the map (e.g.
map.take(map.firstKey())). Let's call the shared payload of this QMap
SP, with its refcount of 2; it's important to note that the argument
(call it A) passed to the mutating function belongs to SP.

Each thread may then find the reference count to be different than 1 and
therefore do a detach() from inside the mutating function. Then this
could happen:

Thread 1:                         Thread 2:

detach()                          detach()
  SP refcount != 1 => true          SP refcount != 1 => true
    deep copy from SP                 deep copy from SP
    ref() the new copy                ref() the new copy
  SP.deref() => 1 => don't dealloc SP
  set the new copy as payload
                                    SP.deref() => 0 => dealloc SP
                                    set the new copy as payload

  use A to access the new copy      use A to access the new copy

The order of ref()/deref() SP and the new copy in each thread doesn't
really matter here. What really matters is that SP has been destroyed
and that means A is a danging reference.

Fix this by keeping SP alive in the mutating functions before doing a
detach(). This can simply be realized by taking a local copy of the map
from within such functions.

remove() doesn't suffer from this because its implementation doesn't do
a bare detach() but something slightly smarter.

Change-Id: Iad974a1ad1bd5ee5d1e9378ae90947bef737b6bb
Pick-to: 6.2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
7039fb1e42 Skip QTimeZone::checkOffset() if there are no valid zones to test
Change-Id: I62df34fe40b8e89b99912e8ad0d1d2f2f11fd71e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
bcc15f36cc Check for relevant zones existing when adding data rows
tst_QDate::startOfDay_endOfDay_data() naively assumed some zones would
exist. They don't on QNX, apparently.

Change-Id: I3a364964d03f59f5869b4b7639f089dd303180b1
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
0cad974d0d Add a note to save the next reader some confusion
I was briefly confused about why an Etc/GMT+3 test was using GMT as
localtime. Fortunately I worked it out before mis-"correcting" it.

Change-Id: I7b0473c7d3974ef186e1170cf4999aca52aaaf45
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
6437bd240f Skip test if it has no data-rows
On QNX, tst_QDateTime::fromStringStringFormat_localTimeZone_data()
failed to set up any rows for the data-driven tests to fetch, leading
to an assertion failure on trying to fetch a row.

Change-Id: I7c405b1142a8cb6d445b501ea44fe3d440570cf3
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
297f9aa6c8 Add some missing entries to QTest::qExec()'s \sa line
Change-Id: I45300d5f9df519c5edb68d24232830bd0850915a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-26 02:14:51 +01:00
Rami Potinkara
1a87f06916 Android: Set sem_wait m_terminateSemaphore behind an atomic flag
Prevents QML app using QtActivity never calling
AndroidJniMain::startQt..'s to jam as ANR

Pick-to: 6.2 5.15
Task-number: QTBUG-97115
Change-Id: Ibfe8579dbb701068f4896b6d826ff487094bdf56
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-11-26 02:27:49 +02:00
Marc Mutz
9baf1d5256 QAndroidActivityResultReceiver: make uniqueActivityRequestCode() lock- and UB-free
The old code attempted to detect the overflow of the requestCode
variable, but because it didn't do anything about it except warn, it
still ran into the overflow, and, since the variable is signed, into
UB. That means that a clever compiler will just eliminate the warning
as dead code because it can backtrack and see that the condition
guarding it is never true, because otherwise UB happens.

Fix that problem by using a uint counter (unsigned overflow is defined
to wrap) and only convert to int after the check.

Also fix two inefficiencies with the old code:

1. We don't need a mutex just to up a counter in a thread-safe
   way. Upping a shared counter is the prototypical use-case for
   relaxed atomics, so use that. That also solves the problem of the
   non-POD static object at function scope (QMutex) that forced
   compilers to emit thread-safe static initialization code.

2. We had a static variable whose initial value isn't 0, which means
   it can't be in stored in the BSS, but only in the DATA segment. Do
   the trivial transformation of subtracting the offset so the
   variable starts at 0. The offset can be added afterwards.

Pick-to: 6.2
Change-Id: I3560df21d6b4e4201cb6772237780cc8b400631d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-25 13:16:06 +01:00
Marc Mutz
f4e89d58da QVERIFY_EXCEPTION_THROWN: re-throw unknown exceptions
Swallowing unknown exceptions is dangerous business, as the exception
might be a pthread cancellation token, the swallowing of which would
terminate the program.

Instead of returning from the catch-all-clause, therefore, re-throw
the unknown exception.

Fix tst_verifyexceptionthrown failure cases that use
non-std::exception-derived true negative exceptions to not let the
exception escape from the test function.

As a drive-by, pretty up the macro's docs.

[ChangeLog][QtTest][QVERIFY_EXCEPTION_THROWN] Now re-throws unknown
exceptions (= not derived from std::exception) (was: swallowed them
and returned from the test function), in order to play nice with
pthread cancellation.

Pick-to: 6.2 5.15
Change-Id: Ic036d4a9ed4b7683fa67e27af8bcbae0eefdd0da
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-25 13:00:55 +01:00
Toni Saario
8761208aef Gate bic tests behind a manual feature
Bic tests do not work due to bic tests being broken.
A feature enables easier testing of the bic tests.

Change-Id: I15b400ee8f0f877ac2c6c71fc50d51c5e11b330d
(cherry picked from commit 31910cbc09ff219b332aac94afe78c99d34274b3)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-25 08:57:06 +00:00
Luca Di Sera
c880696f06 Doc: Replace use of \oldcode-\newcode
The command-pair was recently deprecated.

The replacement code should produce an output that is equal to the
previous one.

Task-number: QTBUG-98499
Change-Id: If26e0d85a174ebc3858b638c34d7f43637eab46d
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-25 09:55:48 +01:00
Fabian Kosmale
925ad78024 tst_qmetatype: Temporarily disable expensive tests on QNX
The compiler runs out of memory and fails to compile tst_qmetatype.cpp.
Set TST_QMETATYPE_BROKEN_COMPILER from a previous compiler workaround
for QNX to disable the most expensive part of the test.

Task-number: QTQAINFRA-4669
Change-Id: I3a99b6b790dc074e9d1db262e758555fb45e4331
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-11-25 09:53:34 +01:00
Mårten Nordheim
8f8775adf3 QHash: fix thread race around references and detaching
If we detach from a shared hash while holding a reference to a key from
said shared hash then there is no guarantee for how long the reference
is valid (given a multi-thread environment).

Pick-to: 6.2
Change-Id: Ifb610753d24faca63e2c0eb8836c78d55a229001
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-25 08:52:39 +00:00
Mårten Nordheim
a92619d950 QAuthenticator: Filter out algorithms we don't support
Which is anything other than MD5

Pick-to: 6.2 5.15
Fixes: QTBUG-98280
Change-Id: Ifbf143f233ee5602fed1594e3316e6b2adec1461
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-25 08:52:33 +00:00
Eirik Aavitsland
8a883dea1c Update baseline testing framework
Merge in various minor changes and fixes that have been done to the
branched copy in qtquick3d, and clean out some outdated code.

Mostly just coding style fixes and cleanups, but also:

- adds -keeprunning command line parameter, intended for tests that by
  default exits early if it seems the platform is too unstable
  (e.g. crashing) for a meaningful testrun.

- Changes behaviour for fuzzy matches, from SKIP to PASS. The (mis)use
  of QSKIP was done to force log output; now the output is just
  printed by qInfo() instead.

Pick-to: 6.2
Change-Id: I46e77a94cc5b1980ac420086c2ae88dc9b84ef12
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-24 11:47:43 +01:00
Marc Mutz
5750a9728e qmake: don't use magic numbers
Use a local enum to enumerate the different "interesting" keywords.

Task-number: QTBUG-55458
Change-Id: I30a6336072d3184b720d8c016f199572dba87a81
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-11-24 10:47:10 +01:00
Joerg Bornemann
a756a9aa8b configure: Remove vestiges of handling QMAKE_* variable assignments
When qmake and CMake build were both available next to each other, we
answered QMAKE_FOO=bar assignments in the CMake build with an error
message.  This code is never triggered these days and can be removed.

Change-Id: Ifd29283b8ddc86b94c4e6cbce9e9252215e9f2fe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-24 10:47:10 +01:00
Volker Hilsheimer
95907f9be4 Add variations of QPushButton with default property set
Change-Id: Ie928575b131c7031da9a4d735159ba3d14ccad6c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-24 07:40:47 +01:00
Thiago Macieira
84c9fcffee tst_QHashSeed: improve quality of the quality() test
We expect to produce all-bits-set in the combined OR'ed value of the
seed, so instead of counting how many bits got set and reporting that,
simply compare to -1 and count how long it took to get that far.

To make sure, I've increased the number of iterations by 50%.

Change-Id: I89446ea06b5742efb194fffd16ba37b2d93c19ef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-23 20:48:08 -08:00
Yuhang Zhao
e75b1dfe38 Windows QPA: Further cleanup of pre-Win10 code
Mostly a removal of dynamically loaded Win32 APIs.
Since Qt 6's minimum supported platform is Win10 1809
(10.0.17763, code name RS5), all these functions will
be available and no need to resolve them at run-time.

Things not remove:
WinTab functions in "qwindowstabletsupport.cpp".
Not my familiar area, so not touch it.

Pick-to: 6.2
Task-number: QTBUG-84432
Change-Id: I7ad6c3bc8376f6c0e3ac90f34e22f7628efeb694
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-24 09:16:38 +08:00
Marc Mutz
f5f7f78766 QObject: don't #include qproperty.h
The qobject.h header needs QBindingStorage in-size and QBindable
in-name-only. The former was moved to its own header in a previous
commit, which we include now, while the latter can just be
forward-declared. This allows dropping the qproperty.h include from
qobject.h.

[ChangeLog][Potentially Source-Incompatible Changes] The qobject.h
header no longer implicitly includes qproperty.h. If your code depends
on the transitive include, explicitly include <QProperty> where
needed.

Task-number: QTBUG-97601
Pick-to: 6.2
Change-Id: I8d6320f5978e20dfc394d2b1e49f626b99529c37
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-23 21:23:44 +01:00
Marc Mutz
0347b4ee5e QTest: mark qFail() as cold
Unit tests should not fail, so a call to qFail() is by definition
exceptional. Therefore, mark the function as cold. It probably doesn't
matter in the grand scheme of things, but it also doesn't cost much.

Change-Id: I0cafcfa65ff285812155d0687deded8d26cf4efd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 21:23:41 +01:00
Thiago Macieira
5eda43de89 tst_QHashSeed: reset the global seed in each iteration
QHashSeed is not a random number generator (though it uses one). It
returns the same value over and over again unless you reset it to a new,
random seed.

Fixes: QTBUG-98480
Change-Id: I89446ea06b5742efb194fffd16ba36601f08d794
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-23 12:19:32 -08:00
Joerg Bornemann
3f56950862 Move macdeployqt and windeployqt from qttools to qtbase
Having all *deployqt tools in qtbase will allow us to couple deployment
support more tightly with the build system.

Change-Id: I299efdacfa6b66a303bb3996ff3ff84e723210a5
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-23 21:11:45 +01:00
Yuhang Zhao
1e9f9a4b7d QOperatingSystemVersion: cache the retrieved version
It won't change during runtime, so make it a static
variable to avoid fetching the information repeatedly.

Change-Id: I430ceba218f9f3515558736238d1d5a74cf59419
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-23 09:59:55 +00:00
Timur Pocheptsov
3fcdb6cb6e QCocoaMenuBar: set the app's 'Window' menu
To enable a list of windows the app has open in the Dock's menu.
Not to surprise existing applications with a 'Window' menu where
they did not have it before, make the item hidden.

Fixes: QTBUG-59433
Change-Id: I1ac3d3de69f4313f39c4631dc4b68bf6e096532a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-23 08:35:22 +00:00
Yuhang Zhao
e01c25e859 QtBase: replace windows.h with qt_windows.h
We have some special handling in qt_windows.h,
use it instead of the original windows.h

Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 12:53:46 +08:00
Marc Mutz
4c7759cae2 Restore src/tools/moc/util/generate_keywords.pro
The file was inadvertently removed in
ad2da2d27a.

Pick-to: 6.2
Change-Id: Iaaf74d7ae382b0c9487fb25a58632dfc5be6538d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-23 00:36:34 +00:00
Marc Mutz
0fc2cde89b qapplicationstatic.h: fix syncqt warning
Warning was:
  "QtCore: WARNING: src/corelib/kernel/qapplicationstatic.h includes QMutex when it should include QtCore/QMutex"

Comply.

Change-Id: Ifc74b4f8052b7e95f86cab9a01a7e91bcbc3022d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-23 01:36:34 +01:00
Marc Mutz
9d79e5f26c QVLA: Self-Encapsulate Fields
Use member functions to access some (combinations of) fields in
preparation of moving said fields to base classes:

   s + ptr  → end()
   s        → size()
   ptr      → data() (or begin(), depending on context)
   a        → capacity()

Fixed a const-incorrectness issue detected by the change.

Task-number: QTBUG-84785
Change-Id: I2218d57559208c9d77b8860d419979e92f140e13
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-22 21:20:54 +01:00
Eirik Aavitsland
8ce3693856 QImageReader: check allocation limit for minimum 32 bpp
Also, as a driveby, add an environment variable so the limit can be
changed at runtime.

[ChangeLog][QtGui][QImageReader] When checking allocation limit during
image reading, the memory requirements are now calculated for a
minimum of 32 bits per pixel, since Qt will typically convert an image
to that depth when it is used in GUI. This means that the effective
allocation limit is significantly smaller when reading 1 bpp and 8 bpp
images.

Pick-to: 6.2 6.2.2
Change-Id: If1b204d413973b0975eea531e29c260fdcec931d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-22 14:29:20 +01:00
Heikki Halmet
f1c280f31f Add support for Microsoct Visual Studio 2022 official release
MSVC2022_PREVIEW can be removed later when MSVC2022 official
release has been merged

Task-number: QTQAINFRA-4540
Pick-to: 6.2
Change-Id: I7756b53b1cd5863d21c1c1e3bb19373f6f0cf8fa
Reviewed-by: Ville-Pekka Karhu <ville-pekka.karhu@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
2021-11-21 20:22:39 +02:00
Sona Kurazyan
102f7d31c4 Add support for combining multiple QFutures
[ChangeLog][QtCore] Added QtFuture::whenAll() and QtFuture::whenAny()
functions, returning a QFuture that becomes ready when all or any of the
supplied futures complete.

Task-number: QTBUG-86714
Change-Id: I2bb7dbb4cdc4f79a7a4fd494142df6a0f93a2b39
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-20 10:28:29 +01:00
Thiago Macieira
3b49aa72fe Q{CoffPe,Elf,MachO}Parser: check that the magic string is present
Commit 2549a88ba2 changed the ELF and
Mach-O parsers to return an offset to the actual data header, not the
magic string, which we stopped searching for anyway. This commit brings
such a validity check back and adds it to the new COFF PE parser.

Change-Id: Iccb47e5527544b6fbd75fffd16b8b2252a76f179
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 22:51:04 -08:00
Thiago Macieira
892d5607d0 QPluginLoader: add COFF PE file parser
Fixes: QTBUG-67461
Docs: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
Change-Id: I5e52dc5b093c43a3b678fffd16b77bf9a8f2b17e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 22:51:03 -08:00
Thiago Macieira
235173175b CMake: reorganize the QT_FEATURE_library portion of CMakeLists.txt
No need to attempt to compile both qelfparser and qmachoparser in all
systems.

Change-Id: Iccb47e5527544b6fbd75fffd16b7ee5a1555a7a8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 22:51:02 -08:00
Thiago Macieira
09c58614db QString::fromUtf16: use qustrlen
We have it.

Pick-to: 6.2
Change-Id: Iccb47e5527544b6fbd75fffd16b901fe4d2920a7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 18:33:07 -08:00
Marc Mutz
fd8f81f385 Re-apply "QReadWriteLock: replace (QWaitCondition, QMutex) with std::(condition_variable, mutex)"
This reverts commit 1283ee3245.

We now have wrappers around std::mutex and std::condition_variable
that fall back to QMutex and QWaitCondition on the broken Integrity
toolchain. Use them.

Change-Id: I881aa931167b845b489713048b57ccc5f79d4237
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-20 02:38:41 +01:00
Marc Mutz
229f356cef Short live q20::ssize()!
Extract the definition of q20::ssize() from tst_qanystringview.cpp,
where it had to be placed for its backport to 6.2.

Change-Id: I3f758c98a4b1efd453f4fc044b8d3f1a89de62d1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-20 01:38:41 +00:00
Marc Mutz
2fbe460245 QAndroidActivityResultReceiver: avoid double(triple)-lookup
The code used the if (!contains()) { insert() } anti-pattern,
necessitated by Qt's deviation from the STL of allowing insert() to
overwrite an existing entry, causing two lookups of the same key.

Fix by recording the size prior to the execution of the indexing
operator and taking a size increase as the cue to populate the (new)
entry. This way, we look up the key only once.

Also fix two instances of double lookup caused by the if (contains())
{ value() } anti-pattern.

Change-Id: I961fe45ec571aa94aff5dd578f2276e7b74d800d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-20 02:38:40 +01:00
Ievgenii Meshcheriakov
07034b765e Use Authz API to query permissions info in Windows filesystem backend
Microsoft documentation for GetEffectiveRightsFromAclW function that
was used previously has this at the top of the page:

> GetEffectiveRightsFromAcl is available for use in the operating
> systems specified in the Requirements section. It may be altered
> or unavailable in subsequent versions. Instead, use the method
> demonstrated in the example below.

This says to me that the function is deprecated. In addition to
that, it is not able to handle ACLs that are not in "canonical"
order, returning ERROR_INVALID_ACL. Such ACLs are useful to
represent POSIX permissions in Windows, and are produced by
Cygwin for example.

This patch uses Authz API referenced by the message quoted above.
The used API is available starting from Windows XP/Windows Server
2003. This API also allowe to perform access checks given access
token, and so allows to use similar code all permission checks.

Task-number: QTBUG-79750
Change-Id: I8b11ff3cc83cd9ed5bfb2ce9432a375a122cdbbf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 23:35:48 +01:00
Tor Arne Vestbø
db780c4ca5 xcb: Return standalone image from QXcbBackingStore::toImage()
Otherwise the original backingstore image will detach from the
m_xcb_image data on the next backingstore paint or scroll.

Pick-to: 6.2
Change-Id: I73f68d9c2e7c106951541831a5df8b97695f2001
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-19 21:55:45 +01:00