QQuick3DObject: simplify disconnecting out of Private::connectionMap


The old code used find() + erase(), in four LOC. But we can just use
take(), because disconnecting from a default-constructed Connection is
a no-op.

Technically speaking, this changes the sequence of operations: before,
it would first disconnect() and then erase(), now it first erases and
then disconnects. The new way is safer, because it doesn't leave
(albeit briefly) an invalid Connection in the QHash, which may cause
false positives if e.g. contains() was used to check whether a given
QObject was still connected. I'm not saying there is such code, just
that take() is in general more robust.

This, as a drive-by, also avoids passing a const object to
disconnect(), which is going to be deprecated since the function
modifies its argument.

Amends b5306e189095279e466d00895786d3e13b162ea6 (6.5), which, however,
just moved this code out of the .cpp file.

Pick-to: 6.12 6.11 6.8
Task-number: QTBUG-144929
Change-Id: I19f5226edc5f528b9c94690194a4a5bbcb9bbd72
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
commit0fda3b3fd8f37dc38afb30c36626795c479e6da5
parent7f1b1238718075ce43af5043c4757a794e664c67
authorMarc Mutz <marc.mutz@qt.io>
committerMarc Mutz <marc.mutz@qt.io>
commit timeMon, 24 Aug 2026 09:01:12 +0000