SignalHandler: optimize remove(QObject*)


Don't look up the object in m_connectionCounter three times
(contains(), value(), remove()). Instead, use find() to find it once,
and std::move(it.value()) + erase() as a take() that can report
whether the element existed in the container prior to extraction.

This also means we can port the foreach loop to a ranged for loop now
without hesitation: by erasing the element from the container before
iterating over the QObject::disconnect() calls, we ensure immunity
against a potential reentrance into the object (disconnectNotify()
calls unknown code) that changes m_connectionsCounter, which the
foreach loop was immune against (d/t taking a copy of the container
under iteration).

Change-Id: I6cf36c729f488bf1334fd344ddd0191db101d103
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
commit485727b41ed777ee9392be8aa770adb1b4415aa6
parent20f0b58a24dabf17d5d1dcfc06eaa3ccafcd7268
authorMarc Mutz <marc.mutz@qt.io>
committerMarc Mutz <marc.mutz@qt.io>
commit timeSun, 25 Dec 2022 18:10:14 +0100