Commit Graph

42095 Commits

Author SHA1 Message Date
Friedemann Kleint
00d9f68c41 Speed up tst_QApplication::testDeleteLaterProcessEvents2()
Quit the event loop once the object is destroyed.

Change-Id: I6df1cfe867daacb6af56eb84646be91d98a2f545
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-31 21:50:37 +02:00
Friedemann Kleint
ae653fc08b tst_QApplication::testDeleteLaterProcessEvents(): Split the test
The test can trigger timeouts in COIN, split into subtests.

Change-Id: I1fa5d52422275f89b2858d90c5979632aa7058e2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-31 21:50:32 +02:00
Volker Hilsheimer
d934fd7f54 Send MouseMove events without buttons if the press closed the popup
With nested popup widgets, pressing a mouse button on the lower
popup will close the active popup. MouseMove events that are generated
before the button is released again should not have that button
included, as it is likely to result in incorrect state handling in
the widget. This change removes all buttons from the MouseMove event,
which is the second best option.

This is mostly consistent with the behavior when closing a popup and
no other popup remains. The widget underneath will get MouseMove
events without the respective button included.

This change doesn't include a fix for the final release event, which
should ideally also not be delivered to the remaining popup, as it
never got a corresponding press event. Qt has already reset the states
in which it stores which widget received the press event at the time
the release is generated, such as qt_button_down and qt_popup_down.
So we can't separate a release grabbed by a newly opened popup (which
we want) from a release to the popup that became active after closing
(which we don't want).
However, widgets can more easily work around this issue, and the risk
of breaking things by changing the code further becomes too high.

Change-Id: I603bbdbc7e7355952d96ab77c5e2d2f1e6f94987
Fixes: QTBUG-82538
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2020-03-30 20:06:20 +01:00
Liang Qi
22fe293038 testlib: add QAbstractItemModelTester::verify()
This amends b3e4be2d8b.

When building testlib with QtGui linked:(use "QT = core-private gui"
in src/testlib/testlib.pro)

    Undefined symbols for architecture x86_64:
      "QAbstractItemModelTester::verify(bool, char const*, char const*, char const*, int)", referenced from:
          QTestPrivate::testDataGuiRoles(QAbstractItemModelTester*) in qabstractitemmodeltester.o

Change-Id: Ideb10ddd6717fed8d9f91f75bbfc9d5a22104730
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-03-30 19:32:06 +02:00
Andy Shaw
2e0c29a4bb itemviews: Use the start of the current selection when getting the range
When doing a shift-select while moving the mouse then the start point
should be based on the start of the current selection and not the
pressed position. If there is no current selection start index, then
we can safely depend on pressed position as this will be the previous
index pressed on.

This resolves an issue introduced by
e02293a76d when fixing QTBUG-78797

Fixes: QTBUG-81542
Change-Id: Ia66c42b220452fdcbc8cfccc05dbc8a3911c3f5e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-03-30 11:17:59 +00:00
Thiago Macieira
bff56f953a tst_QCborValue: Prepare for 64-bit QVectors in Qt 6
Change-Id: Ief61acdfbe4d4b5ba1f0fffd15fe1e921aab0a72
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-27 16:45:59 -03:00
Thiago Macieira
783d574b93 CBOR support: prevent overflowing QByteArray's max allocation
QByteArray doesn't like it.

Apply the same protection to QString, which we know uses the same
backend but uses elements twice as big. That means it can contain
slightly more than half as many elements, but exact half will suffice
for our needs.

Change-Id: Iaa63461109844e978376fffd15f9d4c7a9137856
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-03-27 16:45:48 -03:00
Kai Koehne
0b4ae8e682 MinGW: Fix build with -angle
Since Qt 5.14, debug libs for MinGW don't necessarily have a 'd' suffix anymore.

Fixes: QTBUG-83087
Change-Id: Ia9f499ebed05e96fb056134681a2124c2262fb08
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-27 15:34:12 +01:00
Thiago Macieira
f581b04119 QCborValue: apply a simple optimization to avoid unnecessary allocations
If the map or array is known to be empty, we don't need to allocate a
QCborContainerPrivate.

Change-Id: Ief61acdfbe4d4b5ba1f0fffd15fe212b6a6e77c3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-25 16:22:02 -03:00
Thiago Macieira
02d595946f QCborValue::fromCbor: Apply a recursion limit to decoding
A simple 16k file can produce deep enough recursion in Qt to cause stack
overflow. So prevent that.

I tested 4096 recursions just fine on my Linux system (8 MB stack), but
decided 1024 was sufficient, as this code will also be run on embedded
systems that could have smaller stacks.

[ChangeLog][QtCore][QCborValue] fromCbor() now limits decoding to at
most 1024 nested maps, arrays, and tags to prevent stack overflows. This
should be sufficient for most uses of CBOR. An API to limit further or
to relax the limit will be provided in 5.15. Meanwhile, if decoding more
is required, QCborStreamReader can be used (note that each level of map
and array allocates memory).

Change-Id: Iaa63461109844e978376fffd15fa0fbefbf607a2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-25 16:21:47 -03:00
Thiago Macieira
b7da66132b QCborValue: create a wrapper to set the QCborStreamReader error state
The next commit will need to do so from outside QCborContainerPrivate,
where QCborStreamReader::d can't be accessed (private).

Change-Id: Iaa63461109844e978376fffd15fa0f6f04081bf2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-25 16:21:38 -03:00
Tor Arne Vestbø
02fa39ed22 macOS: Flush sublayers via separate IOSurface backingstores
Flushing sublayers via QImage copies of the root IOSurface was causing
performance regressions due to the constant allocations of new images
each frame.

We now re-use the QCALayerBackingStore implementation for sublayers,
which gives a dynamic swap-chain.

We're still paying the CPU cost of the copy from the root backingstore
to the layered backingstores, as well as the memory cost, but at least
improves the situation.

We do not try to be smart and paint directly into the sublayers,
as that would leave the root backingstore stale, potentially causing
glitches when views are repositioned. Investigating this is left
for future work.

Fixes: QTBUG-82986
Change-Id: I758a3d8e1e40e2ed4fe6bc590a4a5a988d87a3a7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit ce2d68ebe1aefeae78ff2fd8ec5ff7e20790ef69)
2020-03-25 12:20:00 +01:00
Oliver Wolff
f10b31fc1b ANGLE: Fix resizing of windows (Take 2)
Task-number: QTBUG-62475
Change-Id: I0ea17e7875906508941ae64bb396a4236928b0f9
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-03-24 14:25:51 +01:00
Alexander Volkov
cc1d891b8e xcb: Add support for XdndActionList property
This allows to pass and receive possible drop actions from other
processes, including GTK applications.

