Commit Graph

39927 Commits

Author SHA1 Message Date
Allan Sandfeld Jensen
5c351da046 Protect against integer overflow in painting transformed images
Makes it safe to sample pixel coordinates above 32767.

Fixes: QTBUG-76829
Change-Id: I5965afef1bd65106fcfc130dd37572309eacbe42
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2019-07-19 11:55:50 +02:00
Tor Arne Vestbø
af683471bd macOS: Add QCocoaWindowManager for dealing with window levels
Moves and improves the logic for lowering splash screens to a dedicated
window manager, which will learn more tricks in patches to come.

Change-Id: I8b8fd1dd78fdaf6f106a59c84d2a59254f3539c3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2019-07-19 10:56:23 +02:00
Tor Arne Vestbø
92563a2453 macOS: Allow overriding NSKeyValueObservingOptions for QMacKeyValueObserver
Change-Id: I6dc0f7c542ccfb768c1cd8688168c415e2c8a087
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2019-07-18 16:00:29 +02:00
Volker Hilsheimer
de775f2e62 macOS: activate correct object when using multiple QSystemTrayIcons
Since we need to set the delegate on the defaultUserNotificationCenter,
which is a gobal object, we have to update the delegate when we show
the message. Otherwise, the last delegate created and set will receive
the notification, and the last QSystemTrayIcon created will emit the
activated signal.

Before clearing the delegate upon destruction, make sure that it's
the right item first.

Also updating coding style in the respective parts of the code, and
plugging a memory leak.

Change-Id: Ife62ae0776a5a610a6fd735b2959b807c3a410c7
Fixes: QTBUG-77003
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-07-18 15:26:49 +02:00
Giuseppe D'Angelo
907923b7ca qmake: fix move semantics
ProFunctionDef is move-enabled, meaning its `m_pro` field can
become nullptr. Its usage in the assignment operator and the dtor
must therefore be protected with a check.

Amends 9c63ad562b.

Change-Id: I0c77b07dc83969565480bbb9d9fc80751d4246b1
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2019-07-18 12:55:33 +00:00
Timur Pocheptsov
334f09b585 tst_http2 - make the test less rough in general
1. Use per-case QNAM objects
2. In a slots (connected to QNetworkReplies) - if an error detected - stop
   the event loop (no reason to continue waiting) and then do normal
   QVERIFY/QCOMPARE things.
3. In tests, check QTest::currentTestFailed after the event loop returned -
   if an error was detected by a slot, no need to continue with QCOMPARE/QVERIFY
   in the test itself.

Task-number: QTBUG-77053
Change-Id: I3827a629a2749becd3dc6eee7fd6994d96441e65
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-07-18 06:18:40 +02:00
Thiago Macieira
69ef6e8212 QStandardPaths: update docs to what $HOME is on iOS
It's not <APPROOT> (any more, or was ever).

Fixes: QTBUG-76911
Change-Id: I6aed4df6a12e43c3ac8efffd15aed22128862c23
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-07-17 22:41:47 -03:00
Qt Forward Merge Bot
d3de20d409 Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-07-18 01:00:20 +02:00
Qt Forward Merge Bot
7576250b1c Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I685000c4f33fb3707b2102fae0b58092107dc8f0
2019-07-18 01:00:08 +02:00
Edward Welbourne
1d8c9978fa QDateTime docs: don't encourage use of deprecated textdate functions
The textdate API methods are deprecated in favor of QLocale; so
suggest use of QLocale in place of them.  Don't credit the deprecated
methods as being used where they aren't.

Change-Id: I0abcb1f69729760ae1b86cb8088e4158c0ad6010
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
2019-07-17 14:25:13 +02:00
Tor Arne Vestbø
d224c762bc macOS: Use correct virtual screen when resolving GL surface format
Change-Id: I8288db85c8e99bf9fccfcfbca7f9e3594d00fa48
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2019-07-17 09:56:15 +02:00
Tor Arne Vestbø
d2e4bde5d0 macOS: Use lambdas instead of Obj-C categories for GL helper functions
Allows us to reference captured variables and keeps the function
local to where it's used.

Change-Id: I609892888720202021862d26a74ceb50e232f356
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2019-07-17 09:55:57 +02:00
Tor Arne Vestbø
7a7fe9dbb3 macOS: Move QCocoaGLContext initialization into dedicated method
Change-Id: I9dc2c400c3d26e9fcfaac04b61c1503229f59dba
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2019-07-17 09:55:31 +02:00
Tor Arne Vestbø
e0a486c77d Tie QPlatformOpenGLContext to its QOpenGLContext before initializing
So that the context can be referenced during initialization.

