Copy DataEngine relays before itterating

relay->checkQueueing emits a signal to all observers. As it's a signal
anything can happen at that point. It's seemingly common for a receiver
to connect/disconnect a new visualisation which in turn alters
d->relays.

This broke when a foreach (with implicit shallow copy) was ported to a
for statement.

This report contains a good analysis and test case

BUG: 422973

Probably also:

BUG: 421392
BUG: 423713
BUG: 423776
BUG: 422230
BUG: 423081
This commit is contained in:
David Edmundson 2020-07-04 23:54:20 +01:00 committed by David Edmundson
parent b713e96531
commit 582d9ed38d

View File

@ -353,7 +353,9 @@ void DataContainer::checkForUpdate()
if (d->dirty) {
emit dataUpdated(objectName(), d->data);
for (SignalRelay *relay : qAsConst(d->relays)) {
//copy as checkQueueing can result in deletion of the relay
const auto relays = d->relays;
for (SignalRelay *relay : relays) {
relay->checkQueueing();
}