Fixes: QTBUG-75744
Change-Id: I944edc6fa00f8801a25912e70eb104a647a9fc0e
Reviewed-by: JiDe Zhang <zccrs@live.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-03-23 19:35:19 +03:00
Joni Poikelin
cb509f3aee Doc: fix copy paste errors in border-*-style documentation
Change-Id: I442513ec87e25610898c2102170a5f2bfec5ee77
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-03-21 11:36:04 +02:00
Robin Burchell
2af04860f6 qtimezoneprivate_tz: Apply a cache over the top of timezone data
Constantly re-reading the timezone information only to be told the exact
same thing is wildly expensive, which can hurt in operations that cause
a lot of QTimeZone creation, for example, V4's DateObject - which
creates them a lot (in DaylightSavingTA).

This performance problem was identified when I noticed that a
QDateTime binding updated once per frame was causing >100% CPU usage
(on a desktop!) thanks to a QtQuickControls 1 Calendar (which has a
number of bindings to the date's properties like getMonth() and so
on).

The newly added tst_QTimeZone::systemTimeZone benchmark gets a ~90%
decrease in instruction count:

--- before
+++ after
 PASS   : tst_QTimeZone::systemTimeZone()
 RESULT : tst_QTimeZone::systemTimeZone():
-     0.024 msecs per iteration (total: 51, iterations: 2048)
+     0.0036 msecs per iteration (total: 59, iterations: 16384)

