Commit Graph

39274 Commits

Author SHA1 Message Date
Alex Trotsenko
4e695eece7 QWindowsPipeWriter: do not clear the buffer in thread pool callback
In a blocking application, receiving the results of write operations
must be synchronized with the waitFor...() functions. But, clearing
the buffer in another thread can cause the code

  localsocket.write(...);
  QVERIFY(localsocket.bytesToWrite() > 0);

to fail unexpectedly, if the socket has been disconnected between
the calls.

So, defer resetting the buffer until checkForWrite() is called.

Change-Id: I8c21036aab6a4c56d02c0d9a18d4bbce52d724f4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-18 10:46:35 +03:00
Giuseppe D'Angelo
51e28dc54f QIconLoader: code tidies
Turn QThemeIconEntries into an owning container (std::vector of
unique_ptr), so that code using QThemeIconInfo doesn't have to
manage ownership (and forget to do so, and cause bugs like
QTBUG-93050).

The fallout is mostly on isEmpty() vs empty(); as drive-by fixes:
* use auto;
* use make_unique (no raw news);
* turn a few indexed loops into range-based ones;
* streamline an if-else-if chain;
* turn a !(a == b) condition into a != b.

Change-Id: Ie3ac9de57c80ed3184ec0d15c847f81306ef48ca
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-18 09:41:49 +02:00
Zhang Hao
33238ea2c6 Fix QTextEdit cursor rectangle vertical positioning
When there are characters with different pointsize in QScriptLine,
the value of si.descent is less than sl.descent, which will cause
the y value of the cursor rectangle to be too large.
If si.descent is less than sl.descent, the height of the cursor
rectangle is equal to base plus si.descent.
Amends e99a883bd3

Fixes: QTBUG-96288
Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Pick-to: 6.1 6.2
Change-Id: I4a8566b32cfa75d8ca1a584f5e8e577c5c9caf0d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-18 00:55:36 +00:00
Edward Welbourne
1c6d6b7c0d Fix name used for qmath.h in an include
Pick-to: 6.2
Change-Id: I9be8d4cc33d75a806a1ecf9950d7bac330abe9ea
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-17 17:54:10 +00:00
Giuseppe D'Angelo
d48db627f3 QVersionNumber: fix iterator/pointer mistake
The dataFitsInline and setInlineData functions take a pointer/size
pair, not an iterator/size pair. The code was working because QList
iterators implicitly convert to pointers -- but that's sloppy,
just use the list's data() function instead. Do a similar change
for the constructor taking an initializer_list, for symmetry.

Change-Id: I2cec191620185b3b08169c4051296eb610f14ecf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-17 17:29:24 +00:00
Kai Köhne
6faa6cb1d7 Doc: Add version and description to Qt-DBus documentation
This makes sure that the Qt version is part of the HTML title.

Pick-to: 6.2
Change-Id: I2ad8535a9289616d21c18bd9e92d4a91f6faced0
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-17 17:54:09 +02:00
Edward Welbourne
7a4b586f4b Remove conditioning on Android embedded
It is no longer handled separately from Android.
This effectively reverts commit 6d50f746fe

Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-17 17:30:14 +02:00
Giuseppe D'Angelo
d8fd2425fb QCoreApplication: enforce non-null arguments when sending/posting events
Passing nullptr as receiver and/or as an event parameter to sendEvent,
postEvent, etc. is meaningless. It's also something that users can check
for. Therefore, it should not be allowed. Note that the current code
already relies on the arguments not to be null, albeit "indirectly"
(e.g. they get dereferenced without any null checks).

Hence: add asserts that check for non-null in all the relevant
codepaths, except for the ones in which there's currently just a
warning; for those, add a Qt 7 note.

Change-Id: Ia4c58551de88a5d1003f09efa448c1330b6cb122
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-17 16:48:45 +02:00
Laszlo Agocs
0cea6384ae android: Implement nativeResourceForContext
To bring the plugin on par with xcb and eglfs in this regard.

New code has a better way to query these via
QOpenGLContext::nativeInterface() (or, more correctly, will have a
better way once the ability to query the config and display is added
in a follow up patch), but having some symmetry between the EGL-based
plugins won't hurt.

This is relevant in particular with OpenXR: not knowing the EGLConfig
makes it impossible to use the API on Android:
https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrGraphicsBindingOpenGLESAndroidKHR

Pick-to: 6.2
Change-Id: I163aed070096a4b58d3f650906c2f70ea31b3231
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-17 14:48:45 +00:00
Laszlo Agocs
0dbed05bbc rhi: vulkan: Reset state more aggressively
...when starting a render/compute pass.

This matches most other backends in fact, the Vulkan backend has
just certain historical differences, and is complicated due to the
fact that it has the option of using secondary command buffers for
passes that specify ExternalContents (to support the case of wanting
to issue direct Vulkan commands in a code block surrounded by calls
to beginExternal and endExternal).

Not resetting state such as the currently bound index buffer when
starting a pass quickly blows up when two consecutive render passes
use different settings, one targeting the primary while the other
the secondary command buffer. Instead of further complicating the
logic, just reset the relevant state in every begin(Compute)Pass.

Comes with an autotest that is crafted so that it manages to
downright crash when run with Vulkan without the fix to the backend.

Fixes: QTBUG-89765
Pick-to: 6.2
Change-Id: I8dc47bd179c17d45a0556ec31200dc90c4b67ca5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-17 16:48:44 +02:00
Tor Arne Vestbø
c70bb357cc Fix loading of OpenSSL on macOS versions that ship its own OpenSSL
The unversioned libcrypto.dylib that's shipped with macOS 10.15 will
result in a crash if loaded, with a message saying that the unversioned
library should not be loaded, as it doesn't provide a stable ABI.

Task-number: QTBUG-95249
Pick-to: 6.2 5.15
Change-Id: I49325e5d675155e90840cc93623549f725bc77b4
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-17 16:09:51 +02:00
Tor Arne Vestbø
28b14b966f Deduplicate maybeQuitOnLastWindowClosed handling
The functionality now lives in QGuiApplication, and is triggered
by QGuiApplication and QApplication after dispatching the close
event to the window.

The slight difference between how a Qt GUI and Qt Widget app
determines if a window should contribute to the close-on-quit
behavior has been abstracted into a QWindowPrivate helper.

The additional checks that were in place for skipping out of
the whole maybeQuitOnLastWindowClosed machinery have been kept.

Task-number: QTBUG-53286
Change-Id: I81bd474755f9adb3a2b082621e5ecaa1c4726808
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-17 14:56:19 +02:00
Tor Arne Vestbø
1b0cb84212 Fix QGuiApplication command line options documentation for X11
Fixes: QTBUG-96600
Pick-to: 6.2 5.15
Change-Id: Ic3670b952d97270cce4f0a8df8bba79e934e4a6d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-17 14:56:19 +02:00
Liang Qi
bb4b40b7e1 Revert "Qt xcb: remove false detects of Qt::GroupSwitchModifier"
This reverts commit 25a7034d78.

The change makes the 5th modifier key broken, which is more
serious than Backspace key doesn't work in CapsLock on.

And we don't have a better solution for both of them now,
perhaps it's better to keep the old behavior in 6.2 LTS.

Task-number: QTBUG-49771
Fixes: QTBUG-95108
Fixes: QTBUG-95289
Pick-to: 6.2 6.2.0 5.15
Change-Id: Ie5d0aafa562b5097e089cafc83ae227c75c6d752
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-17 13:32:00 +02:00
Mitch Curtis
fae419a8e6 macOS: Use new QPlatformTheme::appearance() function
Instead of qt_mac_applicationIsInDarkMode().

Task-number: QTBUG-94859
Change-Id: Ib64c081adfafb2843a7593d0e35668cce70cffd0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-17 13:32:00 +02:00
Mitch Curtis
2248487c6c Add QPlatformTheme::Appearance for detecting light/dark modes
And implement it on Windows and macOS.

Fixes: QTBUG-83908
Fixes: QTBUG-94859
Change-Id: I7b0c062adf5d4dbaefa64c862ab8ab1348809d71
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-17 13:31:59 +02:00
Tor Arne Vestbø
b6200de5d0 Don't unload libraries on Darwin-based operating systems
We can't guarantee that the library didn't define Objective-C classes
that still have lingering references, resulting in warnings such as:

 Attempt to use unknown class 0x10e52e110.

And possibly crashes such as:

 thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00007fff203829ee libsystem_kernel.dylib`__ulock_wait + 10
    frame #1: 0x00007fff203fa0c5 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 162
    frame #2: 0x00007fff2026226b libobjc.A.dylib`unmap_image + 85
    frame #3: 0x000000010001e11f dyld`dyld::removeImage(ImageLoader*) + 557
    frame #4: 0x000000010002291d dyld`dyld::garbageCollectImages() + 956
    frame #5: 0x000000010002e35d dyld`dlclose + 191
    frame #6: 0x00007fff203cf1c9 libdyld.dylib`dlclose + 183
    frame #7: 0x0000000103f9f2f1 libQt6Core_debug.6.dylib`QLibraryPrivate::unload_sys(this=0x000000011ba2c7d0) at qlibrary_unix.cpp:294:9
    frame #8: 0x0000000103f93f3f libQt6Core_debug.6.dylib`QLibraryPrivate::unload(this=0x000000011ba2c7d0, flag=UnloadSys) at qlibrary.cpp:614:36
    frame #9: 0x0000000103f971fb libQt6Core_debug.6.dylib`QLibraryStore::cleanup() at qlibrary.cpp:425:22
    frame #10: 0x0000000103f970f9 libQt6Core_debug.6.dylib`qlibraryCleanup() at qlibrary.cpp:447:5
    frame #11: 0x0000000103f970d1 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #12: 0x0000000103f930f5 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #13: 0x00007fff202e5d25 libsystem_c.dylib`__cxa_finalize_ranges + 316
    frame #14: 0x00007fff202e6010 libsystem_c.dylib`exit + 53
    frame #15: 0x00007fff203d1f44 libdyld.dylib`start + 8
    frame #16: 0x00007fff203d1f3d libdyld.dylib`start + 1

  thread #5, queue = 'com.apple.root.user-interactive-qos', stop reason = signal SIGABRT
    frame #0: 0x00007fff203a356e libsystem_kernel.dylib`__abort_with_payload + 10
    frame #1: 0x00007fff203a4fbd libsystem_kernel.dylib`abort_with_payload_wrapper_internal + 80
    frame #2: 0x00007fff203a4f6d libsystem_kernel.dylib`abort_with_reason + 19
    frame #3: 0x00007fff202749e3 libobjc.A.dylib`_objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 114
    frame #4: 0x00007fff20274971 libobjc.A.dylib`_objc_fatal(char const*, ...) + 135
    frame #5: 0x00007fff20255ccb libobjc.A.dylib`lookUpImpOrForward + 881
    frame #6: 0x00007fff2025539b libobjc.A.dylib`_objc_msgSend_uncached + 75
    frame #7: 0x00007fff22f368d6 AppKit`-[_NSWindowTransformAnimation setCurrentProgress:] + 42
    frame #8: 0x00007fff22f37a8a AppKit`__55-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:]_block_invoke + 31
    frame #9: 0x00007fff22d0774f AppKit`NSPerformVisuallyAtomicChange + 132
    frame #10: 0x00007fff22f379dc AppKit`-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:] + 172
    frame #11: 0x00007fff22e9a184 AppKit`-[NSScreenDisplayLink _fire] + 180
    frame #12: 0x00007fff2362f0b4 AppKit`___NSRunLoopTimerCreateWithHandler_block_invoke + 34
    frame #13: 0x00007fff204c6be9 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    frame #14: 0x00007fff204c66dd CoreFoundation`__CFRunLoopDoTimer + 927
    frame #15: 0x00007fff204c623a CoreFoundation`__CFRunLoopDoTimers + 307
    frame #16: 0x00007fff204ace13 CoreFoundation`__CFRunLoopRun + 1988
    frame #17: 0x00007fff204abf8c CoreFoundation`CFRunLoopRunSpecific + 563
    frame #18: 0x00007fff2123d607 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    frame #19: 0x00007fff22f378f0 AppKit`-[NSAnimation(NSInternal) _runBlocking] + 453
    frame #20: 0x00007fff22f376ae AppKit`__42-[NSAnimation(NSInternal) _runInNewThread]_block_invoke + 97
    frame #21: 0x0000000104edb032 libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #22: 0x0000000104edc264 libdispatch.dylib`_dispatch_client_callout + 8
    frame #23: 0x0000000104ef04ac libdispatch.dylib`_dispatch_root_queue_drain + 828
    frame #24: 0x0000000104ef0d3f libdispatch.dylib`_dispatch_worker_thread2 + 127
    frame #25: 0x0000000104f7eac7 libsystem_pthread.dylib`_pthread_wqthread + 244
    frame #26: 0x0000000104f7dae3 libsystem_pthread.dylib`start_wqthread + 15

This has been e.g. observed when a QNSWindow isn't closed and released
at application quit as expected. Although that is a corner case that
shouldn't happen, the general case is still valid.

Fixes: QTBUG-96208
Pick-to: 6.2 5.15
Change-Id: I6c9d220e6f5389707baf7ae983f3156e8e51c316
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-09-17 13:31:59 +02:00
Ivan Solovev
fb3549fc47 Introduce QDoubleValidator::fixup()
The provided implementation tries to fix positions for the group
separator.
In case of scientific notation it can also converts the value to
normalized form.
It uses QLocale::FloatingPointShortest internally to convert the
double value back to string, so the number of decimals may change
after calling this method.

Change-Id: I963bc5f97b653e2bb912f4b95b09a4d1ee201e7f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-17 09:55:11 +02:00
Craig Scott
d47278fd09 Ensure _qt_is_android_executable is set for internal executables too
The _qt_is_android_executable property is normally set by the
_qt_internal_create_executable() command. But various other internal
commands don't route through that and go through
qt_internal_add_executable() instead. The former is used only by the
public API, the latter only by the internal API. Refactor both so that
the internal one calls the public one. This ensures all targets receive
the same base settings, including the _qt_is_android_executable
property.

Fixes: QTBUG-96085
Pick-to: 6.2
Change-Id: I157356872c9d942d7be5f1abbbcbac97961b1f40
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-17 13:57:27 +10:00
Laszlo Agocs
eda1276f80 rhi: document serializedLayoutDescription
The docs are internal still but won't hurt to keep them up-to-date.
At the same time, enhance the QRhiRenderPassDescriptor
serializedFormat() docs as well, with appropriate notes about the
intended usage of the "serialized" data.

Pick-to: 6.2
Change-Id: I8425fff625903468621e3b09d089b345fada85f4
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-09-16 22:58:22 +02:00
Laszlo Agocs
43a42fa196 rhi: Allow testing renderpass compatibility without the objects
Follow what has been done for QRhiShaderResourceBindings. Have a way
to retrieve an opaque blob (that just happens to be a list of integers)
so that a simple == comparison can be used to determine compatibility
even when the objects from which the blob was retrieved are no longer
alive.

The contract is the following:

bool a = rp1->isCompatible(rp2);
bool b = rp1->serializedFormat() == rp2->serializedFormat();
assert(a == b);

Pick-to: 6.2
Change-Id: I45e7d05eeb6dfa2b2de474da0a0644912aaf174a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-09-16 22:58:17 +02:00
Laszlo Agocs
c5a3cabce0 rhi: Note in the docs that texture copies expect a matching format
Pick-to: 6.2
Change-Id: I0a1fb042ec2a3983ffbd146ff9bdc9af20134fa5
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-09-16 22:58:11 +02:00
Waqar Ahmed
b21403992e QTextDocumentLayout: remove multiple calls to lineHeightType
Get LineHeightType once and reuse the value. There still are 2 calls
to lineHeightType from inside the QTextBlockFormat::lineHeight but
leaving them cause they need a bigger change.

Change-Id: I4016a5e483a0358d43f73d174a74545d4f3be338
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-09-16 20:30:04 +05:00
Kai Köhne
643b58a429 Rewrite Qt Resource System overview
Restructure the Qt Resource System page to make the content more
accessible, and coherent:
- Focus less on the .qrc file format, but the overall use cases
- Treat CMake as first-class citizen
- Make it more obvious when to use :/, and when qrc:/

Some details that were deemed unnecessary were removed:
- details about the internal naming of the .cpp file when
  qmake is used.
- References to QDir::addSearchPath() and the search path list were
  removed. They relate IMO only indirectly to the Qt resource system.
- A lot of the explanation around Q_INIT_RESOURCE/Q_CLEANUP_RESOURCE
  were dubious at best.