Change-Id: I9ec69b2431ba1ac6256cb2e969a76f515497e247
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2019-07-17 09:00:57 +02:00
Thiago Macieira
6bd35e4708 Work around Apple Clang's -Wshadow warning
Well, yeah, it technically does...

 qcborstream.h:245:15: warning: declaration shadows a typedef in the global namespace [-Wshadow]
 /usr/include/libkern/OSTypes.h:36:26: note: previous declaration is here

Fixes: QTBUG-75825
Change-Id: Idce141629dd34287808bfffd159ee2a75428bf12
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2019-07-16 21:13:45 -07:00
Thiago Macieira
8abbbb4c48 Fix regression causing QVector::fill w/ same size to not detach
Caused by commit 01301b0b34, which made
vector.resize(vector.size()) not to detach, which was used by fill() and
assumed that detaching happened. The test does not test the resize()
behavior, only that fill() is not broken anymore.

[ChangeLog][QtCore][QVector] Fixed a regression that caused fill() not
to detach, corrupting shared copies.

Fixes: QTBUG-77058
Change-Id: I6aed4df6a12e43c3ac8efffd15b1b527a8007bf3
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2019-07-16 18:09:51 -07:00
Friedemann Kleint
05bb156aaa Windows QPA: Fix emitting of QScreen's changed signals
When changing the primary screen, the various changed signals of
QScreen were out of order. Most notably, the wrong DPI value was
emitted since QGuiApplicationPrivate::processScreenGeometryChange()
checks and emits DPI and orientation as well. Rearrange the code to
assign new the values and emit DPI first.

Task-number: QTBUG-76902
Change-Id: If4037108391c36ab3a8bfcb9b2989d5bea41202f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2019-07-16 22:07:11 +02:00
Paul Wicking
4f26f05869 Doc: Add trailing "." to all \brief commands in QLineEdit
Minor housekeeping.

Task-number: QTBUG-77063
Change-Id: I9c04dd4220c0c2ad2afa51f88df197f5992752ff
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2019-07-16 08:16:24 +02:00
Timur Pocheptsov
7a61cb46e6 tst_http2::flowControlServerSide
fix the bloody test for good - the idea to have a shared QNAM (shared
by test cases in this test) was somewhat wrong to start with.

Fixes: QTBUG-77053
Change-Id: I5755e96ec988e2dd546f527f3f902fc43914b0b7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-15 16:17:16 +02:00
Mårten Nordheim
2a15ec72c0 QHttpSocketEngine: The 'Connection' options are case insensitive
As noted in RFC7230 Section 6.1 the 'Connection' options are case
insensitive.

https://tools.ietf.org/html/rfc7230#section-6.1

Change-Id: I80b98d82eaa5572d38a6c3f99383bc059ec91c54
Fixes: QTBUG-76990
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2019-07-15 13:31:12 +02:00
Qt Forward Merge Bot
a837ec15fe Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-07-13 01:00:33 +02:00
Qt Forward Merge Bot
a3d1fee81b Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I5d2a4fa33b4aa22da39ac045e6b85ab940b8720b
2019-07-13 01:00:21 +02:00
Tor Arne Vestbø
7d3a55cbd2 Remove unused arguments from QWidgetPrivate::create_sys
The public QWidget::create still has them, but we don't need to
propagate them on - that just makes debugging the window creation
flow harder.

The window argument to QWidget::create is technically used to
guard an early exit in the function, but to keep behavior the
same we leave it for now.

Change-Id: Ic0287575aa25f1272e216adc1b75e34d6f55f6d9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-12 14:54:13 +00:00
Qt Forward Merge Bot
38c2b80e65 Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-07-12 15:29:54 +02:00
Tor Arne Vestbø
deac052a40 Revert "Reset QWidget's winId when backing window surface is destroyed"
This reverts commit a9246c7132.

The QWidget machinery is way to fragile to reset the winId under the
feet of QWidget like that. We would potentially need to include all
the logic in QWidget::destroy. This also ties into the flow between
QtGui and QtWidgets during window closing, which is still unresolved.

Change-Id: I168048a63c89796398eb5331a80ce3e5c8d9a208
Fixes: QTBUG-76588
Task-number: QTBUG-69289
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2019-07-12 14:17:43 +02:00
Qt Forward Merge Bot
77d126ccb5 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	configure.pri

