Skip changes made while iterating over connections for emit


If changes are made to the connections while iterating over them
during an emit, these new changes should be ignored until the next
emit.  If not, the following things could happen:
 * newly added connections could be called for the current emit
 * an existing connection may not be called at all

New connections added to the list are already ignored because forEach
caches the length before processing an array.

However, if an item is removed during forEach, the current index is
not adjusted, which will result in next item being skipped if the
removed item is before the current index. This is dealt with by creating
a new list during disconnect with the diconnected item removed.  This
way the list that forEach uses is not modified.

This logic is slightly different than QObject, which uses a linked list.
If handlers A and B have been attached to the same signal, and handler A
disconnects handler B, handler B would still be called, even if it was
connected after handler A, which is not the case for QObject.  A more
complex solution may be required if this behavior needs to match
QObject.

This also removes an error message when disconnect fails to find any
matching connection.  This more closely matches QObject.

Change-Id: Ief04426a962362055022f450d9767d4b5fe152a1
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
commitb808e4f8ec42df64fee5f6f170c225b6fbd62070
parent295b33d05396cad96bbed3094bf23d880fe58109
authorAndrew Webster <awebster@arcx.com>
committerAndrew Webster <awebster@arcx.com>
commit timeFri, 21 Feb 2020 10:46:35 -0500