f141108887
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> |
||
---|---|---|
.github/workflows | ||
bin | ||
cmake | ||
coin | ||
config.tests | ||
dist | ||
doc | ||
examples | ||
lib | ||
libexec | ||
LICENSES | ||
mkspecs | ||
qmake | ||
src | ||
tests | ||
util | ||
.cmake.conf | ||
.gitattributes | ||
.gitignore | ||
.lgtm.yml | ||
.tag | ||
CMakeLists.txt | ||
config_help.txt | ||
configure | ||
configure.bat | ||
configure.cmake | ||
dependencies.yaml | ||
qt_cmdline.cmake |