Pick-to: 6.2 6.2.0
Fixes: QTBUG-95126
Fixes: QTBUG-94977
Fixes: QTBUG-59394
Task-number: QTBUG-88044
Change-Id: I04b64f2366631b2106f047de121daf5fdb01073d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-09-16 15:30:04 +00:00
Laszlo Agocs
d55a6891d1 rhi: gl: Have a way to state GL_TEXTURE_RECTANGLE is wanted
Added specifically to support the deprecated CVOpenGLTextureCache on
macOS, because Qt Multimedia still needs a way to use that when the
applications requests using OpenGL instead of Metal.

Follow what we did for GL_TEXTURE_EXTERNAL_OES, and add a flag that
simply makes all our glBindTexture calls use the
GL_TEXTURE_RECTANGLE[_ARB] target.

Pick-to: 6.2
Change-Id: If818b13a9f520cdb8bdc16de84a3ca0e18ad6c33
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-16 17:04:35 +02:00
Luca Di Sera
10eedd175e Doc: Centralize RFC documentation-links in rfc.qdoc
In the effort of repairing broken links as per QTBUG-96127,
a series of RFC links referring to `tools.ietf.org/html/*` were modified
to point to the new address that the site redirected to.

To simplify executing a similar task and to diminish the duplication of
manually inserted urls, the already existing `rfc.qdoc` file, containing
`\externalpage` commands directing to RFC locations, was enhanced with
links to all RFCs that were mentioned in the current documentation, so
as to aggregate this common category of links.

All links pointing to a `ietf` domain inside QDoc documentation blocks
were then changed to use the newly provided external-references.

Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-16 15:52:27 +02:00
Tor Arne Vestbø
0246bfd40a Close QDialog via QWidget::close()
By going via QWidget::close() we ensure that if there's a QWidgetWindow
backing the dialog (which is almost always the case), we will plumb down
to QWindow::close(), resulting in QEvent::Close events to the QWindow.

Since we don't want QDialog subclasses to receive a call to a closeEvent
override that they didn't receive before (and which they might interpret
as rejection or cancellation), install a temporary event filter that
eats the QCloseEvent resulting from the call to close().

Task-number: QTBUG-53286
Change-Id: Ie8f6f0cb3160acfd5865dc74f0a7b6d87f838724
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-16 14:24:00 +02:00
Tor Arne Vestbø
8aa1fc6f12 testlib: Gracefully handle messages outside of test function in JUnit reporter
Fixes: QTBUG-96543
Task-number: COIN-755
Pick-to: 6.2
Change-Id: I2334597319f3595f37f48c9811f667e57b99df28
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-16 11:22:50 +02:00
Tor Arne Vestbø
bedc588698 Always reset close-status of QWidget when trying to close
Move the status setting and resetting back into handleClose so that we
don't end up with it being set if handleClose is never called in response
to a close attempt. This can happen when QWindow's platform window has
already been destroyed.

Since QWindow::close handles that case gracefully and returns true,
we can safely call it multiple times.

Add test coverage to verify that we get exactly those close event
calls that we want.

Change-Id: Ica77bf17c26d923c3b79b1e5a688addbc88a6277
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-15 18:53:57 +02:00
Morten Johan Sørvig
83419fb8a3 macOS: convert mask region to native geometry
QWindow::mask() returns a region in device independent
geometry which can’t be used directly by the platform
plugin.

Pick-to: 6.2 5.15
Task-number: QTBUG-94770
Change-Id: I76279bc74cfabe315178327938f485f4447568be
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 16:19:39 +00:00
Volker Hilsheimer
b020ec6ada macOS: don't block CMD+H while a popup is open
The shortcut hides the application, which works in native apps such as
Xcode or Safari also while a popup menu (or combobox drop down) is open.

This essentially reverts 29104c85db, which
introduced the blocking of CMD+H to prevent the popup stack in the Cocoa
plugin from going out of sync. With that stack gone after the previous
commits, this is no longer a problem.

Task-number: QTBUG-82626
Task-number: QTBUG-96450
Task-number: QTBUG-58727
Pick-to: 6.2
Change-Id: I35603d971741f03b793b7839b183b7ab37200647
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:49:35 +02:00
Volker Hilsheimer
65c9acc5f5 macOS: remove the popup stack from QCocoaIntegration
Since popup handling is now done exclusively by Q(Gui)Application, we
don't need to keep track of the popup stack in the Cocoa plugin anymore.

Fixes: QTBUG-96450
Change-Id: I869f36f52bc2210b6c92efd9425502de4122c553
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:49:35 +02:00
Volker Hilsheimer
1e5249bfa4 macOS: remove mouse and key grabbing logic from Cocoa plugin
For QGuiApplication with QWindow, no other QPA plugins do
so, and for QApplication with QWidgets, QApplication implements popup
functionality consistently.

Task-number: QTBUG-96450
Change-Id: I47489296e0e470d8948ca7858d0a2608c58b2975
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:49:35 +02:00
Volker Hilsheimer
a6279b74e2 macOS: Remove duplicate code closing popups on window interaction
After 70b94eea10, all popups are closed
on mouseDown within the window frame. As with native applications, the
popup is closed on press, and before the press is delivered to the frame
(ie before the jewel is shown as depressed).

The previous notification handlers for window moving, minimizing, and
closing can now be removed, together with the alternative implementation
of closePopups that relies on the Cocoa plugin maintaining its own
popup stack.

This reverts 048e66a11d.

Task-number: QTBUG-96450
Task-number: QTBUG-77833
Change-Id: I165f3caa64bf9a7b4c4d5455ca33e87029d75f73
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:49:34 +02:00
Volker Hilsheimer
6880b6319c macOS: Use QGuiApplication popup APIs in Cocoa plugin
This removes more dependencies to the Cocoa plugin managing its own
popup stack.

Task-number: QTBUG-96450
Change-Id: Id01577739af525a34728f27b790b9aaac29705f2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:49:34 +02:00
Volker Hilsheimer
276943c8b7 Make the closeAllPopup helper virtual in QGuiApplication
QPA plugins might have to close popups for events that are not delivered
to QWindow or QWidget instances. For instance, the Cocoa plugin has to
explicilty close popups when the user clicks into the window frame.

Expose this functionality through a virtual in QGuiApplicationPrivate,
and move the QApplication implementation from a static helper into the
override.

Task-number: QTBUG-96450
Change-Id: I52be5710c8d7515b9ae2e4bbadb069df4b3ed546
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:49:34 +02:00
Tor Arne Vestbø
62b658ee8e doc: use \note in QKeyEvent documentation
Pick-to: 6.2
Change-Id: I0924f5a540ab5e58f7830c1af099ce6e44287811
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-15 17:49:34 +02:00
Craig Scott
4f96af37b2 Allow finalizers to be delayed to later in the same directory scope
Deferred CMake calls are executed in the order they are created.
Sometimes, a deferred call created after a call to qt_add_executable()
or qt_add_library() needs to be executed before target finalization.
For example, a file may be written using a deferred write, but the
finalizers might need that file to exist.

Provide an internal _qt_internal_delay_finalization_until_after()
command that can be called to let finalization know it has to defer
to later. Target finalizers will check an internal property for IDs
recorded by that command and will re-defer itself if it detects that
any of those haven't run yet.

Task-number: QTBUG-96290
Pick-to: 6.2
Change-Id: Ia791e99339bab351eff0d675a552393e524490e8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-16 01:31:35 +10:00
Tor Arne Vestbø
2f6d572dad macOS: Compute NSWindow background color without checking styleMask
The check for styleMask == NSWindowStyleMaskBorderless to decide whether
to clear the NSWindow background was broken, as NSWindowStyleMaskBorderless
has the value 0, but is only supposed to be compared to its companion
NSWindowStyleMaskTitled (with value 1). A window can perfectly well be
NSWindowStyleMaskBorderless and NSWindowStyleMaskMiniaturizable e.g.,
so by comparing directly to NSWindowStyleMaskBorderless instead of
masking to the first bit first we ended up making miniaturizable
windows non-translucent.

We now check the Qt::FramelessWindowHint directly, and also whether
the window is opaque. Ideally we'd have QWindow flags that could
plumb WA_NoSystemBackground from Qt Widgets, as well as a background
color property on QWindow to control the system background, but
in the meantime we'll have to use the FramelessWindowHint heuristic.

The QWidget docs have been updated to reflect this.

Task-number: QTBUG-95042
Pick-to: 6.2
Change-Id: I0d40eecace60883c205ebb8c76cef1092cdf1144
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-09-15 17:06:10 +02:00
Morten Johan Sørvig
088b364e4b QEventDispatcherWasm: handle EventLoopExec
Call emscripten_set_main_loop like the old GUI event
dispatcher did, with one difference that requestAnimationFrame
updates are now no longer handled by the event dispatcher.

Change-Id: If02d90ae9c45d7b38999567d733a237af842cded
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 17:06:10 +02:00
Morten Sørvig
46039092bd Use QHighDpi::toNativeWindowGeometry()
This function implements the isTopLevel() logic, which
we now don’t have to duplicate at each call site.

Change-Id: Ic8b857aa7cd3c3c23d5e950d9f50b66c81ba3ccf
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 14:23:03 +00:00
Ievgenii Meshcheriakov
1afd562b0b QThreadPool: Fix restarting of expired threads
Ensure that expired threads have actually finished before attempting
to restart them. Calling start() on a thread that is not yet finished
does nothing.

Add a regression test into tst_qthreadpool that attempts to trigger
reuse of expired threads and verifies that all submitted tasks
execute.

Fixes: QTBUG-72872
Pick-to: 6.2
Change-Id: I2109b628b8a4e91491115dc56aebf3eb249646b5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-15 15:46:53 +02:00
Ivan Solovev
797039eb20 qlocale_mac: make sure that helper functions return QVariant
QLocale treats a null QVariant returned from the QSystemLocale::query()
as a signal to fall back to CLDR implementation.
In Qt 5 QVariant(QString()).isNull() was returning true, so we could
easily return an empty QString() to fall back to CLDR.
In Qt 6 the QVariant() behavior has changed.
This patch makes sure that all the helper methods in macOS system locale
implementation return a null QVariant() when they fail to provide any
reasonable value.

Task-number: QTBUG-84877
Pick-to: 6.2
Change-Id: I85be3b1463b1366f737e912c99bc11e37af98c62
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-15 10:30:08 +02:00
Ivan Solovev
cc22857d1e QAndroidSystemLocale: add missing day and month format handling
This patch adds support for previously missing Narrow format, as well
as standalone day name handling for QAndroidSystemLocale

Task-number: QTBUG-84877
Pick-to: 6.2
Change-Id: Ib74fb8f0e12f03ab96022abaf26ac9039ffaa60b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-15 10:30:01 +02:00
Ivan Solovev
61343b5a3f Teach QLocale::system() to use narrow format
QLocale::system() was not making use of QLocaleFormat::Narrow, always
treating it in the same way as QLocaleFormat::Short.
This patch fixes the issue for day and month names.

The implementation falls back to CLDR if system locale fails to
provide some data.

Pick-to: 6.2
Task-number: QTBUG-84877
Change-Id: Ia37e59dbf02d7a5e230f2767d294b9ab7de37f33
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-15 10:29:55 +02:00
Ivan Solovev
05d336620c Fix system locale instantiation
Construction of the static QLocalePrivate called defaultIndex()
and systemData() in an implementation-dependent order, but
defaultIndex() needs to be called after systemData().
So move the systemData() call that's used to ensure it all stays
up to date to before the static initializer.

Pick-to: 6.2
Change-Id: I801b678c01b4e4ddd4de16e9aead7167ec4477f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-15 10:29:50 +02:00
Thiago Macieira
21dd9b96a5 QElfParser: stop trying to look into the .rodata section
The return code NoQtSection was not being handled at all, so hasMetaData
remained equal to false. This was probably not intended, but has been
like that since Qt 5.0. See previous commit for details.