Also impacted (over in QDateTime) is
tst_QDateTime::setMSecsSinceEpochTz(). The results here are - on the
surface - less impressive (~0.17% drop), however, it isn't even
creating QTimeZone on a hot path to begin with, so a large drop would
have been a surprise.

Added several further benchmarks to cover non-system zones and
traverse transitions.

Done-With: Edward Welbourne <edward.welbourne@qt.io>
Task-number: QTBUG-75585
Change-Id: I044a84fc2d3a2dc965f63cd3a3299fc509750bf7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-20 16:58:09 +02:00
Mauro Persano
d535dfea1f Doc: replace QFileInfo::created with birthTime
Change-Id: Ia497febcbf28e4b3babe50fc6f05e12f3d686b91
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-03-20 09:20:54 -03:00
Mitch Curtis
fcbbe7ff21 Merge "Merge remote-tracking branch 'origin/5.14.2' into 5.14" 2020-03-19 16:14:25 +01:00
Mitch Curtis
1480922511 Merge remote-tracking branch 'origin/5.14.2' into 5.14
Change-Id: I34ca28c75b88e882c3f35f182bf01acb22b77637
2020-03-19 16:10:31 +01:00
Timur Pocheptsov
ad68ecf1d9 q_getTimeFromASN1: fix invalid access
No sanitizer is needed, just looking at the code is enough.
It was wrong.

Change-Id: I9df417c137d6b3361c3161865e099a8be40860de
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-19 14:48:08 +01:00
Eskil Abrahamsen Blomfeldt
1a18e138f4 Android: Fix deployment on Windows host
The paths in the build properties require forward slashes
apparently. On Windows, we would default to native backslashes
and they would be stripped from the path. Converting to forward
slashes fixes the problem.

Issue was introduced by dd04fb639b,
since before that, the NDK path was retrieved from the environment.

Fixes: QTBUG-82944
Change-Id: I6c51113efcf671461a5871991b3225a52b95266c
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2020-03-19 10:23:07 +01:00
Timur Pocheptsov
05dd80871c tst_QMenu: make QSKIP message truthful
Since the test was refactored and QCursor::setPosition() replaced
with QTest::mouseMove(), the test is completely crippled on macOS,
since it relies on the parts in widget's code, ifdefed with condition
!Q_OS_OSX and commented as "Cocoa tracks popups". Yes it does,
but not for "fake" events generated by QTest. The original test
was introduced when fixing different problems on non-Apple platform(s)
anyway. Let's make QSKIP message saying the truth.

Task-number: QTBUG-63031
Change-Id: If54f195ccc0d4409cc2e7f4ae0b0fbf43989b286
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-03-18 10:02:29 +00:00
Volker Krause
c53cccc171 Fix JNI signature for the timezone getDisplayName call
Due to the changes in 5.14.1 this code now actually seems to be hit here,
throwing NoSuchMethodError exceptions all over the place and breaking
date/time handling quite spectacularly.

Change-Id: I9bee3de39ec98f86d7944b94e89119505f62dc6c
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2020-03-17 08:30:32 +01:00
Antti Kokko
3d25bbcdf1 Add changes file for Qt 5.14.2
Change-Id: I804e2f07ccbf077c443aef627854c6c411014269
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-03-17 06:16:25 +01:00
Volker Hilsheimer
ffbf5ae11d Fix potential out-of-bounds or nullptr access
This ammends change baed8534bc, which
might have introduced a hard to reproduce segmentation fault when the
screen number is out of bounds, or when the QScreen object doesn't
return a valid pointer for QScreen::handle.