Also required s/solid\.color/solidColor/ in a couple of places in:
	src/gui/painting/qpaintengine_raster.cpp

Change-Id: I29937f63e9779deb6dac7ae77e2948d06ebc0319
2019-07-12 12:23:29 +02:00
Alexandru Croitor
3c0ba6675b Fix warnings as errors on macOS with new Xcode 10.2.1
A switch statement was comparing enum values of a different enum.

Change-Id: I578f79b15b1007afaa64cd3a2a80d6a75d3bed77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-07-12 12:18:15 +02:00
Andre Hartmann
f5840944a6 QByteArray: Clarify that QByteArrays always use the Latin-1 encoding
... irrespective from the users current locale.

Fixes: QTBUG-76938
Change-Id: I78810a75ecf9e9f1067363ce56656124b6ddcefd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-07-12 06:46:39 +02:00
Topi Reinio
7d4c9a6f8f Doc: Ensure macOS-specific widget docs are generated on other platforms
The Clang parser in QDoc fails to parse the .mm source files if their
include files are not found. Add a dummy 'AppKit.h' file under the
/doc directory for this purpose, and add its include path to
qtwidgets.qdocconf.

Task-number: QTBUG-77009
Change-Id: Iaa984cb8f860367cbb7aa95808d26fb69d7da349
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2019-07-12 06:19:07 +02:00
Volker Hilsheimer
ae972a1928 macOS: show QSystemTrayIcon message icons in notification popups
The icon provided was ignored, even though NSUserNotification provides
the option to specify a contentImage.

The message popping up will show that image on the right side of the
notification; it will not repace the application icon on the left side.

[ChangeLog][Widgets][QSystemTrayIcon] On macOS, show the icon passed
into showMessage in the notification popup

Change-Id: I8ecda7f893006e74a4f35f37ddc07063ebfe4e83
Fixes: QTBUG-76916
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-07-11 22:50:20 +02:00
Marc Mutz
987dde2965 Optimize and fix handling of QtMessageHandlers
A function may almost always have static storage duration, but that
does not necessarily mean that we can store and load pointers to them
without memory ordering. Play it safe and use store-release and
load-acquire for them (which combines to ordered for the fetchAndSet
call in qInstall*Handler(), as we don't know what the caller will do
with the returned function pointer).

Also change the initial value of the atomic pointer to nullptr.
Nullptr already signified the default handler in qInstall*Handler(),
so the API doesn't change. But by using nullptr to mean default, we
place these variables in the BSS segment instead of TEXT, save dynamic
init, or at least a relocation, and we dodge the smelly comparison of
function pointers, using comparison against nullptr instead.

Also, as a drive-by, put the call to ungrabMessageHandler() in a
scope-guard. Both the message handler, as well as the Qt code calling
it (toLocal8Bit()!), may throw, and that would stop all further
logging. In Qt 5.9, we can't use qScopeGuard(), yet, so use a local
struct calling ungrabMessageHandler() in its dtor.

The code still has one problem: When a logging action is underway, and
another thread exchanges the message handler, we might still execute
code in the old handler. This is probably not a problem in practice,
since no-one will use a dynamically-compiled function for logging
(right? :), but should probably be documented or fixed. This patch
does not address this issue, though.

Change-Id: I21aa907288b9c8c6646787b4001002d145b114a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit cd401b74a1)
(cherry picked from commit ea16c860bd75a35134ebb1d4f3be5db58f4a4e21)
2019-07-11 20:05:19 +00:00
Friedemann Kleint
54684f10e9 QSaveFile: Fix changing the file name after hitting on readonly file
The call to QFileDevice::unsetError() in QSaveFile::open() does
not clear QSaveFilePrivate::writeError. Clear it in addition.

Fixes: QTBUG-77007
Change-Id: I5e5009750f1726d1c74c1b4eb1c33f3a5393fe4f
Reviewed-by: David Faure <david.faure@kdab.com>
2019-07-11 22:00:10 +02:00
Thiago Macieira
d01693733f QDirIterator: don't require NFD normalization on Darwin for validity
HFS+ filesystems do enforce NFD normalization, so the test worked for
those filesystems. But on APFS, the filesystem is normalization-
insensitive but preserves it, so our transformation caused valid files
to be rejected.

This commit also optimizes the solution for all systems too. Instead of
converting from 8-bit to UTF-16 then back to 8-bit (allocating memory in
both steps), we only convert to UTF-16. And if we detect the locale is
UTF-8, then we use the further optimized QUtf8::isValidUtf8 function
that doesn't allocate any memory at all (ditto for US-ASCII, the case of
someone running with LANG=C).

