Go to file
Marc Mutz f141108887 Port QCoreApplication::requestPermission() to SlotObjUniquePtr internally
Well, except that the ownership of the slot object here is actually
shared between the PermissionReceiver and the lambda passed to
QPermission::Private::requestPermission(), which eventually may hand
ownership over to QMetaCallEvent, so we can't really use
SlotObjUniquePtr.

While we can, of course, manually copy and call ref(), even if the
slot-object is stored in a SlotObjUniquePtr, unfortunately, the lambda
is subsequently stored in a std::function, which infamously cannot
hold move-only objects, so we actually need something copyable.

So grasp the nettle and implement a SlotObjSharedPtr.

I was originally planning to just make this a typedef for
QIntrusiveSharedPointer, but that's not in dev, yet, let alone 6.5, to
which we're picking this, and there was always this nagging impedance
mismatch between the QIntrusiveSharedPointer behavior, inherited from
it's Q(Explicitly)SharedPointer roots, on the one hand, to always
ref() in the constructor from raw pointer, and, OTOH, QSlotObjectBase
starting its life with a ref-count of one (1) (not zero (0), like
QSharedData).

I eventually found the (elegant, if I may say so myself) solution to
just not provide a constructor from raw pointer, only one from
SlotObjUniquePtr, which, granted, has the same issue, but which is, by
now, probably, hopefully, more fully grasped by QtCore regulars, and so
we can piggy-back on that for SlotObjSharedPtr's constructor
semantics.

Add a comment nevertheless.

Inside the lambda, we could theoretically move the slotObj into
QMetaCallEvent::create(), after adding such conversion to
SlotObjSharedPtr, but that would require making the lambda mutable,
and seeing as it's stored in a std::function and copied around, I was
not ready to make that change just yet.

As a drive-by, make PermissionReceiver's constructor explicit.

Pick-to: 6.6 6.5
Fixes: QTBUG-115330
Change-Id: I4e0cec13d19a19eeec31e4101ce289d07c92ce46
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-02 22:11:12 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Add simple project generation based on existing source files 2023-02-08 12:59:19 +01:00
cmake Fix standalone headersclean_check targets 2023-08-02 20:22:52 +02:00
coin COIN/Android: Move android_emulator_launcher.sh to qt5.git 2023-07-25 23:07:45 +03:00
config.tests Remove the mandatory x86-64 features from its feature list 2023-05-31 14:55:37 -07:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Docs: Add a macro for documenting something as a technical preview 2023-08-02 12:47:15 +00:00
examples Update Android notifier example to match example guideline 2023-08-02 15:47:15 +03:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec Remove syncqt.pl 2023-06-30 13:23:46 +02:00
LICENSES Clarify license of SHA-1 algorithm 2023-04-26 16:36:18 +02:00
mkspecs Support PRELOAD var substitution for WASM main html with qmake 2023-07-27 22:16:21 +02:00
qmake qtpaths: generate proper JSON 2023-07-08 10:50:41 +02:00
src Port QCoreApplication::requestPermission() to SlotObjUniquePtr internally 2023-08-02 22:11:12 +02:00
tests CMake: remove check for cxx11_future 2023-08-02 12:36:18 -07:00
util Use module.exports to get the entry function name in WASM test lib 2023-08-02 15:43:45 +02:00
.cmake.conf CMake: Require CMake 3.21 when building/using Qt on Apple platforms 2023-06-28 22:09:20 +02:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Add CMakeUserPresets.json to .gitignore 2023-06-23 12:13:08 +02:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
CMakeLists.txt Introduce QT_ALLOW_SYMLINK_IN_PATHS flag 2023-05-03 19:44:45 +02:00
config_help.txt Correct the default value of unity-build-batch-size in the help message 2023-07-19 22:50:32 +02:00
configure Retrieve an old -redo behavior 2023-02-07 18:51:58 +00:00
configure.bat Retrieve an old -redo behavior 2023-02-07 18:51:58 +00:00
configure.cmake Update the implementation of -unity-build 2023-06-29 10:20:25 +02:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
qt_cmdline.cmake Update the implementation of -unity-build 2023-06-29 10:20:25 +02:00