As the issue doesn't reliably reproduce, this is a speculative fix that
adds bounds and nullptr checking.

Change-Id: I0cec0a344e80159ee1723d840f207267a608cef4
Fixes: QTBUG-82807
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-03-17 06:15:55 +01:00
David Faure
97422abcfc QTreeView: don't call model.index(-1, 0) when using spanning items
drawTree() does
    QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos());
    d->hoverBranch = d->itemDecorationAt(hoverPos);
and itemDecorationAt does
    const QModelIndex index = q->indexAt(pos);
which might very well be an invalid index.

Change-Id: I7db98871543bd7e1c57fcc475d2646757bf2bb42
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-03-16 10:44:26 +01:00
Andy Shaw
f45d2dc543 WinRT: Open the URLs via the XAML thread to enable them to be opened
UWP expects these functions to be opened via the XAML thread, so we
ensure this is done by running those functions on that thread.

Change-Id: I57ae3a7d9b45d0b1a00ac23b103386bd34b65c6d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-03-14 11:41:02 +01:00
Friedemann Kleint
1d403ef81a Windows QPA: Fix broken frame geometry when moving windows with native menus
QWindowsWindow::updateFullFrameMargins() which is called
from the screen changed handling does not take native menus
into account.

Since the size of the menu is not known when using
EnableNonClientDpiScaling(), obtaining the correct frame
size requires triggering a WM_NCCALCSIZE message. Extract
the helper forceNcCalcSize() from QWindowsMenu and
use that from updateFullFrameMargins() in case menus are present.

Amends d2fd9b1b98.

Fixes: QTBUG-82580
Change-Id: I306f1faf84e26c88608cb22ffd42eccc848905c3
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2020-03-13 15:11:00 +00:00
Tor Arne Vestbø
d8ab719c08 Fix double scaling of SVG icons on high DPI screens
On a high-dpi screen and AA_UseHighDpiPixmaps set, QIcon will ask its
engine for a scaled-up pixmap. When the icon has been created from a
theme, the engine is a QIconLoaderEngine. For a SVG icon, that engine
would recursively use QIcon to load the scaled-up pixmap, leading to
double scale-up. Fix by bypassing the QIcon API in the SVG case,
loading the SVG icon directly from the SVG icon engine.

Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Fixes: QTBUG-73587
Fixes: QTBUG-75039
Change-Id: I7fba02b6454decb5fcbca9c5a092e75954261dfd
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-03-13 13:12:18 +00:00
Morten Johan Sørvig
bcdf49bcc6 wasm: support emsdk >= 1.39.4
Keep using the old/deprecated behavior for the Qt 5.14
series.

Task-number: QTBUG-74601
Change-Id: Icee99803f300dfa0116a4de75f9fb26d1010625d
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2020-03-13 10:18:43 +01:00
Shawn Rutledge
7d20f86958 Stabilize and rename tst_qmessagebox::expandDetails_QTBUG_32473
This has been flaky on OpenSuSE; if the stored geom.topLeft() is 0,0
it apparently means the window manager (probably kwin) didn't get around
to decorating and repositioning the dialog by the time
qWaitForWindowExposed() returns.  Because we check later to see whether
it moved, we need to be certain of its initial position.