Change-Id: I42eb903a916645db9900fffd16a4445eff9a082c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-09-14 12:25:54 -07:00
Thiago Macieira
42ec48d819 QPlugin: make the macros match the scanning code for ELF systems
For ELF platforms with a GCC-compatible compiler, the QElfParser has
been ignoring the .rodata section ever since Qt 5.0 commit
7443895857 ("Remove support for Qt 4 style
plugins"). That change removed handling of return value
QElfParser::NoQtSection from the ELF parser, which meant that the
plugins without a .qtmetadata section were never considered plugins. In
other words, for those systems, the __attribute__ macro is mandatory.

For systems with a GCC-incompatible compiler, there were only two in Qt
5.x's lifetime: Oracle/Sun Solaris with SunCC and IBM AIX with IBM xlC
compiler. Neither compiler supports C++17 according to [1], so they
can't be in use in Qt 6. IBM xlC now comes with a Clang-based front-end
for users who need Qt 6 and the OpenIndiana distribution of Open Source
Solaris has been using GCC since 2012.

So make the macros mandatory from now on.

[1] https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B17_features

Change-Id: I42eb903a916645db9900fffd16a443745446cc64
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-14 12:25:54 -07:00
Thiago Macieira
de9d7b0b25 QElfParser: remove one more unnecesary variable from the ELF parser
There's no need to keep this variable in the class.

Pick-to: 6.2
Change-Id: I2de1b4dfacd443148279fffd16a35775d56d3e45
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-14 12:25:54 -07:00
Thiago Macieira
33a870afae QElfParser: don't attempt to parse ELF files of the wrong endianness
There's no sense in continuing to parse. We'll never be able to load
such a plugin anyway. This simplifies the code generation a lot because
now all the read<T> calls become unconditional qFromUnaligned<T>, which
is just a memcpy(), which for primitive types the compiler will simply
emit a memory load into a register.

Task-number: QTBUG-96327
Pick-to: 6.2
Change-Id: I2de1b4dfacd443148279fffd16a3574daf010635
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-14 12:25:54 -07:00
Thiago Macieira
a8083ff47a Q_DECLARE_INTERFACE: rework to use more inline functions
That way, we can add the NOLINTNEXTLINE comment to suppress clang-tidy,
which otherwise flags all usage of const_cast in C++ code.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a247b96d223772
Reviewed-by: Rui Oliveira
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-14 19:25:54 +00:00
Ievgenii Meshcheriakov
884e5c2c75 QDataStream: Add reminders to remove operators for qfloat16
Having I/O operators defined for incomplete types causes hard
to diagnose problems when types with template conversion
operators are used as arguments to signals or slots.

Removing qfloat16 operators is not possible before Qt 7
because of backward compatibility.

Task-number: QTBUG-93499
Change-Id: Ifa296bb58c45a06abf79dbe5666a666adaa8eab9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-14 15:08:58 +00:00
Shawn Rutledge
9ecce4dff4 Adjust src/corelib/serialization/qdatastream.[h/cpp] for 6.3.0
Change-Id: I9809d6122c6d3c5ad5753d52679f4ac67a17e3d4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-09-14 11:08:30 +00:00
Tor Arne Vestbø
198c24a4e2 macOS: Move handleMouseEvent: to MouseAPI category
Fixes warning of method definition not found.

Change-Id: I87866785d1564e29fc356c033ae8cf972548ea7f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-14 12:18:02 +02:00
Ivan Solovev
de80346829 QByteDataBuffer::getChar() - assert that buffer is not empty
Found by CodeChecker.
The getChar() method can return a garbage value if called on an empty
buffer. Considering that QByteDataBuffer is an internal class and that
there seems to be no current usage of this method, just add a Q_ASSERT
to make sure that the buffer is not empty.

Task-number: QTBUG-96303
Pick-to: 6.2
Change-Id: Iab0aee596aabafe999996f83177ca8bba16a58b6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-14 12:15:38 +02:00
Thiago Macieira
a7fa677fc2 QPlugin/QFactoryLoader: remove Qt 5 plugin remnants
Qt 6.x does not need to be able to read the old Qt 5-based binary JSON
metadata. The QT_WARNING_DISABLE_DEPRECATED was needed in 5.15 while we
used the then-deprecated functions to decode.

Pick-to: 6.2
Change-Id: I2de1b4dfacd443148279fffd16a39ee074da3ef4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-14 01:12:18 -07:00
Thiago Macieira
ae36509d5c QPlugin: remove Q_EXTERN_C macro
Our plugins are code generated by moc, so always C++. I don't know when
the last time it was that you could declare plugins from C.

Pick-to: 6.2
Change-Id: I2de1b4dfacd443148279fffd16a35e466f8a4c20
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-14 03:59:56 +00:00
Thiago Macieira
55e565c763 QElfParser: don't use int for the enum
An enum shows the proper values in the debugger...

Pick-to: 6.2
Change-Id: I2de1b4dfacd443148279fffd16a3a5848196983c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-13 20:59:50 -07:00
JiDe Zhang
413098c3e3 feat: add new interfaces for std::filesystem::path
Add for QFile::exists/symLinkTarget/remove/moveToTrash/
rename/link/copy

Change-Id: I4cbb908e945f043b2a5278a6d8d5149b2f20e871
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-14 03:18:04 +02:00
Tor Arne Vestbø
ec3260e5c7 Close QWidget during destruction via QWindow
Ensures that the QWindow and platform machinery is involved in closing
the widget.

Change-Id: I4ca4ed0b1b31b835d62d2fc0a2158e34e15d710e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-13 21:21:04 +02:00
Richard Moe Gustavsen
f06f39779c QPlatformWindow: fix isAncestorOf not breaking recursion
The current implementation got stuck always asking for
the parent of the same child

This patch will make sure we actually walk up the
parent chain.

Pick-to: 6.2 6.2.0 6.1 5.15
Change-Id: I9f67f6305e0143526f53952a563d496e760ac2e7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-13 19:54:18 +02:00
Volker Hilsheimer
73753ee3af macOS: Don't close popups in Cocoa plugin for most mouse events
QWidget and QApplication handle popup closing for most events at the
right time for the Qt-internal state logic. On other platforms popup
QWindows are never closed automatically when clicking outside.
So don't close any popups in the Cocoa plugin either, and let the Qt
logic take care of it. This ensures that window activation is done at
the right time, that Qt's modal popup stack is consistent, and that
mouse replay for events closing a popup works.

There are however two exceptions: mouse events in the window frame don't
produce a QMouseEvent for Qt; and mouse events in a modally blocked (by
Cocoa) window don't reach Qt at all. For those case, the logic in QWidget
and QApplication is not enough.

For the former, leave the change introduced in 70b94eea10
to explicitly close popups for LMB down in the frame. This still needs
to happen before the event is delivered.

For the latter case, deliver the event explicitly to Qt when we discover
that the target window is modally blocked while a popup is active. The
handleMouseEvent implementation then takes care of the redirect to the
active popup, and Qt will further respect the modal stack in the
QApplication::isWindowBlocked implementation.

Change-Id: I578eb5e6aebc897a0ff1f69bc5c53bcaa05d138d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-13 19:14:29 +02:00
Tor Arne Vestbø
1093562d08 Don't hide QToolTip automatically when another window is closed
QTipLabel has a global application event filter, looking for reasons
to close the tooltip. To fix QTBUG-55523 an additional condition was
added in 7c18cb4f83 to also close the
tooltip when intercepting QEvent::Close, but this was unnecessary,
as the fix in 29205c53e4 was sufficient.

Furthermore, hiding the tooltip on close events turned out to cause
issues when the closing widget/window was the tooltip itself, causing
recursion. This was fixed by 24239aef35.
(which unintentionally also changed behavior for WindowActivate,
WindowDeactivate, FocusIn, and FocusOut due to the case fallthrough).

As it turns out, there is another case that will close the tooltip
prematurely, and that's when the Qt::UI_AnimateTooltip effect is
enabled, which is the case on e.g. Windows. In that situation a
QRollEffect widget is created for the duration of the effect,
which is then closed after the effect finishes. When closing
the effect via QWidget close, we'll end up with a close event,
triggering QTipLabel to hide itself.

Since the logic of hiding the tooltip when other windows close
was never needed to fix the original issue in QTBUG-55523, we
opt to remove it completely, instead of adding even more
heuristics to the code.

Task-number: QTBUG-55523
Change-Id: I8d341262c85fd2e8cf9c496974e46ae0e9245e5c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-13 18:54:17 +02:00
Laszlo Agocs
e346b9524c Expose the config and display for EGL-based QOpenGLContexts
...in the native interface.

Using OpenXR is impossible on some platforms (for example, Android)
without knowing all three. The EGLContext alone is not enough, and
EGL offers no way to query the EGLConfig a context was created with.
https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_opengl_es_enable

Therefore, expose all three so libs/apps can use the new way to query
these native resource without resorting to the old-style
nativeResourceFor* queries.

Change-Id: I7efb0a26b858150da55e711752af99426e744322
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-13 18:31:56 +02:00
Fabian Kosmale
7c1230d9a8 Add documentation for QPropertyBindingError
Pick-to: 6.2
Change-Id: Ia957cedb4c80cbab956d93c5f1af4d3dd5209089
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-13 18:31:56 +02:00
Mårten Nordheim
a7bb5b0245 QTestJunitStreamer: Include <vector>
The indirect include is not available everywhere
Amends b8191f41c6

Pick-to: 6.2
Change-Id: If0abf3b0186594ff5381dab847cbdf13e4fcf448
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-13 17:13:32 +02:00
Volker Hilsheimer
8bb11d0337 macOS: don't replay mouse presses that closed a popup
On macOS, we only follow the native behavior to not replay mouse
presses outside of a popup because we close popups in the QPA
plugin before any popup-specific logic in QApplication kicks in,
so a press that closed a popup is never seen by Qt at all.

Before we can remove the popup closing code from the QPA plugin,
implement the existing platform style hint for Cocoa to prevent
mouse press replays.

Change-Id: I2328f706ba148ece2d0e3fb4e71fe9123ab5e205
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-13 16:43:06 +02:00
Tor Arne Vestbø
6ecd157487 macOS: Improve QAppleKeyMapper logging
Pick-to: 6.2
Change-Id: If0018f2a1c8809e66b695949e8dc7b463c4612a6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-13 12:51:52 +02:00
Tor Arne Vestbø
11214f4c42 Don't exclude WA_DontShowOnScreen widgets for QWidgetWindow event processing
The Qt::WA_DontShowOnScreen widget attribute does not limit whether a
widget will be created (have a QWindow and corresponding QPlatformWindow).
It only limits whether the widget will be shown.

As a result, we need to respect and process incoming events on a QWindow
level, just as any other window. Any considerations that may apply because
of WA_DontShowOnScreen should happen further down in the event delivery.

For example for the issue in 74aae00a4e8e70845e8092abbefa7830c386e66b,
where QWidgetWindow::handleExposeEvent() cleared the WA_Mapped flag which
was set by QWidgetPrivate::show_sys().

Change-Id: I187ebe14ea84538a3715f1d09fb1ba1ce93fcc82
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-13 12:51:33 +02:00
Luca Di Sera
3ddc3c78ce Doc: Update some links to Microsoft's documentation
The documentation links on `msdn.microsoft.com` and
`msdn2.microsoft.com` now redirect to `docs.microsoft.com`.

Some of the links in the documentation were to those domains.

In particular:

- An `\externalpage` link to the `Mitigating Cross-site Scripting With
HTTP-only Cookies` article.
- An `\externalpage` link to `Microsoft Actibe Accessibility Event
Constants`
- A link to the `RtlGetVersion` function in
`qoperatingsystemversion.cpp`
- A link to the `GetCommandLine` function in `qcoreapplication.cpp`
- A link to the `KNOWNFOLDERID` constant in `qfiledialog.cpp`

While the redirection works, our script to catch broken links on
dev-snapshots builds of the documentation doesn't handle redirection
correctly, reporting it as broken.

Both to appease the broken-links script and to avoid an unneccesary
redirection, the above links were modified to
point to the equivalent address in the new domain.

Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: I0e9a132f06af7fc43bca6c8ad2054feb6e3e27cd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-13 08:57:03 +02:00
Luca Di Sera
715b2cd5ad Doc: Update link to RFC-4627
The old `tools.ietf.org/html/*` web pages containing RFCs now redirect
to `datatracker.ietf.org/doc/html/*`.

While the redirection work, our script to catch broken links on
dev-snapshots builds of the documentation doesn't handle redirection
correctly, reporting it as broken.

Both to appease the broken-links script and to avoid an unneccesary
redirection the RFC link in `json.doc` was modified to point to the
new address.

Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: Ic0b0441fb298cfe2e282904e7e8d9155ab25091c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-13 08:56:19 +02:00
Eskil Abrahamsen Blomfeldt
e0ad2cee55 Fix querying font aliases that share name with other fonts
a332f3fabc disabled resolving all fonts
on the system for every font lookup, which was a significant startup
time improvement. But it also caused a regression: When a font has
an alias which shares the name of a proper font, then this would
not be resolved correctly.

This is fairly typical on Windows/GDI due to backwards-compatibility.
Instead of being collected under a shared typographical family, fonts
are disambiguated by adding the style name to the family name. The
proper typographical name is still available, but this is not
enumerated by the system.

So "Segoe UI" for instance, will be available as "Segoe UI",
"Segoe UI Light", "Segoe UI Bold" etc.

When we populate family aliases, we register that "Segoe UI Light"
is actually "Segoe UI" with Light weight, and prior to
a332f3fabc this would be done implicitly.

But after the optimization, we would only populate family aliases once
we stumbled over a font request for a non-existent font. For "Segoe UI",
we would simply return the regular weight font as the best imperfect
match.

The fix is to populate font family aliases not only when the family is
non-existent, but when the match is imperfect, e.g. if we are asking
for a Light weight font and only finding a regular one. User code can
still avoid this somewhat expensive operation by using the full
family names on Windows.

This also requires a fix to a test. When removeApplicationFont() is
called, we invalidate the font database, so it will be reset to a state
that does not contain the family aliases. Therefore we cannot guarantee
that it is identical to what it was before the test started, since this
depends on what has happened previously in the application.

[ChangeLog][QtGui][Text] Fixed an issue where some font styles and weights
would not be selectable. This was especially noticeable on Windows.

Pick-to: 5.15 6.1 6.2
Fixes: QTBUG-94835
Change-Id: I892855edd1c8e3d3734aace396f6000d897d2ec4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-11 11:59:51 +00:00
Paul Olav Tvete
d7b02e8cbf Move QWINDOWSIZE_MAX to platform headers
QWINDOWSIZE_MAX is needed to implement platform plugins and Wayland
shell integrations. Moving the #define from qwindow_p.h to
qplatformwindow.h makes it available from a supported header file.
This should not break anything, since qwindow_p.h includes
qplatformwindow.h

Change-Id: Ie003b1e9d6494695057d59aba5a17ad7fd51c654
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-10 23:13:20 +02:00
Tor Arne Vestbø
b8191f41c6 testlib: Replace custom QTestCoreList with std::vector
The custom linked list implementation was implemented using
recursion, and as a result didn't handle long lists of test
cases, exhausting the stack on e.g. Windows where the default
stack is only 1MB. This was the case with e.g. the tst_QChar
test that produces 20K test cases.

Replacing with a std::vector should do nicely for our use-case.

No attempt has been made at further reducing the complexity
of QTestElement/QTestCoreElement/QTestElementAttribute.

Pick-to: 6.2
Change-Id: Ie295f7cf937ec6abdc4606b6120818551ad285c7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-10 22:19:45 +02:00
Alex Trotsenko
4e0082a9ca Allow destruction of QWinEventNotifier in its signal
Avoid use-after-free issue in QProcess.

Fixes: QTBUG-96285
Fixes: QTBUG-96359
Pick-to: 6.2 6.1
Change-Id: I953d7a8ecaf301ec3a27db37e13748f905c3d097
Reviewed-by: Christoph Cullmann <cullmann@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-10 23:03:44 +03:00
Edward Welbourne
9ba4ce0102 Modernise and simplify handling of qtimezoneprivate_data_p.h's data
Add some trivial inline methods to the classes that populate the
tables to simplify access to their data. Use ranged-for loops to
iterate those tables (now that they no longer have bogus all-zero
entries at the end).

In the process, noticed windowsIdToDefaultIanaId() doing a double
iteration of the windowsDataTable, first via toWindowsIdKey() to map a
windowsId to a key, then again to map that key to the matching ianaId;
inline the former and use the table row from which it got the key to
extract its ianaId instead.

Change-Id: I76267f53c7e6f5c593e33b6146b8f98bfb6d042f
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-10 19:33:06 +02:00
Edward Welbourne
ce868ffb7c Remove trailing zero rows from qtimezoneprivate_data_p.h's tables
They are not needed. Iterations over the table track their sizes.
The size-of-table constants just needed their -1s removed.
Incidentally use std::size() rather than sizeof(array)/sizeof(element).

Change-Id: Ie20eef9f6f5786d93c10b830a87e006d3c5bcc1a
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-10 19:33:06 +02:00
Edward Welbourne
72338c12bc Use qmath.h's conversions between degrees and radians
The make the semantics overt and avoid the joys of yet another
approximation to pi/180 hard-coded in our source-code.

Change-Id: I9dcbaada2e7de119e385fc7056bc601ecd59311a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-10 17:15:40 +02:00
Ivan Solovev
248f0aad1c Fix binding guard in property evaluation
The comment for keepAlive means that it should be destroyed after the
updateGuard goes out of scope and restores its value. In this case
keepAlive should be actually created *before* updateGuard, not after it.

Pick-to: 6.2 6.2.0
Task-number: QTBUG-96303
Change-Id: I4f8e67b49c1d6579228e22111105fb936f1f94db
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-10 16:14:29 +02:00
Tor Arne Vestbø
296621a52f Set Qt::SubWindow on windows embedded by QWidget::createWindowContainer
The embedded window is parented into the containing QWindowContainer
widget, which may either have a window handle itself, or is a child
of a widget that has one (typically the top level).

By setting Qt::SubWindow we inform clients about the embedded window's
place in the world, allowing e.g. QPlatformIntegration::defaultWindowState
to choose the correct state (Qt::WindowNoState) for the window instead of
making it Qt::WindowMaximized on iOS.

Pick-to: 6.2 6.2.0
Change-Id: Icf834192d99fee455aaba3c57bee1a4f1fde5025
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-10 13:07:27 +00:00
Tor Arne Vestbø
c066cd2600 Always give Qt::SubWindows a default window state of Qt::WindowNoState
On platforms such as iOS, the default window state is Qt::WindowMaximized,
so that calling show() will fill the entire screen. But sub-windows should
not get this treatment, as their geometry is typically managed manually.

Pick-to: 6.2 6.2.0
Change-Id: Ib17c2011a16baf6023fe368b94fa7f38e12bd777
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-10 13:07:27 +00:00
Lars Schmertmann
dca394096f Adapt the implementation of QDesktopService on iOS to Android
Change-Id: I8c2048155c5c065b5cdf7ad4cef9d8a446a0561d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-10 13:01:41 +02:00
Luca Di Sera
34f29e5749 Doc: Update a link to Windows Sockets
The link was to `msdn.microsoft.com` which now redirects to
`docs.microsoft.com`.

While the redirection works, our script to catch broken links on
dev-snapshots builds of the documentation doesn't handle redirection
correctly, reporting it as broken.

Both to appease the broken-links script and to avoid an unneccesary
redirection, the Winsock link in `qlocalsocket.cpp` was modified to
point to the new address.

Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: Idff5c2e96f7c90259219a554f73e16c37b81cafe
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-10 11:13:43 +02:00
Lars Schmertmann
f2b914afc6 Android: Enable QDesktopService
QDesktopServices::openUrl(const QUrl &url) is already implemented
on Android. But even if it is possible to set an URL handler, the
mechanism to invoke it is missing. With this commit the URL handler
will work on Android like it is already working on iOS.

Task-number: QTBUG-84382
Pick-to: 6.2
Change-Id: Ic560bd380f1cc59586861aa1a6a3ea064276a39e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-10 06:41:15 +02:00
Morten Johan Sørvig
5083d9dcd6 macOS: process all activation events synchronously
Commit ed483346 changed the main code path to deliver
activation events synchronously, however it looks like
an additional code path was missed.

Use SynchronousDelivery also in becomeFirstResponder.

Pick-to: 6.2
Change-Id: I9061868b0dd0db0252f281e3a974cffe795af38f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-10 01:09:39 +00:00
Alexey Edelev
76665f2a72 Replace manual android properties reading with genex's
Since qt6_android_generate_deployment_settings uses 'file(GENERATE'
API now, we can use generator expressions when writing target
properties to deployment setting files.
This adds the generic functions to accumulate list and non-list
target properties and write them to a deployment setting file
with respecitve key.

Change-Id: Ibfdc875c84c39166f26b2f12ab59831d4f9a6e00
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-09 23:44:39 +02:00
Alexey Edelev
d20f4ae706 Support deploying of libraries from a build tree when building android apk
If the project consists of an executable and multiple libraries that
are linked to the executable, currently you need to specify them
manually using QT_ANDROID_EXTRA_LIBS target property.

This automates deploying of the libraries that are a part of the
project build tree. _qt_internal_collect_target_apk_dependencies
collects all the known non-imported shared libraries from the project
build tree. When running androiddeployqt we specify extra library
directories that point to the collected library locations in build
tree, to help androiddeployqt resolve shared libraries that are build
as a part of the project.

The described procedure is running automatically if CMake version is
greater than or equal to 3.18 is. For the CMake versions less than
3.18 users need to call a new public qt_finalize_project function at
the end of project's top-level CMakeLists.txt

Task-number: QTBUG-94714
Change-Id: I400ca4e49e940cfc25ae90d65372e79825bee55a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-09 21:49:37 +02:00
David Skoland
db8729b018 Change two types in qurlidna
To avoid comparison between signed and unsigned integers,
and the compiler warnings that come with it.

Change-Id: I1028a980dfde68acc338f0e480fdeec42ed81ffb
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-09 18:15:23 +02:00
Tang Haixiang
dfae6416dc Revert "Add Deepin to the list of GTK based desktop environments"
This reverts commit 39f0633f0b.

The Deepin desktop environment is developed based on Qt, but some
applications use dialog boxes of GTK, and some applications use dialog
boxes of Qt. This doesn't look good. The initial commit was trying
to unify this by always using GTK dialogs.

But this turned out to not look good, so instead the plan is that
all application dialogs can be based on Qt. Reverting the original
commit as a result, as it is no longer applicable.

Pick-to: 6.2
Change-Id: I2824b7b2f292f3896c9f94ccce6979f77d66578b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-09 15:36:16 +00:00
Craig Scott
2e4d8d8ec5 Remove inline docs for qt_import_plugins() to avoid duplication
Don't maintain two copies of the docs for qt_import_plugins() in
separate places. Remove the inline docs because they are not the
canonical ones that the user docs contain.

Also remove the TODO and qml plugins. Those are now handled by a
separate command, qt_import_qml_plugins(). Add a "see also" link to
assist in discoverability.

Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I3bb872f77a1b57fd5f2f4fe1355625c47e44a351
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
1fed96d19f Add documentation for the NO_DEFAULT option for qt_import_plugins()
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I3ba7fa52fa38c2ee1f9080f91894c36504a4f451
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
afb7d3b814 Update Qt5:: namespaced targets in snippets to versionless Qt::
The docs for CMake commands all show the versionless commands as the
primary name, with versioned commands added as a note. Use the same
preference for targets for consistency and update the Qt5:: namespaces
to Qt:: rather than Qt6::.

Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I6bf1929a11656f88e27bb5877e9521a3a651361e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
2ad35d133a Remove unused qt5_... CMake command snippets
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I92535fd96937638bb8997a63455ba5152055b72a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
9ad8d2c0d4 Move some CMake commands out of tech preview status
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I6739e5d2fb4716f40e99576a73f57bca51060e92
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:15 +10:00
Craig Scott
944c424ff6 Split up cmake-macros.qdoc into one file per command
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: Ieeb4293fb8d17c57fb25e0ac5cd333b07fc53278
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:15 +10:00
Craig Scott
5b58fbf9a2 Move CMake-related doc files into their own subdirectory
This is in preparation for splitting up the cmake-macros.qdoc file into
one file per command.

Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I9e56b88139cc6a53cd03cbed3d14404577f89faa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:15 +10:00
Tor Arne Vestbø
aafed07dee macOS: Don't show QMessageBox::about(Qt) as modal windows
The system behavior is to not show these kinds of dialogs as modal,
and we've documented that for QMessageBox.

However, calling show() instead of exec() is not enough, as the
default constructor of QMessageBox will set the modality of the
widget to application-modal. We need to explicitly override this.

[ChangLog][macOS] QMessageBox::about(Qt) now shows dialog non-modal,
as documented.

Pick-to: 6.2
Change-Id: I6bb59efb81feb23122276a9eede71b2f20c9d7c6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-09 15:10:36 +00:00
Alexey Edelev
3a9b5162e6 Collect QT_QML_ROOT_PATH based from the project resources
Use the _qt_internal_collect_qml_root_paths function to collect qml
files from the resources. The function is called only if Qml module is
found.

Pick-to: 6.2
Task-number: QTBUG-93340
Change-Id: I2b5f51e3d7fb8aa82f46e88b2aac5e52bf0930d5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-09 17:10:36 +02:00
Øystein Heskestad
9a602e68cf Move QNAM's http header parsing into separate class
Fixes: QTBUG-80701
Change-Id: I43f5e102c15d121dba74e07e3cd4bb8aded1c763
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-09 16:55:50 +02:00
Craig Scott
1fb242ba9f Fix invalid JSON due to missing comma after value
Amends 248828b9a3

Pick-to: 6.2 6.2.0
Change-Id: I606835942e988736786aaf6881ecddc94c8a882c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-10 00:11:13 +10:00
Jan Grulich
dda7dab827 Use wayland platform plugin on GNOME wayland sessions by default
Qt wayland platform plugin has improved quite a lot and it is now pretty
much usable on Gnome. It also improves user experience a lot on HiDPI
displays.

Pick-to: 6.2
Change-Id: I943e0bb969f384bdc3c603e290ce9c8358b70f63
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-09 16:11:13 +02:00
Martin Storsjö
a126b9be89 normalizeTypeFromSignature: Update for Clang 13
Clang 13 now outputs "unnamed struct" just like GCC, while it earlier
used to output "anonymous struct" (since
https://reviews.llvm.org/D96807).

Therefore, for Q_CC_CLANG check for both "anonymous" and "unnamed".

This fixes the QMetaType testcase when built with Clang 13.

Change-Id: I34de8c2ca05c0e691fbb990b001f011b0f336dc3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-09 08:54:42 +03:00
Tang Haixiang
39f0633f0b Add Deepin to the list of GTK based desktop environments
Deepin prefers the GTK3 theme implementation with native dialogs etc.

Pick-to: 6.2 6.2.0
Change-Id: I54cea9d17c0d7f5e466c700adce5aa68f0cf5564
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-09 00:53:10 +00:00
Alexey Edelev
42d0089d44 androiddeployqt: Add support of multiple qml root paths
If application uses qml files from multiple locations, e.g.
subdirectories inside source directory it's important to provide this
information to qmlimportscanner to produce consistent set of QML
modules that need to be included into the end-point application apk.

This makes possible to specify more than one QT_QML_ROOT_PATH per
target and propagates these paths to the qmlimportscanner using
androiddeployqt tool.

Pick-to: 6.2
Task-number: QTBUG-93340
Change-Id: Ic31017b3f2671108adb6d6118ef1c75f1ccc3ec5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-08 23:37:51 +02:00
Volker Hilsheimer
fd3315bc61 macOS: Move pointingDeviceFor helper to top of file
It's confusing to have it in the middle of the code implementing the
various interfaces. Make review of follow up patches easier by moving
it out of the way.

Change-Id: I10f6e8f7642ec0cb14ae31b14a023c6a9ef455d9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 18:39:10 +00:00
Mårten Nordheim
2e520f29a7 OpenSSL: Let people opt-in to use TLS 1.3 PSK callback
It's a workaround for the workaround...

If TLS 1.3 was explicitly chosen and the PSK callback is set then
without this patch the callback is never called since, with TLS 1.3, PSK
would only be queried once at the start of a connection.

It can now be re-enabled with an environment variable. A new API should
be added to address the new requirements of PSK with TLS 1.3:
For session resumption the connection MUST use the same hash algorithm
as in the original session. For new sessions the hash algorithm must be
decided ahead of time, or a default will be used (as defined by the
standard). A user can also pass along multiple identity+key pairs and
the server will pick one it recognizes. This is not something we can
currently do with the preSharedKeyAuthenticationRequired callback.

[ChangeLog][Network][QSslSocket][OpenSSL] When using TLS 1.3 we
suppress the first callback from OpenSSL about pre-shared keys, as it
doesn't conform to the past behavior which
preSharedKeyAuthenticationRequired provided. With this update you can
opt-out of that workaround by setting the QT_USE_TLS_1_3_PSK environment
variable

Pick-to: 6.2 6.1 5.15
Task-number: QTBUG-95670
Change-Id: Ia7454bbbf394cbcb859de333b371d0890b42a1c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-08 18:28:40 +00:00
Edward Welbourne
4641ff0f6a Add new am/pm format-specifier that preserves locale's case
The existing a, ap, A and AP specifiers all force the case of the
formatted am/pm indicator. The indicators returned by QLocale's
amText() and pmText() methods are those given in CLDR, with no case
coercion. Application writers may reasonably want these strings used
verbatim, rather than having to chose a case and impose it on the
locale's indicators, in defiance of national custom. For example,
while en_US uses upper-case indicators by default, cs_CZ uses
lower-case ones. An application author writing a time format has been
forced to chose which of these locales to be wrong in.

Add support for aP and Ap specifiers, whose mixed case indicates that
the locale's case is to be respected. Amend an existing test-case of
tst_QLocale's formatDateTime() that used Ap (expecting, of course, an
upper-case indicator followed by a stray p) to now expect the
locale-appropriate-cased indicator. Extend formatTime() to test cases
using aP and Ap, to illustrate the difference between en_US and cs_CZ.

Rework QDateTimeParser to also support the new format specifier. This
required expanding its Case enum, used by the getAmPmText() method,
which was formerly shared with QDateTimeEditPrivate; however, as that
class no longer makes any reference to this method, it and the enum
can be made private, allowing a systematic clean-up of their use.
Added test-cases for both serialization and parsing; and amended some
existing parsing tests to verify am/pm indicators are matched
case-insensitively.

[ChangeLog][QtCore][Important Behavior Changes] Time formats used by
QLocale, QTime and QDateTime's parsing and serialization now recognize
'aP' and 'Ap' format specifiers to obtain an AM/PM indicator, using
the locale-appropriate case for the indicator, where previously the
author of a time format had to pick a case that might conflict with
the user's locale. For QTime and QDateTime the locale is always C,
whose indicators are uppercase. For QLocale, the case will now match
that of amText() or pmText(). Previously, 'aP' would have been read as
a lower-case indicator followed by a 'P' and 'Ap' as an upper-case
indicator followed by a 'p'. The 'P' or 'p' will now be treated as
part of the format specifier: if the prior behavior is desired, either
use 'APp' or 'apP' as format specifier or quote the 'p' or 'P' in the
format. The prior 'a', 'ap', 'A' and 'AP' specifiers are otherwise
unaffected.

Fixes: QTBUG-95790
Change-Id: I26603f70f068e132b5c6aa63214ac8c1774ec913
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-09-08 20:28:40 +02:00
Alex Trotsenko
400a7c540e QWindowsPipeWriter: stop reporting errors from write()
To match the Unix behavior, callers of the write() function (i. e.
QProcess::writeData() or QLocalSocket::writeData()) should return -1
only if the pipe is already closed. All data being written must be
buffered and no state transition is allowed in response to this call.

Considering the fact that all callers ignore the return value of the
write() function, there is no point in returning anything other than
void.

Change-Id: I52480fc453e076920209bb8e3d52813279393d70
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-08 17:21:05 +00:00
Morten Johan Sørvig
a72066f449 wasm: add DialogExec hack/warning to event dispatcher
Show the warning (and call emscripten_sleep) for the standard
build, but not for the asyncify build.

Change-Id: I695a580ea60897872beee6fa2b6ae70acb9e7dcf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Morten Johan Sørvig
04fd894400 High-dpi configuration change testing
Export configuration() and setConfiguration() from the offscreen
platform plugin using QPlatformNativeInterface. tst_qighdpi can
then resolve and make use of them since it always uses the offscreen
platform plugin.

Add screenDpiChange() auto test.

Change-Id: I459b4df5d94ec4991234a346e3a94618cb3485e9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Morten Johan Sørvig
95d5710d7b Offscreen: add configuration update API
Add support for updating the platform configuration at runtime,
which  enables use cases such as changing the screen configuration
from an auto test.

Provide functions for getting and setting the complete
configuration as a QJsonObject:

    QJsonObject configuration()
    void setConfiguration(QJsonObject)

User code can then either set a completely new configuration,
or make a smaller update by using a get-modify-set sequence:

    // Set the logical DPI for screen 0 to 192:
    auto config = configuration();
    config[“screens”][0][“logicalDpi] = 192
    setConfiguration(config);

This approach means we can expose a minimal but complete
API, at the cost of doing more work in the offscreen plugin
in order to figure out what changed.

Note that this change does not export thew API from the
platform plugin.

Change-Id: If776c36d5ae6d72dca715cc8e89e42768ed32c60
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Topi Reinio
1117e732d9 Doc: Fix documentation warnings for Qt Network
The Clang compiler used in QDoc complained about the documentation-
specific overload of QAbstractSocket::bind():

  error: incomplete type 'QHostAddress' named in nested name specifier

Also, fix an attempted snippet inclusion to use the \include command,
and fix the comment tag spacing and indentation.

Pick-to: 6.2
Fixes: QTBUG-96293
Change-Id: Ie4d78933fa7ac0aaf7f3bcc6487e7fd823db5123
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2021-09-08 18:31:18 +02:00
Tor Arne Vestbø
c138f55591 Clear up QWindow::isActive() documentation
The isActive function does not determine if a window should be active,
but whether it is currently active. The way the documentation was phrased
may have lead people to believe the former.

Pick-to: 6.2 6.2.0 5.15
Change-Id: I05a4cb3d8784a2fefa24bdd42ea96cfdae22b9d1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-08 16:22:01 +00:00
David Faure
a9d3506bf9 QTextImageFormat: add Qt7 TODO to remove the default value
Change-Id: I8b60b302c9df7ce7c44b89fe45f813c4532b7bd6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-08 15:43:16 +02:00
David Faure
b67f887a04 QTextOdfWriter: fix exporting pixmaps to ODT
The QVariant returned by resource() can contain either a QPixmap
or a QImage. The code here is now more similar to the one in
qtextimagehandler.cpp.

Also, the quality is 0 when not set, in which case we want a nice PNG
rather than a very very low quality JPG with just a few large blocks of
same-color pixels.

Pick-to: 5.15 6.2
Change-Id: I49db542e2234c8068f85a636a81a7d8cdb7b5876
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-08 15:43:16 +02:00
Giuseppe D'Angelo
c44e3b119a Add a conditional noexcept specification to qExchange
Following P2401 (which libstdc++ and MS-STL already implement)
and [res.on.exception.handling]/5 that gives us freedom to
strenghten any noexcept specification.

Change-Id: I17ebd9148a181eb8496ace3a9d8010008160b564
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-08 15:43:16 +02:00
Sona Kurazyan
28e194d3b2 Fix QtConcurrent::blockingMapped to work with non-template sequences
The code for deducing the type of output sequence was assuming that the
input sequence is always a template class and was trying to use the
corresponding container type for the output sequence. Fixed the
deduction code, to assume that the output sequence has the same type as
the input sequence, when it's not a template class. Also added tests to
verify that all QtConcurrent functions support non-template input
sequences.

Fixes: QTBUG-30617
Pick-to: 6.2 6.1
Change-Id: I486fe99f3207cfff5dcceb3712cc7de863067edb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-08 15:05:32 +02:00
Craig Scott
2b0e55a3e2 Clean up duplicated code block
Two separate changes addressed the OUTPUT_TARGETS variable not being
set in the calling scope of _qt_internal_process_resource() for a
particular code path, but they did so at different places. Remove one
of them, since we don't need both.

Pick-to: 6.2
Change-Id: Ibc1052e886ec73a99231ada3b7a1bb9e7a873cc4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-08 22:20:06 +10:00
Craig Scott
0d4b2355e5 Fix dependencies on sources generated in a different scope to target
In certain situations, a file generated by add_custom_command(OUTPUT)
may be added as a source to a target defined in a different directory
scope. That makes its GENERATED source property not visible to the
target for CMake versions before 3.20. For 3.20 and later, policy
CMP0118 can make the generated state of a source file global, but that
policy is under the control of the user project, since its value at
the end of the target's directory scope is what is used. Therefore we
can force that global visibility using CMP0118. With CMake 3.18 or
later, we can set source properties in arbitrary scopes, which allows
us to force visibility in the scopes we need it. Use that for all
CMake versions 3.18 and later to make the source file properties
visible to the target.

Making the generated state of a source file visible to the target
isn't enough on its own. In the scope that the file is generated,
there must be a target that depends on the file or else CMake won't
set up the necessary dependencies to ensure that generation happens
before the target tries to use it. Add targets in the generated
file's own scope where we currently might not do that.

Task-number: QTBUG-95200
Pick-to: 6.2
Change-Id: Ic1dfca1a193041de01d7f903b79473b9d47f1d1d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-08 22:20:06 +10:00
Andy Shaw
b919fc8fd0 SQLite: Update SQLite to v3.36.0
[ChangeLog][QtSQL][SQLite] Updated SQLite to v3.36.0

Pick-to: 6.2 6.2.0 5.15 5.12
Change-Id: I05cde47b757455dfd438405bfba1818c7f6eec00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-08 08:20:33 +00:00
Laszlo Agocs
19febad9f2 rhi: Reset resource state tracking tables upon layout-compatible updates
...just like create() would do when requesting a full rebuild.

Not relevant for the OpenGL backend, while D3D and Metal may get away
without doing this, but the Vulkan backend gives visible rendering
errors in Qt Quick once updateResources() is taken into use and a
scene manages to do the "right" amount and types of changes.

The most common source is a changing uniform buffer offset. Consider
how the Qt Quick scenegraph merges uniform data into a single buffer
in unmerged batches (i.e. when a set of geometry nodes cannot be
batched together in a single draw all). While each node gets its own
draw call, each associated srb refers to the same uniform buffer at
binding point 0, just with a different offset.

Without the layout-compatible-update optimization (that is
QRhiShaderResourceBindings::updateResources()) this is not something
that needs extra care: once an srb is built or rebuilt (by calling
create()), the offset, just like the resource itself is fixed and
cannot change. And once create() is called, it conveniently
invalidates all related data structures, leading to the subsequent
setShaderResources() rewrite descriptors (incl. the resource, the
offset, etc.) with Vulkan or do whatever is relevant with other
backends.

updateResources() only does the minimum amount of changes because we
know that the binding list layout has not changed. It turns out this
was a bit too minimal, because certain state tracking data structures
still need resetting, just as if we called create().

The problem is becoming apparent with non-layout data such as the
uniform buffer offset, storage buffer offset, or the storage image mip
level. It however works as expected when changing the resource itself.
E.g. if a binding point now references a QRhiBuffer different than
before, then there is no visible problems, regardless of the buffer
offset being different or the same. Hence being difficult to discover,
until the aforementioned Qt Quick renderer case triggers it.

Why is this?

Changing the resource (buffer, texture, sampler) itself works due to
the guarantees given by the QRhi resource model. Consider the
following:

ubuf is a uniform buffer
ubuf->create();
srb->setBindings({ references ubuf });
srb->create();
// use the srb in some draw calls
// ...
// later, when preparing the next frame we decide we need new data with
// a different size even:
ubuf->setSize(new_size)
ubuf->create();
// fill in new data to ubuf
// use the srb in some draw calls

at this point "magic" happens: note how there is no rebuilding of the
srb itself (no create(), no nothing), yet it will correctly pick up
the now-different native buffer objects underneath ubuf.

This works because there is a certain degree of state tracking
happening that allows recognizing that a resource referenced from an
srb got rebuilt and now has different native objects (e.g. a VkBuffer)
underneath, which in turn needs (with Vulkan) rewriting the associated
descriptor with the new native resource.

Incidentally, this also makes updateResources() work just fine as long
as it replaces the QRhiBuffer/Texture/Sampler reference for the
binding point. However, with the example snippet above there is no way
to change the other associated data such as the buffer offset. (that
would need rebuilding the srb with create(), and that resets all
related state tracking structures)

So once we encounter an updateResources() where the same QRhiBuffer is
now used with an offset different from before, that is not recognized
by setShaderResources() and (with Vulkan) it will not rewrite the
descriptor with the new offset. (unless the changes for another
resource in the binding list trigger it; the granularity here is quite
coarse, i.e. we either rewrite (with Vulkan) all descriptors or none
at all; this makes the problem even less apparent because now
rendering errors occur only when Qt Quick ends with an update where
only the uniform buffer offset, but nothing else changed)

Pick-to: 6.2
Change-Id: I82ee43aa358947288135ff72ec213e091342e9cb
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 21:47:49 +02:00
Laszlo Agocs
ce9d0491f2 rhi: Improve srb layout serialization helpers
Be idiomatic and return the output iterator one past the last element.
Otherwise passing in a plain pointer (as exercised by the autotest now)
fails to function because we write over the same 4 elements again and
again for each binding.

Pick-to: 6.2
Change-Id: If74463fa5140ffa2b1d5be97b71868848ad46614
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 21:47:44 +02:00
Thiago Macieira
7e8c7b3ed8 Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()
Instead of making it return a non-useful nullptr.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a245cce5ea65f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-07 12:09:49 -07:00
Thiago Macieira
da2fd6a903 Q_DECLARE_INTERFACE: add missing const to const qobject_cast
[ChangeLog][Potantially Source-Incompatible Changes] The macro
Q_DECLARE_INTERFACE used to cast away the constness of the QObject
parameter. That is now fixed in this release, but may cause failure to
build source code that depended on this incorrect behavior. If fixing
the const correctness in your code is not an option, insert an explicit
const_cast<IFace *> of the object prior to the qobject_cast call.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a246a36f0c088f
Reviewed-by: Rui Oliveira
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-07 12:09:49 -07:00
Edward Welbourne
0108275b0c Unix fallbackLocale(): use QString::tokenize() rather than split()
We only want the first entry, so avoid all the allocations of
split()ing and just look at the first.

Change-Id: I81beee1856608c932254213f2971fc37bc457c41
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-07 21:09:49 +02:00
Tor Arne Vestbø
121fddcf5a Split up close handling in QWidget into a pre and post step
If we are the one initiating the close (from Qt Widget land), we want
to mark the widget as closing as early as possible.

Clarified the role of close_helper by renaming it to handleClose.

Change-Id: Iae250a0ae1583d743c59e99fcb99fdf18d2a1882
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-07 21:09:49 +02:00
Andreas Buhr
80256b3683 Revert "QUrl: Remove explicit casts to {const,} void*"
This reverts commit 63c1e7c4a1.
It caused the following compilation error with g++-11.
error: ‘void* memcpy(void*, const void*, size_t)’ copying an
object of non-trivial type ‘class QChar’ from an array of
‘const char16_t’

Fixes: QTBUG-96268
Change-Id: I2680b15aba8d0d867092391fcee3815e7fa4c0bc
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-07 18:55:40 +00:00
Doris Verria
f3bc1f8500 Cocoa: Make sure we can display multiple sheets for the same NSWindow
On macOS, to display a modal with Qt::WindowModality set, or of type
Qt::Sheet, we call beginSheet:completinHandler:. However, this method
won't display the specified sheet unless the current active one is
dismissed, which is a different behavior than what we expect for
this case. Use beginCriticalSheet:completionHandler: whenever we
already have an active sheet attached to the NSWindow, which allows
us to display multiple sheets for the same window.

Fixes: QTBUG-91059
Pick-to: 5.15 6.1 6.2
Change-Id: I86bdbcbd63758edbbc48a8aade0178917dcb0e5b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-07 20:18:26 +02:00
Assam Boudjelthia
7dc05252a0 Allow building android{deployqt, testrunner} under target host_tools
When doing a cross build for Android we need only the host tools which
are available under cmake's host_tools target, but androiddeployqt and
androidtestrunner are not part of that. This fixes that.

Pick-to: 6.2
Change-Id: Icdbc4a78ca050b66ec8df656d9ec766ef6c9f4b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-07 17:08:25 +00:00
Volker Hilsheimer
7166a82844 Refactor QStatusBar to reduce memory allocation
Reading through the code contemplating what might have caused QTBUG-89141
brought up some opportunities for improvement.

* updated coding style and variable names
* use ranged for where possible and meaningful
* replacing a QList of pointers to heap-allocated structs with a list of
  values

Since the QList population code makes sure that we never have gaps (we
only insert within the existing range), the test for null-entries is not
needed, and was perhaps just precausion to avoid nullptr dereference.

Task-number: QTBUG-89141
Change-Id: I4694d820427a221f1334d2428f50069751919aef
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-09-07 15:48:35 +02:00
Sona Kurazyan
9f13842fe6 Fix compilation for recursive Qt containers
The operator checks cause compilation errors when trying to check for
their existence for recursive containers. This happens because of trying
to check for the operators on the template parameter type(s), that
inherit from the container itself, which leads to compilation errors.
Introduced alternative versions of the operator checks (with _container
suffix), that first check if the container is recursive, i.e. any of its
template parameter types inherits from the given container, and skips
the operator check, if that's the case.

The fix is done for all Qt container types that had the problem, except
for QVarLengthArray and QContiguousCache, which don't compile with
recursive parameter types for unrelated reasons.

Fixes: QTBUG-91707
Pick-to: 6.2 6.1
Change-Id: Ia1e7240b4ce240c1c44f00ca680717d182df7550
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-07 15:48:35 +02:00
Laszlo Agocs
4cde0e484c rhi: Enable serializing a layout description without baking an srb
Pick-to: 6.2
Change-Id: I66d28cc9d5417bcd5d192fa100c21f69fd42fd6b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 14:41:11 +02:00
Laszlo Agocs
b6b0c33058 rhi: Make the serialized srb layout description accessible
...by the Qt Quick renderer, for example.

A typical Qt Quick material binding set serializes to 8 uints. This
would not demand a container like QVector. However, being implicitly
shared is essential here due to the intended usage (query the
serialized blob, put it into a cache key, hash it, compare it, all
without any copying and new allocs; we can afford an extra alloc
upon each srb construction, but don't want more afterwards in the
rendering engines)

Also make it clear in the pipeline docs that the optimization Qt Quick
is (soon going to be) doing is legal. (the srb ref in the pipeline can
be dead and dangling as long as every call to setShaderResources()
specifies a layout-compatible alternative)

Pick-to: 6.2
Change-Id: I97efbea1fa3516b10c9832adbab0a21b7bc0845d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 14:41:11 +02:00
Zhang Hao
cca8ed0547 QPaintEngineEx: solve compile error
Use the same variable name in function
Amends 6869d2463a2e0d71bd04dbc82f5d6ef4933dc510

Pick-to: 6.1 6.2
Change-Id: If710a53993e84d048f9052f4fcf92eb57635f585
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-07 12:00:56 +00:00
Mårten Nordheim
e94f75fc50 Remove QNetworkAccessCache::Node's explicit ctor
Change-Id: I2a993bcf96a0c603496e8a420251a7e01f46acee
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
2021-09-07 13:38:54 +02:00
Alexandru Croitor
c2a2522089 CMake: Copy and install lldb QtCore.py script for lldb and Xcode use
The file was not handled during the qmake -> CMake transition.

qmake had a more generic mechanism to allow embedding dSYM scripts per
Qt module, but it wasn't used as far as I know, so the CMake
implementation only limits it to QtCore.

Pick-to: 6.2
Change-Id: Ibcd818df1897f603ac194092b28d4bd4d1d6c6ae
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-07 12:53:37 +02:00
Alexandru Croitor
fc038ef445 Fix lldbbridge.py loading when using lldb + Python 3 from CLI
or from Xcode.

A command line lldb that uses python3 fails to load the 'utils'
module dependency when importing lldbbridge.py via the dSYM script
debug_script.py.

Add the directory where lldbbridge.py is as an additional import path
to sys.path.

This fixes the bridge to load in both CLI lldb and from within Xcode.

Traceback (most recent call last):
  File "src/corelib/debug_script.py", line 92, in __lldb_init_module
    bridge = import_bridge(bridge_path, debugger, session_dict)
  File "src/corelib/debug_script.py", line 42, in import_bridge
    bridge = imp.load_source(MODULE_NAME, path)
  File "Versions/3.8/lib/python3.8/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783,
       in exec_module
  File "<frozen importlib._bootstrap>", line 219,
       in _call_with_frames_removed
  File "Qt Creator.app/Contents/Resources/debugger/lldbbridge.py",
         line 34, in <module>
    import utils
ModuleNotFoundError: No module named 'utils'

Amends 1b73c202ce

Pick-to: 6.2
Change-Id: I521d7530e35ee9c51ae0418d2c532e58ec1952d0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-07 12:53:37 +02:00
Lorn Potter
70b9e0687b wasm: fix network data URI scheme
Inadvertantly ifdefed out. Tested and works fine

Fixes: QTBUG-96170
Pick-to: 6.2 5.15
Change-Id: Ib26cf76a548146d4212c48b228965348038f34e8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-09-07 20:53:37 +10:00
Thiago Macieira
b631440902 JSON parsing: fix incorrect sign-extension for decoding bad escapes
The parser was lenient in accepting backslashes followed by invalid
characters, but accidentally sign-extended everything above 0x7f causing
broken outputs that weren't valid UTF-16 either.

For example, the sequence "\\\xff" (backslash followed by 0xff) produced
sequence "\ud7bf\udfff" (U+D7BF is not a surogate pair).

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a113c703a7696f
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 16:23:01 -07:00
Thiago Macieira
248828b9a3 3rdparty: Update TinyCBOR to v0.6-rc1
Change-Id: Ie72b0dd0fbe84d2caae0fffd16a169a70845d33e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 15:41:33 -07:00
Volker Hilsheimer
dad1e14941 Forward touchEvents to children inside QGraphicsProxyWidget
This reapplies the fix from 1ecf2212fa,
using QApplication::translateRawTouchEvent to dispatch the touch event
received by the QGraphicsProxyWidget to the relevant child widgets
under each touch point.

In addition, limit the implicit grabbing of each touch point before
sending the event to those cases where we have to: touch pads, and
if the target widget comes from a closest-widget matching. And don't
call the QTouchEvent override of QEvent::setAccepted() on QTouchEvent
instances in QGraphicsView classes, as this will override each event
point's acceptance state.

This way, we can identify which touch points have been accepted after
event delivery, any only implicitly grab those points that were.
Otherwise, touch points not accepted by a proxied widget hierarchy
will still be part of an accepted event, and be grabbed by the
viewport of the QGraphicsView. This would then lead to infinite
recursion when the QGraphicsProxyWidget passes the TouchUpdate event
on to each touch point's grabber.

Re-activate the test case, and extend it with more combinations.
Refactor touch-event recording to make it easier to test multi-touch
scenarios.

Task-number: QTBUG-45737
Fixes: QTBUG-67819
Pick-to: 6.2
Change-Id: Id5611f4feecb43b9367d9c2c71ad863b117efbcb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-06 19:41:22 +00:00
Ivan Solovev
78dee15da4 Fix QLocale::system() standalone day and month handling
Some backends were missing support for standalone days and months,
also the standaloneDayName() implementation was always using the
same codepath as dayName().
This patch fixes the issues.

Support for narrow format will be added in the following patch.

Task-number: QTBUG-84877
Pick-to: 6.2
Change-Id: I38ee06342cafab544e3c69097bd0e6ae68e85645
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 20:40:12 +02:00
Volker Hilsheimer
eb39b5fd36 Doc: fix qdoc warning from wrong function prototypes
std::chrono values are passed by const reference.

Still warnings from undocumented parameters, but rephrasing
the documentation doesn't make it better in this case, so perhaps
qdoc needs a way to suppress the warning. Adding an \omit block
where the parameters or return values are mentioned doesn't help.

Change-Id: I7d495d73d8367d9d90dd33a4880ac7c978382d19
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-06 19:44:27 +02:00
Liang Qi
25feb2fe3e xcb: update connection time when possible
At least we try to do it with all events triggered by user.

Pick-to: 5.15 6.1 6.2
Change-Id: I28b399a2517600f7da2c91a50fecdf58b9d81fb6
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-06 19:07:43 +02:00
Ievgenii Meshcheriakov
63c1e7c4a1 QUrl: Remove explicit casts to {const,} void*
Those casts are not needed when passing pointers to simple types
to memcpy.

Change-Id: I686265b0e152aa22e0195ff252c442ab1a122ba7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-06 17:41:53 +02:00
Ievgenii Meshcheriakov
65a2cb6964 corelib: Use char16_t and char32_t types for characters
Use standard char16_t and char32_t types instead of ushort and uint.

Remove members of QUtf8BaseTraits that use those integer types.

Change-Id: I77b1a9106244835c813336a50417f6bbdfada288
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 17:41:53 +02:00
Sze Howe Koh
ee2ac8b4ef qt_pixmap_thread_test(): Simplify logic, merge warnings
Pick-to: 6.2
Change-Id: I0c413c14d124bafbd6b2bd94d7a128e19ed83ade
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-09-06 22:56:56 +08:00
Volker Hilsheimer
e9e8d67e31 Fix segfault when closing widget and destroying window in QDialog::done
On OpenSUSE we seem to get an Enter event after or while the QWindow is
closed, and that appears to reset the currentMouseWindow after we
cleared it in QWindowPrivate::destroy. Apply a workaround similar to the
focus_window to make sure that currentMouseWindow and
currentMousePressWindow don't point to destroyed objects.

Pick-to: 6.2
Change-Id: I61afdaa7d8d1d437058624012319460be2f2567f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-06 14:23:17 +00:00
Volker Hilsheimer
197fcdd7ee Doc: mark documentation of internal functions as such to silence qdoc
Pick-to: 6.2
Change-Id: I9523511b9adf40d1280fbf320c24a79aa2860ef2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
2021-09-06 16:23:16 +02:00
Edward Welbourne
c801e35282 Remove redundant break;s following return;s
Pointed out by the INTEGRITY compiler.

Change-Id: Id5f9b994c348308c56c3a25200419be525b9c933
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-06 15:56:28 +02:00
Craig Scott
f68f6ecf6f Fix cases of output variables not being passed back to calling scope
Some versionless wrappers were not passing back output variables to
their calling scope. Ensure they always are.

Fix qt6_extract_metatypes() to set its output variable in the parent
scope (it was previously setting it erroneously in the local scope).

Some functions had code paths that would not set output variables.
This would allow situations where if the variables had an initial
value set by a higher up parent scope, the output variable would
still have that value in the caller's scope upon return. That could be
misleading, so fix these code paths to explicitly set the output
variable to an empty string instead.

Task-number: QTBUG-96121
Task-number: QTBUG-96219
Pick-to: 6.2
Change-Id: I291775813f025cabdccd4372ac077cdfd3ec090e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 23:56:28 +10:00
Craig Scott
a37789e493 Revert "Ensure versionless wrappers do not introduce a new variable scope"
This reverts commit 08180e76e6.

Macros add another level of escaping that functions do not. The
conversion of the versionless wrappers to macros may alter the
behavior, so revert that change.

Task-number: QTBUG-96219
Pick-to: 6.2
Change-Id: Ic5dcff3081123d957888584ba1d76ae0580d9083
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 23:56:28 +10:00
Tor Arne Vestbø
9877d55a50 macOS: Report preedit cursor position and cursor visibility correctly
Unfortunately QInputMethodEvent::Cursor defines length == 0 as the
cursor being hidden, and length > 0 as being visible. This is the
opposite of what native macOS application do.

A future improvement here would be to base the QInputMethodEvent
logic on QStyle::SH_BlinkCursorWhenTextSelected, which we already
respect for normal selections. That would also allow us to use
QInputMethodEvent::Cursor to set the preedit selection, which
we currently have to fake via QInputMethodEvent::TextFormat.

Pick-to: 6.2
Change-Id: I75b5d8c5403283a0988355e440a98b4df35ec995
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-06 14:37:43 +02:00
chenbin
0624eba1b1 Partially modified to use C++11 standard nullptr
Change-Id: I0542c47d1979235206005bf603822b6ea415f2da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-06 09:49:46 +08:00
Volker Hilsheimer
ef8ca68406 Doc: fix qdoc warning, add \inmodule for qdrawutil header
Change-Id: Iddc0273778adf79250b4e767172b1202817507bb
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-05 23:07:52 +02:00
Volker Hilsheimer
c111b6b7b1 Doc: fix qdoc warning, function prototype missed return type
Also missed the second set of template parameters.

Change-Id: I81ab09ed77af79415ee72334db900bdb94db5739
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-05 21:07:48 +00:00
Volker Hilsheimer
5f3df6e1c7 Doc: fix qdoc warning from wrong see-also
Only QByteArray has a toHex() member, QByteArrayView doesn't.
Since toHex() is linked to from result() already, remove it here
to avoid the wrong impression that there was a toHex() that doesn't
require any memory allocation.

Change-Id: I76f876aca90403baebf9328b794aeaf9be698c46
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-05 23:07:44 +02:00
Tor Arne Vestbø
2262744ad0 QMessageBox: Reset clickedButton for each invocation of the dialog
When showing a messagebox that has already been show we don't want to
keep around the clicked button of the previous invocation.

Pick-to: 6.2
Change-Id: Ib6f6293d40ab338c550ea344094db871ccf45c46
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-04 23:09:30 +02:00
Shawn Rutledge
673ed80fa4 doc: Add the PixelScroll device capability (new in 6.2)
Followup to 69c833dae9

Pick-to: 6.2
Task-number: QTBUG-72167
Task-number: QTBUG-87646
Change-Id: I4ac7cbacd6dc1407ad3b565674a6d6494ec8857f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-04 11:55:27 +02:00
Timur Pocheptsov
c55f61578c QSslCertificate(OpenSSL plugin): fix memory leaks in extension 'parser'
They went unnoticed previously because of lazy evaluation, which is
not the case anymore.

Fixes: QTBUG-96155
Pick-to: 6.2 5.15
Change-Id: I46026a24b354c1db7c10d84fceae06c4ab7cc0fc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-04 08:25:18 +02:00
Sze Howe Koh
ee5077daf5 QPixmap: Fix crash if created without gui app in secondary thread
The thread checking in in_pixmap_thread_test() is only safe, and only
makes sense, if we have a QGuiApplication. If we only have
QCoreApplication, only null QPixmaps may be created anyway, so
threading makes no difference.

Fixes: QTBUG-95358
Pick-to: 6.2
Change-Id: I93c983a3d6c271b0a19dfd0384862fc151459029
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
2021-09-04 03:43:44 +02:00
Tor Arne Vestbø
ae8e96d4c2 macOS: Don't rely on invalidateCursorRectsForView when mouse is over view
Calling invalidateCursorRectsForView will normally result in a updateCursor
callback, where we then set the current cursor using [NSCursor set]. But
if an override cursor is set by AppKit, which happens for example when
hovering over a resizable window's theme frame, then AppKit ignores the
call to invalidateCursorRectsForView. And it will not consult the view
when the override cursor is unset again, which results in the cursor
being reset back to the default arrow cursor instead of the cursor
that was set when we initiated the invalidateCursorRectsForView call.

We need to hit-test to confirm that the mouse is over the view,
as there might be child views in the mix that also have custom
cursors, and we don't want to activate the parent view's cursor
unless we're actually over that view.

Fixes: QTBUG-81552
Fixes: QTBUG-96003
Pick-to: 6.2 5.15
Change-Id: I52573ab7be82f28c6a1cf686bd4b133551cfe98b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-03 22:38:07 +02:00
Volker Hilsheimer
f70421bfc0 Doc: add more notes about full screen windows on macOS
Fixes: QTBUG-68069
Pick-to: 6.2 5.15
Change-Id: I8fc99f708cfa19a9c8cc8d13f6889549c79dd3b3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-03 21:40:08 +02:00
Volker Hilsheimer
1ebea13765 Doc: fix qdoc warnings from wrong parameter type
QWidget::addAction takes a QKeySequence, not a QShortcut.

Change-Id: Ia10adcf50133b306d484a122ed17dddcf94372a6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-03 21:40:08 +02:00
Volker Hilsheimer
62fc486a77 Doc: fix a bunch of qdoc warnings from wrong prototypes
* name method parameters consistently with their declaration
* don't document parameters that are not there

Pick-to: 6.2
Change-Id: I06ae9fdca357ed29eb7a72802f149eb4914181f4
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-03 21:40:08 +02:00
Volker Hilsheimer
2c6de9c099 Doc: add note that hiding a window doesn't close a full screen space
Fixes: QTBUG-52450
Pick-to: 6.2 5.15
Change-Id: I3f819bac470b5a883a74fb58f6fa2d27740eaaf2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-03 21:35:06 +02:00
Joerg Bornemann
4c52dd43ae Fix QMAKE_LIBS_OPENSSL/NOLINK entries in qt_lib_network_private.pri
The file qt_lib_network_private.pri contained the following bit
  QMAKE_LIBS_OPENSSL/NOLINK =
  QMAKE_INCDIR_OPENSSL/NOLINK = C:/openssl/include
  QMAKE_LIBS_OPENSSL =
  QMAKE_LIBS_OPENSSL_DEBUG = -L"C:/openssl/lib/VC" -llibssl64MDd
  QMAKE_LIBS_OPENSSL_RELEASE = -L"C:/openssl/lib/VC" -llibssl64MD
  QMAKE_INCDIR_OPENSSL = C:/openssl/include

The /NOLINK entries are nonsense.  QMake projects that do
  QMAKE_USE += openssl/nolink
would use QMAKE_INCDIR_OPENSSL and discard the QMAKE_LIBS_OPENSSL*
variables.

The QMAKE_*_OPENSSL/NOLINK entries stem from the WrapOpenSSLHeaders
CMake package, and QMAKE_*_OPENSSL from WrapOpenSSL.  It's safe to
assume that both packages use the same include paths.

Remove the QMAKE_LIB parameter from the
qt_find_package(WrapOpenSSLHeaders) call to avoid writing this library
into the .pri file.

Pick-to: 6.2
Fixes: QTBUG-89562
Change-Id: Ibc20f6f90678eb127db7813eb63c5c3e0bff2268
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-03 21:35:06 +02:00
Shawn Rutledge
4d8fb1bc6f cocoa: use TouchPad deviceType for trackpad
WheelHandler { acceptedDevices: PointerDevice.TouchPad }
doesn't react unless we use the right type.

Amends 69c833dae9

Pick-to: 6.2
Change-Id: I813de096b87f3af4dfcf5510abc0d0bd9c15b689
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-03 19:53:32 +02:00
Laszlo Agocs
6906516004 rhi: Add a way to tell an srb that only the resources have changed
Until now, after updating the bindings one had to always rebuild the
srb, which can be heavy esp. on Vulkan (release old objects, create
new layout object, descriptor sets). When updating the binding list in
a way that it is fully isLayoutCompatible() == true with the previous
list, this is an overkill. Internally, most notably in
setShaderResources(), we already should have everything in place in
all backends to recognize if the entries in the binding list refer to
QRhiBuffer/Texture/Sampler objects that are different than before, and
so apart from adding an alternative to create() in the API there is
not much else needed here.

Pick-to: 6.2
Change-Id: I2efdd4fd0b24c7ebba694a975ed83509744b044b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-03 17:14:59 +02:00
Kai Köhne
c104af4c44 Doc: Remove unsupported customFilters
customFilters defined in .qdocconf are not supported anymore by Qt
Assistant since Qt 5.13. Therefore remove them from all .qdocconf files,
also to avoid cargo-culting them to new help modules.

Task-number: QTBUG-95987
Change-Id: I664391460637d2e859348da0338e1a4a3ee9f570
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-03 15:14:59 +00:00
Laszlo Agocs
65cad49473 rhi: Correct a doc note
It is not true that isLayoutCompatible() can be called before create().
That used to be the case before the optimizations have been added.
The docs are still internal, but let's fix it up.

Pick-to: 6.2
Change-Id: Iee61848f058a06774550af6f38a3253956e4cfd3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-03 17:14:59 +02:00
Laszlo Agocs
6cdf95a970 rhi: Include resource count in srb layout compatibility checks
Relevant for Vulkan, given that descriptorCount is part of
VkDescriptorSetLayoutBinding, meaning two srbs with arrays of
SampledTextures should only be reported as compatible if the
array size matches.

Also reduces the prealloc size for the VLAs. For Qt Quick even a
lower number would be sufficient, but we still keep the number
something fairly high in order to play nice with Quick3D.

Pick-to: 6.2
Change-Id: Id92b7c09b051ebe54b1fa2bf4ba78950fe60ba27
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-03 17:14:59 +02:00
Ievgenii Meshcheriakov
19a48b8545 unicode: Regenerate qunicodetables{.cpp,_p.h}
Run unicode utility to regenerate the Unicode tables. This reduces
size of the IDNA mapping tables. Adjust the QUrl client code to use
the new API.

Task-number: QTBUG-85323
Change-Id: Iaa8d6932e611f7aa4009a3fae2972de87b875cf8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-03 14:43:16 +02:00
Alex Trotsenko
340131b4be QWindowsPipeWriter: suppress a warning on unexpected peer disconnection
The other side can close the pipe at any time independently of us, so
ignore the ERROR_PIPE_NOT_CONNECTED error code if the write operation
failed.

Change-Id: I4f7ccd73c19ca2dd24fa1c9f33b5f60541a7521d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-03 09:31:42 +03:00
Volker Hilsheimer
7ba75d088c QWidget: close the QWindow in QWidget::close
We want to close the window, end full screen mode on macOS, and free
platform resources. This is all done by QWindow::close. QWindow::close
closes the platform window, triggering a closeEvent to QWidgetWindow,
which then calls QWidgetPrivate::close_helper.

This way, closing a window via QWidget::close, QWindow::close, or
interactively by the user are all equivalent.

The QCloseEvent generated by the widget needs to be spontaneous for
window-system generated events (i.e. the user clicked the close button),
and non-spontaneous if the window closes because of a call to
QWindow::close. To keep track of whether the event originated in an
explicit call to QWindow::close, add a boolean to the QWindowPrivate.

Add a test case that verifies that the window resources is destroyed,
and that events are delivered as they should.

Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Fixes: QTBUG-46701
Pick-to: 6.2
Change-Id: Iacb6a2c8d5e880b16b0c8f0c9257ed94bed36f5b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-02 20:34:48 +02:00
Mårten Nordheim
05c9894330 QNetworkAccessCache: Style fixes and move asserts
Change-Id: I300d2525d9987737697e2cc6a326be19554902c8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
a253bec500 QNetworkAccessCache: Port to QDeadlineTimer
QDeadlineTimer is semantically more correct than comparing timestamps to
'now'.

Change-Id: I15d9654af2886499392e6409d22f802203aca18d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
3a7d6767e9 QNetworkAccessCache: move debug logging to specific ifdef
Instead of for any debug output.
Since QTestLib cuts off output after X messages we shouldn't add these
by default.

Another option would be categorized logging, but QNAC should not be very
interesting for 'outside' users

Change-Id: I4c2c2a68ca4962476bfecd679f3229ccf3403aee
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
8460a55d32 QNetworkAccessCache: Remove the ctor and init member variables in class
Change-Id: Ic7ce41679d89b496413ef13e6e917bf506b2405d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
3a8f9286fc QNetworkAccessCache: Rename first and last node
'oldest' and 'newest' to me make me thing of 'least recently inserted'
and 'most recently inserted', which is what they used to mean.
But now the expiration can be set per-request so the semantics don't
work anymore.
So, rename to 'nextExpiringNode' and 'lastExpiringNode'. Also rename the
node member elements "older" and "newer" to the more generic "previous"
and "next".

Change-Id: I582267d09c60c68396e4201e4a20185bbf0942e2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-02 16:57:42 +02:00
Edward Welbourne
7403561f21 Remove a redundant check
Missed in a recent fix to QTimeZonePrivate::dataForLocalTime(), but
noticed during picking back to 5.12

Pick-to: 6.2
Change-Id: I63964952150fedf857b7aef12dfc866097d2e2d1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-02 16:35:12 +02:00
Edward Welbourne
f645bb8880 Replace implementation-specific zero test with plain comparison
Various double-to-string converters carefully omit the sign from -0.0,
for which they need to test whether the double is zero. This was
tested by a function that looked at the bytes of the double in an
endian-specific way. Packaging a comparison to zero in a function
seems to avoid the compiler warnings over double-comparison, so retain
the function but make it simpler. The only available benchmark
(QString's number_double benchmark) consistently shows a negligible
improvement in performance.

Change-Id: Id994177e21e4770ced904881d7e84a95cb727605
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-02 16:35:12 +02:00
Craig Scott
f266381b1b Clean up output target handling left behind by earlier changes
Previous work removed the no-longer-used code path that could add
targets from qml compiler features. The variable that code path would
populate was not fully cleaned up in that removal. Clean it up now and
move the variables related to output target handling closer to the
only remaining area where they could be generated.

Also ensure that we set the variable named by OUTPUT_TARGETS even if
isBinary ends up being true. We should explicitly set that variable
to an empty string in that case.

Amends 363df5cd70

Pick-to: 6.2
Change-Id: I17de9788b390aac9a7aedb29ab9bdfee99c305af
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-02 20:52:22 +10:00
Fabrice Fontaine
035dc537be Fix build on riscv32
riscv32 fails to build because __NR_futex is not defined on this
architecture:

In file included from thread/qmutex_linux.cpp:45,
                 from thread/qmutex.cpp:804:
thread/qfutex_p.h: In function 'int QtLinuxFutex::_q_futex(int*, int, int, quintptr, int*, int)':
thread/qfutex_p.h:116:30: error: '__NR_futex' was not declared in this scope; did you mean '_q_futex'?
  116 |         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
      |                              ^~~~~~~~~~
      |                              _q_futex

Pick-to: 6.1 6.2
Fixes: QTBUG-96067
Change-Id: Ib6a9bcc496f37e69ac39362cb0a021fccaf311f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-02 09:59:33 +00:00
Alex Trotsenko
5d68858ba7 QLocalSocket/Win: fix waitFor...() functions for write-only socket
There were several issues with the socket state checking when the pipe
reader is not running:

  - the number of object handles in the WaitForMultipleObjectsEx()
    call might have been zero;
  - a call to the waitForDisconnected(-1) might have hung;
  - we did not perform a loop iteration for the waitFor...(0) calls,
    so disconnect detection was unreliable.

These issues are related to the same code, so they don't seem to be
addressable separately.

Change-Id: I3bca872bb4191e6a7d38a693d81f7981af7fe145
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-02 08:47:11 +03:00
Liang Qi
9a4c98e556 xcb: support xrandr(1.5) monitor setup
More information about monitor in xrandr 1.5, see
https://keithp.com/blogs/MST-monitors/

Since this change, screen is logical instead of physical.

If xrandr 1.5 and later is installed, Qt screen info will get
from xrandr monitor object instead of xrandr output if only have
1.2 to 1.4.

Users can manipulate monitor as they want, for example, a
combination for two physical screens, half of one screen and etc.

Didn't have chance to access MST monitors, but it should work
if xrandr monitor object was created automatically.

[ChangeLog][xcb] Qt screen info will get from xrandr monitor
object if 1.5 is installed.

Fixes: QTBUG-65457
Change-Id: Iad339cc0d4293b2403b4ef6bf6eb770feb3e685f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-01 20:32:04 +02:00
Thiago Macieira
f3743073a7 qstrnlen: micro-optimize further
This is the kind of loop that the autovectorizer is pretty good
at, but this is really just a type of memchr, so help dumber
compilers and build modes without vectorization.

Drive-up fix the style of the test code.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a022a35fa24c17
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 11:32:03 -07:00
ChunLin Wang
ca69e5aeef Fix QListView assert when the last row is moved in IconMode
After the last row is moved, 0 will be returned when obtaining
row and column data. At this time, QListView::doitemslayout will
not call d->doitemslayout, so the QBspTree data structure will
not be cleaned up, leaving a stale tree structure behind. This
will trigger an assert during paintEvent handling if QListView is
set to IconMode

In QListView::ListMode the test for a valid model index doesn't
use an assert.

Call QListViewPrivate::clear explicitly if the column count is 0
so that the QBspTree and other data structures are cleared.

Add a test case that simulates this scenario by implementing a
model that returns a 0 column count for an index after the model
structure was changed through a move of rows.

Done-with: Volker Hilsheimer
Fixes: QTBUG-95463
Pick-to: 5.15 6.1 6.2
Change-Id: I36419be5459b8ced930c619f538482ea1db4ad03
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-01 16:03:15 +00:00
Edward Welbourne
38ec2c830b qlocale_win: Fix non-standalone month names
We have previously been using the standalong (nominative) month names
both when asked for that and when asked for the plain (genitive) month
name, probably because there was no LCTYPE value for the
latter. However, MS's docs for the standalone values do contain a
comment telling us how to get the genitive names.

Rename the old monthName() to standaloneMonthName() and add a
monthName() that calls GetDateFormat() suitably, as described by the
MS doc.

Pick-to: 6.2 5.15
Fixes: QTBUG-92018
Fixes: QTBUG-86279
Change-Id: I27f63198c3a15b792683f476d2019078b0860f99
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-01 17:56:46 +02:00
Edward Welbourne
6da648ad83 Add a QLocale(QStringView) constructor
Only a few more internals just needed to change to take QStringView,
to connect up the constructor with internals already long since
converted.

[ChangeLog][QtCore][QLocale] Added QLocale(QStringView) constructor.

Change-Id: Iec31391e6168f333b4b6fc633c3d7d01872f83b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-01 17:11:44 +02:00
Eirik Aavitsland
dc65267ad8 When clearing QPixmapCache, stop its flushing timer
No need for timer event to reduce cache size when it is already empty.

May also avoid the "Timers cannot be stopped from another thread"
warning at exit, if the global cache object is then deleted by another
thread.

Fixes: QTBUG-96101
Pick-to: 6.2 5.15
Change-Id: Id1aeecfbb43a25a887ebd5cc7242749a74290bb0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-01 17:11:44 +02:00
Eirik Aavitsland
a6a3b1e79c Update bundled libjpeg-turbo to version 2.1.1
[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 2.1.1

Pick-to: 6.2 5.15 5.12
Change-Id: I22a273018229aa35a175f9e903fa605a3eb55c32
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-09-01 17:11:43 +02:00
Ivan Solovev
313de93b1d QDoubleValidator: fix NaN check in validateWithLocale
We can't really compare two NaN's. Should use qIsNaN() for that.

Pick-to: 6.2
Change-Id: Ia514cabe65cfcdeafb39cab91ecdb66f8fae725c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 17:11:43 +02:00
Mårten Nordheim
81a9335c65 Fix documentation of QNetworkAccessBackend
The classes themselves were not documented, so...:

Add some documentation for QNetworkAccessBackendFactory.
Add some overall class docs for QNetworkAccessBackend.

The class docs were marked \internal (because they mostly are).
I don't think we yet have a defined way to handle semi-private APIs but
having them be marked \internal and leaving the documentation in source
seems fine (and was what someone suggested a while back).

Add documentation for pure virtual functions which were overlooked.

Pick-to: 6.2
Fixes: QTBUG-88774
Change-Id: Id7fe18ec92372abb96540cd29543608f87ec862e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 14:51:29 +00:00
Morten Sørvig
81a7344e1d Port to QImage and QPixmap deviceIndependentSize()
Replace the “size() / devicePixelRatio()” pattern with
a call to deviceIndependentSize().

Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-01 15:24:05 +02:00
Edward Welbourne
f98d9aa9da Refine QLocale constructor documentation
Fix a typo and swap two sentences to give a clearer reading.

Pick-to: 6.2
Change-Id: I4a24ad5ba2e022edd121eb686de3638af2c242a6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-01 11:27:42 +02:00
Edward Welbourne
b656cea5de Fix corner case in QTimeZonePrivate::dataForLocalTime()
If the local time for which we want data is after the last known
transition, the two transitions we get to bracket it are the last
known and an invalid one. The code checked the former was valid, but
neglected to check the latter, leading to nonsense arithmetic later in
the function. In this situation we unequivocally want the last known
transition, so the problem is easily solved.

Fixes: QTBUG-96152
Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I6fc830ce538e8a572093cd8dfe832e10689bf904
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-01 11:26:54 +02:00
Edward Welbourne
5598a15fe7 Mark QLocale's private functions [[nodiscard]]
If only to make the exceptions stand out, so we can see which ones
only exist for their side-effects.

Change-Id: I90b649d4da09f57ab986f29c577993dd12e34721
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-01 11:16:52 +02:00
Edward Welbourne
52473c7bf1 Use QByteArrayView::toInt() instead of duplicating its implementation
The code in qEnvironmentVariableIntValue() to parse the text as an int
can now delegate it to QByteArrayView, so that keeping in sync with
QByteArray::toInt(), as a comment requested, is now automatic.

Change-Id: I09a6b7245ecd02f39a850a4ce187f86709282e8c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-31 20:37:14 +02:00
Mårten Nordheim
5ad75eda0c QNetworkAccessCache: Another fix to the linked list insertion
When inserting between two nodes the "previous" node's "newer" was
forgotten and not updated. So every node's "newer" would point to the
"newest" node.

Change-Id: I5b0df8812be5f7f62b3ae363e4c78f582e0e5c43
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-31 17:54:30 +02:00
Fan RuiJie
586d9e6013 Fix text ellipsis not implemented in Tibetan
The original code checks the existence of an ellipsis character first.If
this does not exist (glyph == 0,which is an invalid glyph index), then
it falls back to looking up '.'. But in the Tibetan environment,the
glyphIndex('.') also returns 0, so that it simply doesn't add any form
of "...", and cuts the text instead.

If both the attempts at getting something from the main font fails,
we can do a third pass on the "multi" font engine.

Fixes: QTBUG-95942
Pick-to: 6.1 6.2
Done-with: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Change-Id: I251de3fe92e19be0462c58c2059ecf7d354bfbb0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-31 14:53:45 +00:00
Yang Yuyin
6e9cae0b77 QFileDialogComboBox: member variable is not initialized
initialize d_ptr in the constructor

Pick-to: 6.2
Change-Id: I5a8062dd0a81023e6c1a5858bb8603d279cdbcee
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-08-31 13:18:15 +02:00
Craig Scott
08180e76e6 Ensure versionless wrappers do not introduce a new variable scope
Using function instead of macro prevented the wrappers from being able
to pass back any variables set in the wrapped function. In some cases,
these variables were being explicitly passed back to the caller, but
that isn't needed if you just make each wrapper a macro. This also
makes things more future-proof because any newly introduced output
variables will work without having to update the wrappers.

Task-number: QTBUG-96121
Pick-to: 6.2
Change-Id: Ic4486de668694c06b47e466587b2cdcb969ea047
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-31 17:05:15 +10:00
Volker Hilsheimer
6e2a5312db Revert "Forward touchEvents to children inside QGraphicsProxyWidget"
This reverts commit 1ecf2212fa.

The fix is not correct after all. TouchBegin goes to the correct
widget with the fix, but following TouchUpdate and TouchEnd events
now go to the viewport, as QApplication::translateRawTouchEvent always
gives precedence to the widget that Qt recorded to be the touch
grabber, which is the viewport. This results in infinite recursion,
as the proxy widget trying to send the touch events to the embedded
widget (expecting that translateRawTouchEvent will split it up) ends
up sending the events back to the viewport.

Leave the added test case as QEXPECT_FAIL, reactivate the (never run,
hence unnoticed) test that the fix broke.

Pick-to: 6.2 6.1
Task-number: QTBUG-45737
Task-number: QTBUG-67819
Change-Id: I4810affb3cd066743ae94ab7beb2f0c06b60d211
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-08-30 19:34:50 +00:00
Edward Welbourne
c2a6749af7 Clean up QLocaleData::validateChars() and fix its double-handling
Decrementing decDigits and checking for zero is less complicated than
incrementing a counter to check against it if it's not negative.

A plethora of unenlightening local variables could be replaced by
keeping track of the last character and of a simple state variable
that make checks easier to understand (and explain).
Various conditions could be expressed more simply.

Comment on the condition for omitting grouping characters from the
transcript - it was easy to mistake the comma for a dot !
Comment on the lack of checking of grouping sizes.

Change-Id: Iff8da2376507d2abbbaf5739baf6cbb23e55edaf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-30 18:48:39 +02:00
Edward Welbourne
4e9efb0b60 Teach QByteArrayView how to parse numbers
Now that we don't need '\0'-termination on the data, this is possible.
Moved QByteArray's tests to tst_QByteArrayApiSymmetry and added some
more test-cases.

[ChangeLog][QtCore][QByteArrayView] Added numeric parsing methods.

Change-Id: Ic0df91ecfe5dbf6f008d344dd0464d7927f32273
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
6db5fd5918 Avoid UB (and the consequent need to suppress an MSVC warning)
Converting a negative signed value to its absolute value in the
matching unsigned type can be done by adding one, negating (which we
can now do without the UB), casting and then adding one again.
This is cleaner than casting the negative value to the unsigned type
in order to then "negate" it within that type, about which MSVC
grumbles; we can now avoid the need to suppress that grumble.

Change-Id: I9148ead23c928aeb2b90884a2f2e292fdf3af5e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
0564e4afba Remove temporary inlines for qstrtou?ll()
All callers are now converted to use qstrntou?ll().

Change-Id: I279a800a9f19944e544cc8a7ebaba579d18643b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
88b54cc22a Rework QLocalePrivate::bytearrayToU?LongLong()
Change it to take a QByteArrayView instead of a plain char *; all its
callers do know the size and propagating it enables the implementation
to call strntou?ll() rather than strtou?ll(), thereby escaping the
need for '\0'-termination.

Fixes: QTBUG-74286
Change-Id: Ie9394786e9fcf25c1d1be2421805f47c018d13bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
7d33779a79 Convert various callers of strtou?ll() to call strntou?ll()
Where size is known or can readily be determined.

Change-Id: I442e7ebb3757fdbf7d021a15e19aeba533b590a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
5644af6f8a Replace FreeBSD's strtou?ll() with std::from_chars()-based strntou?ll()
Remove third-party code in favor of STL. Implement (for now)
strtou?ll() as inlines on strntou?ll() calling strlen() for the size
parameter. (This is not entirely safe, as a string lacking
'\0'-termination but with at least some non-matching text after the
numeric portion would formerly be parsed just fine, but would now
produce a crash. However, strtou?ll() are internal and callers should
be ensuring '\0'-termination.)

Task-number: QTBUG-74286
Change-Id: I0c8ca7d4f6110367e93b4c0164854a82c5a545e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Mårten Nordheim
522ca997d3 TLS plugins: Prefix with 'q'
For consistency with other plugins.

Pick-to: 6.2
Change-Id: I45507389a42e645c94f1ca3f32262a2181f282f7
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-30 12:35:41 +00:00
Assam Boudjelthia
07283f1527 Android: pass -g to testrunner to grant run time permissions
Some Qt modules/tests go through features that require run-time
Android permissions which are granted by user input, that of
course is not ideally possible while running unit tests. So when
installing the app adb can do that for us.

Pick-to: 6.2
Change-Id: I92d33d5213c3779d7ca246ec0fb359d2ead4fa6f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-29 19:39:42 +03:00
Tor Arne Vestbø
52f635b9a0 macOS: Hide mouse cursor when initiating IM enabled text input
Fixes: QTBUG-72744
Pick-to: 6.2
Change-Id: I952710e88a11fd00498562c9011461a010f02f7b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 22:41:09 +02:00
Tor Arne Vestbø
3de396590c macOS: Correctly implement attributedSubstringForProposedRange
The substring range refers to the entire text of the focus object,
not just the selection.

As there is no way to pull out the entire text via input method queries
we do the best we can via ImTextBeforeCursor and ImTextAfterCursor.

Returning the correct substring enables input method features such
as backtracking into already committed text with the Hiragana IM,
as well as the Keyboard Viewer's 'Current Text' toolbar.

Pick-to: 6.2
Change-Id: I53286ef1e8e7c5fba37858dda7317ae74d95b528
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 22:41:06 +02:00
Tor Arne Vestbø
9e1875483c macOS: Assume input method handles key event
When input methods are enabled for the focus object we send key events
through interpretKeyEvents, which will involve the input method in the
key event processing. The input method will get back to us with callbacks
such as insertText, setMarkedText, or doCommandBySelector.

In the case of insertText, when the inserted text matches the originating
key event's text, we opt to not send the text as an QInputMethodEvent,
and instead fall back to sending it as a normal QKeyEvent. The reason
for this is that Qt's IM protocol was designed to handle composited
text, so sending non-composited (but IM-initiated) text input as IM
events is unexpected (see 2d05d3bd28).

However, we cannot assume that the input method will always call us
back with one of the above mentioned methods. The input method can
very well eat the event as part of its own operation. This happens
for example when pressing and holding 'a' in a US English keyboard
layout, which will pop up an input panel for the various accents
available. Or it may happen when using the AquaSKK third party IM,
which uses the 'l' key to switch the input mode to latin without
producing any characters.

To allow these input methods the freedom to control the processing
of key events we need to reverse the logic for when we send key
events as QKeyEvent. We now assume that the IM will handle the
event, and only trigger QKeyEvent in two cases where we explicitly
were called back by the IM, but decided that a QKeyEvent is needed:

 - If the IM calls insertText and we consider the text simple text
 - If the IM calls doCommandBySelector and we can't find a matching
   selector for the command. We only implement insertNewline and
   cancel, so in all other cases we want to pass on the key event
   to let the focus object handle it, for example for 'Select All'
   and similar key combinations.

Fixes: QTBUG-46300
Fixes: QTBUG-71394
Pick-to: 6.2
Inspired-by: Vladimir Belyavsky
Change-Id: I9a73a8e1baa2ebe0c5df1166a9ec3d9843632bb1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 22:41:03 +02:00
Mårten Nordheim
587d64507a QNetworkAccessCache: Remove unused code
The function was never called. As a consequence receiverQueue was
only ever read and never written.

Change-Id: I30905446452d9f263124d3af08c42e2e1b0cafbe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-27 21:17:04 +02:00
Shawn Rutledge
ba8f9d8d92 Fix deprecation of QMouseEvent::source() and flags()
Amends 53496e67f0:
- move flags() out of the QT_DEPRECATED_SINCE block in the header
- add QT_DEPRECATED_SINCE block around source() implementation

Pick-to: 6.1 6.2
Change-Id: Id52fa6b04a13efbede3e6ac440060f90b283e773
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 20:31:18 +02:00
Edward Welbourne
d95f4d0018 qlocale_win: Simplify and explain month-name format lookup
Retain the given month number and simply subtract one from it in the
one place it's used (once the two array dereferencs are unified). That
makes it clear that the off-by-one numbering is just down to our
arrays, not some weired quirk of the MS API. Simplify a condition by
inverting it: compare to LongFormat instead of ||-ing comparisons to
the other two members of the enum.

Change-Id: Ia03486b7869255ecdb1372de62d5c745d35d0a0a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-27 20:31:18 +02:00
Juha Vuolle
17d7a8dc2e Update Android default SDK from 29 to 30
By the time of Qt 6.2 release all new apps targeting Play store must
target API level 30 (Android 11) or above (starting in 08/2021 for
new apps and 11/2021 for existing apps' updates).

Pick-to: 6.2 5.15
Task-number: QTBUG-94451
Change-Id: Id7fa2fd62899a7259e365c917292c6c3ac0d2b0d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-08-27 18:31:17 +00:00
Edward Welbourne
7af79ba091 Make clear why QTestLog::addB?XFail() don't add to counters
This reverts commit 904617dfb8 and makes
clear to future readers why that wouldn't be a sensible change.
Update the test's data, eliminating a case of duplicate counting that
was caused by the reverted commit.

Task-number: QTBUG-95661
Pick-to: 5.12 5.15 6.1 6.2
Change-Id: Ice6d3ab06ca171e0d6eb0fac757f1ab774e229f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-27 20:16:18 +02:00
Tor Arne Vestbø
a56b915f71 macOS: Handle replacement range during marking of text
The input method may include already committed text when marking text,
in which case the replacement range reflects the position and length
of the existing text.

We handle this the same way we do replacement ranges in insertText.

Pick-to: 6.2
Change-Id: I148e4701318a59c7e0d9441d157199d7c8606f43
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Tor Arne Vestbø
f97e936049 macOS: Handle IM insertNewline by sending synthetic Qt::Key_Return
Depending on the input method, pressing enter may result in simply
dismissing the input method editor, without confirming the composition.
For example with Hiragana, pressing 'a', then 'Tab', and then 'Enter'.

In other cases it may confirm the composition as well, for example
with Hiragana, pressing 'a' and then 'Enter'.

And in some cases the IME will produce an explicit new line, for
example with US English, pressing '~' and then 'Enter', or with
2-Set Korean, pressing 'a', then 'j', and then 'Enter'.

Semantically, the input method has then asked us to insert a newline,
and we should probably do so via an QInputMethodEvent, either directly
or via [self insertText:@"\r"]. This is also how NSTextView handles
the command. But, if we did, we would bypass all the code in Qt (and
clients) that assume that pressing the return key results in a key
event, for example the QLineEdit::returnPressed logic.

To ensure that clients will still see the Qt::Key_Return key event,
we send it as a normal key event. But, we can not fall back to
handleKeyEvent for this, as the original key event may have text
that reflects the combination of the inserted text and the newline,
e.g. "~\r". We have already inserted the composition, so we need to
follow up with a single newline event.

Task-number: QTBUG-39125
Pick-to: 6.2
Change-Id: If1e95687e6d5b06011692175a325f457b0b8a72f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Tor Arne Vestbø
f563203f60 macOS: Factor out key event handling into helper struct
This allows us to share code between handleKeyEvent: and flagsChanged:
for parsing the incoming NSEvent, and allows for sending key events
from other call sites in the future without duplicating the parsing
and sending logic.

Pick-to: 6.2
Change-Id: Ic63f740523496a9432e439663a20f78b5bc234c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Tor Arne Vestbø
2945c6223b macOS: Return early from key handler if shortcut was handled
The code paths after accepting a shortcut event can never be hit.

Pick-to: 6.2
Change-Id: Ida77417adb8fcfd25a4b20c4eb86056b3769f014
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Mårten Nordheim
b33ccd99e1 QNetworkCookie: Clean up
Rewrite the regex to not capture the things we ignore anyway.
Use capturedView to avoid allocating a string just to turn it into an
int.
Fix a (usually) ifdef-ed out piece of code that was still calling
a QRegExp function.
Make the QRegularExpression static const to save it from having to
recompile every time.

Change-Id: I2f4841a2bc35df4e6cea44aec72432410583f770
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-27 19:22:28 +02:00
Laszlo Agocs
8043a1a75a rhi: gl: Set the screen on the context, if possible
Take the screen from the window, if the window was specified.

When it comes to Qt Quick, this is in fact required in order to
make the behavior on par with Qt 5, see
https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/quick/scenegraph/qsgthreadedrenderloop.cpp?h=5.15#n1336
try to mirror that in Qt 6 as well. There are still subtle differences
between Qt 5 and Qt 6 in particular when qt_gl_global_share_context is
set (do we set the screen from that or from the window?), for now leave
that question unsettled.

What exactly setting the screen on the context does is platform
specific, and can become relevant with multi screen, multi GPU
systems.

Pick-to: 6.2
Change-Id: Icc90b8fea87bf1e34ecf1dec0702f4d3c411db00
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-08-27 18:10:33 +02:00
Giuseppe D'Angelo
7d4d47de70 QObject::connect(): fail to connect to a functor if UniqueConnection is passed
The connect() documentation makes it clear that UniqueConnection does
not work with free functions / function objects and the like; only with
actual PMFs. Rather than silently *ignoring* the flag, be vocal about its
presence by warning, and make the connection fail (as the user has
passed an illegal argument).

[ChangeLog][QtCore][QObject] QObject::connect() now will refuse to
connect a signal to a free function / function object if UniqueConnection
is passed. Note that UniqueConnection has never worked for such
connections -- the flag was simply ignored, and they were established
multiple times. Now, the flag is not ignored and results in a connection
failure (as well as a runtime warning by Qt).

Change-Id: I6509667018c74f9bd24910cde0a1b16c5f84f064
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-27 15:45:25 +02:00
Giuseppe D'Angelo
c9830c2fb9 QToolButton: reimplement the fix for QTBUG-95255
The code in 188d739400 uses a connect() to
a lambda, passing UniqueConnection to avoid establishing the connection
more than once. The problem is that UniqueConnection does not work
with lambdas; it works only with "regular" PMFs to QObject subclasses.

Re-do the same fix, but without a connection: use the checkStateSet()
virtual from the base class that will notify us if setChecked() is
being called on the tool button, and from there synchronize the state
of the default action.

Change-Id: Id512812c562cd6d20bc1a489753b33c269919d32
Fixes: QTBUG-95255
Pick-to: 6.2 6.1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 13:45:25 +00:00
Morten Johan Sørvig
89cda52d66 wasm: enable the new event dispatcher for qtcore
Use the new event dispatcher for all non-GUI threads,
nn practice for the main thread when using QCoreApplication,
and when calling QThread::exec().

Change-Id: I9184d52532e06da7e6a87ee27c7d53e0d15e693a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-27 15:45:25 +02:00
Morten Johan Sørvig
ecb92aacab wasm: add new event dispatcher implementation
Add QEventDispatcherWasm to QtCore. The event dispatcher
supports managing event queue wakeups and timers, both
for the main thread or for secondary threads.

Blocking in processEvents() (using QEventLoop::WaitForMoreEvents)
is supported when running on a secondary thread, or
on the main thread when Qt is built with Emscripten’s
asyncify support.

Code is shared for all both modes as far as possible,
with breakout functions which handle main and secondary
thread as well as asyncify specifics,. Some functions
like wakeUp() can be called from any thread, and needs
to take the calling thread into consideration as well.

The current asyncify implementation in Emscripten is
restricted to one level of suspend, and this restriction
carries over to Qt as well. In practice this means we
support one level of exec()-like API.

Note that this commit does not _enable_ use of the
new event dispatcher. This will be done in separate
commits.

Task-number: QTBUG-76007
Task-number: QTBUG-64020
Change-Id: I77dc9ba34bcff59ef05dd23a46dbf1873cbe6780
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-27 15:45:25 +02:00
Morten Johan Sørvig
c6362cd55c wasm: add Emscripten module accessor to qtloader.js
After enabling -s MODULARIZE=1 there is no longer a
global MODULE object. Add module() accessor which can
be used to retrieve the Emscripten module.

This does not really fit with the current state tracking
since the app transitions from “loading” to “running” before
the module object is ready. We’ll have to revisit this
at some point.

Change-Id: Ib7191cf4ce436e1de99f84b63ed4c10936fa62b1
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-27 15:45:24 +02:00
Alexey Edelev
e1fe816d46 Implement generating of private cpp exports
Add the generating of private cpp exports for Qt modules.

Add the GENERATE_PRIVATE_CPP_EXPORTS option to qt_internal_add_module
that is the manual switch for private exports generator. Existing
modules in qtbase doesn't follow any strict convention of using
private cpp export. So there is no clue how to detect if generating of
the private exports is required or not for the module.

Use autogenerated private cpp exports in QtNetwork module.

CPP_EXPORT_HEADER_NAME argument of the qt_internal_add_module function
is replaced by the CPP_EXPORT_HEADER_BASE_NAME and has a different
meaning. The provided name is used as a base name for the private and
non-private headers that contains cpp exports. Header files suffixes
are constant: .h and _p.h for the non-private and private header files
accordingly.

Pick-to: 6.2
Task-number: QTBUG-90492
Change-Id: Icf11304e00379fb8521a865965c19b974e01e62f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-27 11:01:47 +02:00
Tor Arne Vestbø
abdd524519 macOS: Check NSEvent.characters to determine dead key state
We map NSEvent.characters to text that we pass on in our QKeyEvent,
but for Qt 4 compatibility we explicitly skip function keys and arrow
keys, as the text these events produce are control characters. See
4dbce2a469.

However, these keys are not dead keys, so we can't use the resolved
text we're planning to pass on to Qt to determine if they are.

Pick-to: 6.2
Change-Id: Ib59f0489ae014379c699600f14634c55161ccc8a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 00:29:08 +02:00
Tor Arne Vestbø
294e4c7aa8 macOS: Use current NSEvent to determine if IM text matches key event
Gives us one less state member to worry about in the IM machinery.

Task-number: QTBUG-35700
Pick-to: 6.2
Change-Id: Iaa06b29015f9b9594b8107b74a8931f076a26e12
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-08-27 00:29:02 +02:00
Mårten Nordheim
b3c0537404 QNetworkCookie: Fix use-after-free
The code was previously calling indexOf() on a temporary, which
QRegularExpression would create backing storage for.
After 11d1dcc6e2 the internals were made
to use the QStringView path, which inadvertently meant that there was
no storage for the temporary string anymore. So we need to keep it alive
ourselves.

Change-Id: I542da7010934594eba3b93261322963866ed9297
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 18:16:41 +02:00
Lars Schmertmann
0755eba5e8 Android: Add information about who launched this activity to intents
* With this change, applications can easily determine the source
  of an intent without creating an own extension of QtActivity.
* https://developer.android.com/reference/android/app/Activity#getReferrer()

Task-number: QTBUG-84382
Pick-to: 6.2
Change-Id: I6a5200af1d997640f02e2b934343914fb5f32ccc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-08-26 15:44:12 +00:00
Ievgenii Meshcheriakov
4bf3010378 QUrl: Implement UTS #46
UTS #46 (https://unicode.org/reports/tr46/) is a successor to
IDNA 2003/2008 standards from Unicode.

The current implementation uses nontransitional processing by default.
An optional argument is added to QUrl::toAce() and QUrl::fromAce() to
allow using transitional processing and to ignore the IDN whitelist.

[ChangeLog][QtCore][QUrl] ACE processing is now performed according
to the UTS #46 standard based on IDNA 2008 instead of IDNA 2003.

Task-number: QTBUG-85371
Change-Id: I46b2e86792bc9699cb6961bae8e283fbff72f874
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 16:55:05 +02:00
Ievgenii Meshcheriakov
f5360b7c72 unicode: Regenerate Unicode tables
Re-run unicode utility to update the Unicode tables. This adds
properties and mappings needed to implement UTS #46 (IDNA).

Task-number: QTBUG-85323
Change-Id: Id1de91caddd82095f8f8f2301bfd7bb2ee3fcafd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 16:55:05 +02:00
Alexandru Croitor
80705298ca CMake: Build a subset of tests when targeting iOS in the CI
Add infrastructure to build cmake auto tests in the CI when targeting
iOS.
Currently the are only CI instructions for qtbase.
More work is needed to make it work for other repos.

With this change, we will build a single Widgets application targeting
the iOS simulator. We can't target the device SDK in the CI because
signing fails due to a missing signing certificate and provisioning
profile.

The Coin instructions will now set a QT_BUILD_ENVIRONMENT=ci env var
whose value will be checked in _qt_internal_test_expect_pass, to
ensure we build for the simulator SDK when using a universal Qt.
Without this, xcodebuild will try to build with the device SDK and
fail to build the project.

Pick-to: 6.2
Task-number: QTBUG-95839
Change-Id: Ib39c9527b107b2004746ccbdc9d9d1d658f88c76
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-26 16:40:15 +02:00
Alexandru Croitor
1f3949a5a8 CMake: Make _qt_internal_test_expect_pass more configurable
Introduce new options: NO_CLEAN_STEP, NO_BUILD_PROJECT_ARG,
GENERATOR, MAKE_PROGRAM, BUILD_TYPE.

If cache or env var QT_CMAKE_TESTS_ADDITIONAL_CONFIGURE_OPTIONS is
provided, the value is interpreted as a list of additional configure
arguments to pass to the built project.

Also skip adding a test command if there is no BINARY or BINARY_ARGS
option provided.

Pick-to: 6.2
Change-Id: I3a1d82b41a734dcd3f473e59cc64efd00363e49b
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-26 16:40:15 +02:00
Laszlo Agocs
ae306b1c5a rhi: Polish some feature flag docs
Clean a bit, also enhance, e.g. mention textureLod for TexelFetch which
is how Quick3D uses it, and most notably expand the "in practice" notes.
As no application or library can be expected to write fully conditional
code based on all these flags, knowing when a certain feature is
(un)supported in a real run time environment is essential in order to
make informed decisions on when and in what manner (i.e. with or without
conditions), rely on a given feature.

Pick-to: 6.2
Change-Id: I15ea34e11bd345b36248f92de9b1fdb1fdc3e8d9
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-08-26 15:31:53 +02:00
Laszlo Agocs
afa0ce9045 rhi: gl: Allow passing in a custom shareContext
We already honor AA_ShareOpenGLContexts and pass in the QGuiApp's
context as the shareContext for the QRhi's QOpenGLContext. Extend this
to also allow specifying a QOpenGLContext in the init params struct.

A good example of this is the backingstore compositor that serves
QQuickWidget and co. If one wanted to implement that with (an
OpenGL-based) QRhi, instead of direct OpenGL calls, then the ability
to create a QRhi that uses a context that shares resources with a
given other context becomes essential.

Pick-to: 6.2
Change-Id: I6bc5ff8e803d467f8795197ac1f12fdc0f73bbd1
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-08-26 15:31:53 +02:00
Ivan Solovev
7729989648 QLocale: improve documentation snippet
QString::toDouble() now always uses C locale, so the previous code
snippet does not make much sense, as the results do not depend on the
selected default locale.
The updated snippet uses the default locale, which allows to show the
difference between locales.

Pick-to: 6.2
Change-Id: I76a00429fa5b75cf109cf45bc25280a7fd427e0f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 15:31:53 +02:00
Morten Johan Sørvig
8585cd2483 wasm: don’t dereference null reply pointer
Move all access to the reply inside the nullptr check,
while making sure to still call emscripten_fetch_close()
unconditionally where needed.

Make all four Emscripten callback handlers have a similar
structure where we check if the reply is not null and
not in the Aborted state.

(This removes one emscripten_fetch_t nullptr check in
stateChage(), if it is really the case that Emscripten
calls us with a null emscripten_fetch_t then we should
add it back.)

Pick-to: 5.15 6.1 6.2
Change-Id: Iadcbe6338c338cfeb8967490e0951d8b3e1ec5b3
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-26 15:31:53 +02:00
Tor Arne Vestbø
e68bf3ddaf macOS: Modernize and clean up key event handling
- Pass key event type as QEvent::Type
  - Use proper type for NSEventModifierFlags
  - Use modern Objective-C property access in key handler
  - Modernize flagsChanged implementation using ranged-for
  - Use explicit Qt::Key type in key handling
  - Add FIXME comments for dubious code

Pick-to: 6.2
Change-Id: I533e0a5685108dc3cdccd2b276b4eb7a729d172e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-26 14:53:03 +02:00
Tor Arne Vestbø
146bc0e607 macOS: Move replacement range calculations into helper methods
We're going to need this logic for marked text as well.

Pick-to: 6.2
Change-Id: I461024c3df0c4956c794f16d1cb31fc6b0efe4c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-26 14:53:02 +02:00
Tor Arne Vestbø
137c28d077 Fix Clang warning about loop variable creating a copy
Change-Id: I2a8b75294ee3bde008bcff37519da087f603ca51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-26 14:53:02 +02:00
Volker Hilsheimer
98d65c8d42 QGraphicsView: send timestamp information through QGraphicsSceneEvent
Qt relies on event timestamp information to detect double click events.
The information was not passed through QGraphicsSceneEvent, so the
synthesized QMouseEvent delivered for the second press of a double click
to an embedded widget was never recognized as a double click.

This requires addition of a new setter/getter to QGraphicsSceneEvent.
Event though not all QGraphicsSceneEvent instances will have a valid
timestamp, this provides us with more flexibility than adding the API to
several QGraphicsSceneEvent types (mouse, touch, wheel).

Pick-to: 6.2
Fixes: QTBUG-96009
Change-Id: I343f25902286157f6d6670641dfad9c92dd44250
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-26 14:32:26 +02:00
Mårten Nordheim
842ece2117 NetworkAccessBackend: Remove the backend part of the name
For consistency with naming of other plugins.

Slight compatibility break, but this is semi-private API.

[ChangeLog][Network][QNetworkAccessBackend] The NetworkAccessBackend
plugin-type is renamed to NetworkAccess, if you have a plugin marked
NetworkAccessBackend you need to change it to NetworkAccess.

Pick-to: 6.2
Change-Id: Ib5ea02f542254b0f5b8c425c89ee00075a58c956
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 14:32:26 +02:00