Fixes: QTBUG-76522
Change-Id: Ief874765cd7b43798de3fffd15aa0d81620ad317
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-07-11 11:46:59 -07:00
André de la Rocha
786c588171 Windows QPA: Fix handling of mouse messages synthesized by the OS
The old handler only marked mouse events associated with mouse messages
synthesized by the OS with Qt::MouseEventSynthesizedBySystem when these
messages resulted from touch screen, not tablet input. Quick seems to
depend on this behavior.

Fixes: QTBUG-76617
Change-Id: Ib863d73ae9325f9a19d8a175817fef4e82f7df0b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-07-11 20:03:01 +02:00
Kai Koehne
3f8e754f07 CMake: Properly escape '.lib' in regex
In a CMake regex, you need two backslashes to escape a character. The
.in file therefore needs four backslashes ...

This amends ba4fdd99ff

Fixes:  QTBUG-76698
Change-Id: Ic757354ba596bf020c3ee5e90ee6d2d0fe3ba352
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-11 14:13:19 +00:00
Robert Loehning
3bee5a470a Fix typos in readme
Change-Id: Ifecb1bac475512241de9bcf195955409bb3adaff
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2019-07-11 14:17:08 +02:00
Kai Koehne
de8bd9ec6b Fix build with -no-feature-printer
Skip printsupport subdirectory if printer feature is disabled. Also
removed android-embedded condition for the plugin: Such a
configuration should just disable the printer feature.

Fixes: QTBUG-76941
Change-Id: Ifca7d2311a575c1589ad6a87a775bd016591ee2c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2019-07-11 13:58:36 +02:00
Volker Hilsheimer
cc32226e64 Windows: handle errors correctly when connecting to unreachable host
The previous code handled only some error codes, in a very inefficient
way, for some code paths. This change standardizes error handling using
a helper function that maps winsock WSAE* codes to Qt error codes.

The test for connecting to unreachable hosts or ports is now more
generic, and enabled on Windows, where it passes in local tests,
but dependency on network configuration still makes it fragile,
so ignoring some failures without completely skipping the test.

[ChangeLog][Network][Windows] Correctly emit errors when trying to
reach unreachable hosts or services

Change-Id: Icaca3e6fef88621d683f6d6fa3016212847de4ea
Fixes: QTBUG-42567
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-11 10:46:23 +02:00
Felix Barz
36a15a87de syncqt: Fix module header install target creation
Modified a regular expression in syncqt.pl so that the special case of
a class beginning with another class does not lead to the exclusion of
the first one. This affects the generation of the install target for
generated class headers of Qt modules. Now the expression verifies the
class names are not identical.

Fixes: QTBUG-71323
Change-Id: I210b4d4c3ed64cf189594b95b10aa0e8495a19d2
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2019-07-11 09:50:18 +02:00
Eirik Aavitsland
2d597c0e1a QPixmapCache: guard against usage from non-main threads
Depending on the active QPA plugin, QPixmaps may now be created and
used also in non-main threads. But QPixmapCache is not designed to be
used from such threads, so add guards to ignore such access attempts,
both from application code and from Qt library code.

Such unsafe access would often cause a cryptical "~QObject: Timers
cannot be stopped from another thread" warning; that also disappears
with this fix.

[ChangeLog][QtGui][QPixmapCache] Ignore unsafe access from non-main
threads

Task-number: QTBUG-76694
Task-number: QTBUG-72523
Change-Id: Ia2db37e528aec08bfb48808630bdf5e543689039
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2019-07-10 12:43:23 +02:00
Martin Smith
ffaf3cfc21 doc: Enable a declaration for qdoc
A declaration of fromStdVariant() was not visible to qdoc
because it was ifdef'ed out. This update ensures that qdoc
sees the declaration.

Change-Id: I4b00a895aa61175296ec80806b43311eff4f25ca
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2019-07-10 12:14:13 +02:00
Joerg Bornemann
89aa6e780a Fix determination of host_arch test binary
The host architecture detection binary's file extension is determined by
the host platform, not the target platform. Respect the host variable
that's set in configure.json.

This amends commit d9fb502.