Waiting for the extra "fleece" widget to be shown was based on the
theory that by the time the X server has processed messages related
to that new window, the WM should be done processing the consequences
of the resized dialog window.  But there's no such guarantee, so let's
try removing that.  On the other hand, removing the delay does open
us up to miss a regression (maybe the dialog gets moved after we have
checked that it didn't move).

Rename because we don't name autotests after bugs.

Amends 26ddb586ac

Task-number: QTBUG-32473
Change-Id: I6bbfe2b4baaee389db0d4112f0fec3b7cb9da554
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-03-12 18:46:44 +01:00
Giuseppe D'Angelo
476d296f42 Fix QVarLengthArray documentation
QVLA *does* have iterators and *can* be used with foreach
(... I didn't say it should). Move its description together
with the other containers.

Change-Id: Ib60d1f7b3dc0e8c7004991bd4fdff95b3f23af60
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-03-12 12:16:14 +00:00
Oliver Wolff
6b70c6b866 ANGLE: Fix severe performance regression
The changed buffer usage priority that was introduced in our ANGLE
update caused severe performance regressions for Qt applications.

Fixes: QTBUG-73835
Change-Id: I49839bb272cdeec0027264f2751b88bc149665ad
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
2020-03-12 07:46:38 +01:00
Timur Pocheptsov
c668fd940d Fix 'out of process' autotests
We are, arguably, not testing QProcess and its ability to start or finish,
we test QUdpSocket. If, for some reason (as we discovered on some
specific machines recently) the process does not start or does not produce
any output (canReadLine), we QSKIP instead of failing. Also, all those
QCOMPARE will bypass the part there we stop processes - so must be
RAII-protected.

Fixes: QTBUG-82717
Change-Id: Idfb0d4a483d753f336b3827875eeaf51c79270e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-03-11 18:23:24 +00:00
Allan Sandfeld Jensen
ddd0919bcf Do not crash on skipped Xlib visuals
If XLIB_SKIP_ARGB_VISUALS is set, we might fail to find visuals for
supported configurations.

Task-number: QTBUG-81904
Change-Id: Ib0d26faabe430925881b7f2acfc5361df3af416b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-03-11 16:28:14 +00:00
Andy Shaw
1309205b8b winrt: Update capability management to include IOT namespace
Change-Id: Ib24ecb70454af5ab2e82ebbdc1fed9ef2a52bbb1
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-03-11 12:01:09 +01:00
Allan Sandfeld Jensen
bd3c82f8db Fix non-trivial soft-hyphen line breaks
The effect of the soft-hyphen needs to be updated once the final the
break point has been found.

This change cleans the logic by using two variables keeping track of
soft-hyphen at current evaluated position and at last confirmed break
point. Also adds tests for supression of soft-hyphens in the tight
WrapAnywhere case.

Fixes: QTBUG-35940
Fixes: QTBUG-44257
Change-Id: I7a89a8ef991b87691879bb7ce40cec4a3605fdd5
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-03-10 21:58:21 +01:00
Kari Oikarinen
d6d902a990 Merge 5.14 into 5.14.2
Change-Id: Ib4b26bad47a850cde6253fb3422aae34b2cf622b
2020-03-10 09:43:16 +02:00
Christian Ehrlicher
3702a4c37e QSortFilterProxyModel doc: do not mention deprecated function reset()
QSFPM::reset() is deprecated and begin/endResetModel() should be used.
Therefore adjust the documentation to reflect this.

Fixes: QTBUG-82470
Change-Id: I786b3f25e5674d97d0ef6a0c91342973d5e952e9
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-03-09 06:29:25 +01:00
Marc Mutz
c1bb628572 Port from deprecated std::is_pod to is_trivial + is_standard_layout
The std::is_pod trait is deprecated in C++20; is_trivial
and is_standard_layout exist since C++11.

Change-Id: I4b901d8edf1a55001764445aee9c338d3dc23b21
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-06 18:06:43 +01:00
Friedemann Kleint
7fcc4e0a57 Windows QPA: Do not play sound for QMessageBox::NoIcon
Amends 2f366a63b2.

Task-number: QTBUG-82682
Task-number: QTBUG-81342
Change-Id: I30f465bf432e27828db460f6dbbb59eee0cca8f2
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2020-03-06 13:29:56 +01:00
Allan Sandfeld Jensen
08b9e66347 Fix QDeviceDiscoveryUDev on FreeBSD
Include input.h from the right path.

Change-Id: I016027ab5d6372a8584e04043444a355e7e2d539
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-06 10:57:13 +01:00
Oliver Wolff
7c7bd44669 examples: Fix build for configurations that do not have printsupport
printsupport features are only available if the module is available for
the configuration. Every printer feature check has to be coupled with a
check for the module itself.

Change-Id: Id2ca84e71d5d74463d0ff35e8b18b252a779a883
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-03-05 15:11:36 +01:00
Andy Shaw
2c1b4e37b9 Fix CVE-2020-9327 in SQLite
This was taken from abc473fb8fb99900 in SQLite, ref:
https://www.sqlite.org/cgi/src/info/abc473fb8fb99900

Fixes: QTBUG-82533
Change-Id: I9840e29f19a0b861229987f5b59d8585ba2e55dc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-04 13:37:33 +01:00
Kirill Burtsev
2f52afda8e QLibraryInfo: avoid unneeded conversion for path prefix
Ammends 4ac872639e. Change return type for getPrefix to eliminate
toLatin1/fromLocal8bit conversion of initial value for relocatable
prefix to preserve not-latin1 characters and return valid prefix path.

Fixes: QTBUG-81462
Change-Id: I15cfa49e9e440e257b04dd31803cd1478f3b07f5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-04 12:37:27 +00:00
Volker Hilsheimer
d678827f11 Un-blacklist QElapsedTimer::elapsed test
The test was fixed and metrics show no flaky failures anymore.

Task-number: QTBUG-58713
Change-Id: I50c0844db099f45bb5b7ca51a510bf0318554c44
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-04 10:04:54 +01:00
Thiago Macieira
ae6f73e856 QLibrary: introduce a mutex to protect non-atomic internals
And make pHnd atomic.

The majority of the variables is updated in QLibraryPrivate::load_sys
and updatePluginState(), which get the mutex protection.
QLibraryPrivate::unload_sys() doesn't need a mutex protection because we
have the refcounting.

[ChangeLog][QtCore][QLibrary & QPluginLoader] Fixed a number of race
conditions caused by having two QLibrary objects pointing to the same
library being operated in different threads.

Fixes: QTBUG-39642
Change-Id: I46bf1f65e8db46afbde5fffd15e1a5b3f5e74ea4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-03-03 14:36:32 -08:00
Thiago Macieira
ef92ac5636 QLibrary: stop setting errorString after resolve()
resolve() is technically thread-safe if the library has been loadaed. We
don't promise that, but it's there. More importantly, because
QLibraryPrivate is shared among QPluginLoader and QLibrary that point to
the same file, we can't thread-safely set the error string.

[ChangeLog][Important Behavior Changes] QLibrary::resolve() will no
longer set or clear the error string based on the success of finding the
symbol. The error string will reflect the result of loading the library.

Change-Id: I46bf1f65e8db46afbde5fffd15e1a4f4c2713c17
Reviewed-by: David Faure <david.faure@kdab.com>
2020-03-03 14:36:30 -08:00
Thiago Macieira
f6c1cebe42 QPluginLoader: rework the loading and the caching of instance
There was a race condition in accessing the cached instance factory
member, so rework loadPlugin() to return the cached or newly discovered
instance, with proper, atomic caching. Because I had to change that, I
took the opportunity to fix the QFactoryLoader code that calls
loadPlugin().

Note that QLibraryPrivate::loadPlugin() returns non-nullptr now if the
instance is known, which means the last return in QPluginLoader::load()
will convert to true, not false, if the instance got cached between the
earlier check and the call to loadPlugin(). That's probably what was
intended.

Task-number: QTBUG-39642
Change-Id: I46bf1f65e8db46afbde5fffd15e1a42d2b6cbf2c
Reviewed-by: David Faure <david.faure@kdab.com>
2020-03-03 14:36:28 -08:00
Shawn Rutledge
d9ca61bf0f Add the include for QPointer to avoid MSVC compilation error
It has been reported that 7447e2b337
needs amending to build on MSVC 2019, although it was OK in CI.

Change-Id: Id22c2a3608529abebd66c0e8f401bc6f26f45e18
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-03 22:30:11 +01:00