Change-Id: I134cd7cf12d6a6fe458ac5e37c48dd311d6c4418
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-10 10:53:04 +02:00
Joerg Bornemann
605062b21f Fix MinGW cross-build with precompiled headers on Linux
We need localtime_r() in several places. To have this function
declared when including time.h, _POSIX_THREAD_SAFE_FUNCTIONS must be
defined. E.g. qdatetime.cpp includes unistd.h before time.h to define
said macro.

However, this falls apart when precompiled headers are used, because
of the following include chain in qt_pch.h:
qcoreapplication.h -> qobject.h -> chrono -> time.h

This patch ensures that _POSIX_THREAD_SAFE_FUNCTIONS is defined before
including time.h in qt_pch.h by including unistd.h early.

Fixes: QTBUG-76680
Change-Id: I3875072edf37f45492f29d84fc297a9682e11db4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-07-10 10:41:23 +02:00
Volker Hilsheimer
b426cff1e0 Make tst_QGraphicsItem painting tests most robust
Counting absolute paint events is fragile, as there are no guarantees
that a single call to QApp::processEvents only delivers a single paint
event to a widget. As of QTBUG-76566, we see that the items occasionally
receive three calls to paint, which can be simulated by activating other
windows while the test is running and waiting for events to be
processed.

Instead, verify that we do receive any paint events as the first test,
and then verify increments when we expect updates.

This also reverts change 24b9424adc.

Change-Id: Ib51853e918f31acd3aea10d4109c95f34012a29f
Fixes: QTBUG-76566
Reviewed-by: Dimitrios Apostolou <dimitrios.apostolou@qt.io>
Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
2019-07-10 06:17:09 +02:00
Volker Hilsheimer
59b29d03b2 Further stabilization of QGraphicsItem::cursor test
The QTest::mouseMove calls are not reliable, and seem to produce
flakiness, at least on WinRT. Removing them, and only depending on
handling of the synchronously delivered QMouseEVent for simulated
mouse moves.

Also, initialize the expected cursor shape from an empty scene;
this avoids that showing the view with the cursor accidentially
on an item results in the wrong default shape. Remove hard
coded coordinates, just test what we know.

Fixes: QTBUG-73545
Change-Id: I6f81d6b16bb613ec77aaa776d6a80aac739aeb58
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2019-07-10 06:16:52 +02:00
Sze Howe Koh
f4b5fa76d7 [Doc] Fix minor typos
Change-Id: I7e74806218dcc07d800f4ec08e94abce32483f5e
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2019-07-10 07:35:06 +08:00
Allan Sandfeld Jensen
d9fb502b20 Fix android architecture detection
Android is also unix, so can pick up the host 'arch' binary when
rerunning configure. This patch splits the names so we don't end up
confusing target and host binaries.

Task-number: QTBUG-76445
Change-Id: Ib65251a514e45ad8873f523d71c17e13e56ea58a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-09 22:53:48 +02:00
Volker Hilsheimer
89984a8a61 Fix the systray example to only show an icon when requested
The "None" and "Custom icon" cases where using the same value for icon
type, which resulted in both options showing the application icon.

Use -1 to indicate the custom option, and treat all other options
the same.

Task-number: QTBUG-76916
Change-Id: Ib715f5d328175bd6e221b3f507087954fa542838
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-07-09 18:32:48 +02:00
Marc Mutz
0a3107dd30 QHostInfo: fix a race condition on QHostInfoCache::enabled
In auto-test-enabled builds, QHostInfoCache can be enabled and
disabled using qt_qhostinfo_enable_cache() at any time. We cannot rule
out that users use this function, or, indeed, that the auto-test never
gets a threading stress-test. Under the assumption, then, that
QHostInfoCache::enabled can be set by any thread at any time, and is
read by any thread using QHostInfo::lookupHost(), we're presented with
a data race, thus UB.

Fix by making the accesses to QHostInfoCache::enabed atomic. Relaxed
operations are suffcient, as the bool is the only data of interest in
these situations. In particular, access to the cache itself is
protected by the cache's mutex.

We use std::atomic<bool> because QAtomicInteger<bool> doesn't exist on
all implementations, but std::atomic<bool> must. Commit a0faf9e236 set
the precedent that it works.

Change-Id: Ia1766753bb54c5fe8d8447b51a49a96a7a853eef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-09 13:09:24 +00:00
Martin Smith
4bb975717b doc: Add missing class qualifier
A glass qualifier was missing in a \fn command.
This caused clang to report an error. The class
qualifier is added by this ubdate.

Change-Id: I1c4928183f4c8eb1b28f0fde2ce659a1feb24175
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2019-07-09 12:46:08 +02:00