When the audiences of the old canvas were copied to the new one, the C++ default assignment operator was used. This meant a pointer to the old audiences was copied, causing a crash when continuing iteration through a deleted audience.
Todo for later: This could use further improvement, perhaps by utilizing a QSet in Observers<>. If the observers set is destroyed in the middle of iterating through a large number of observers, there will likely still be a crash because the 'next' iterator of the loop will become invalid (and not just point to the end of the set as in this instance when there is a single observer).
Observers<>::Loop could also observe the set itself, although in that case it would be necessary to derive a custom set class that provides the necessary notifications to Loop.
Fixed|libdeng2: Crash when recreating canvas
When the audiences of the old canvas were copied to the new one,
the C++ default assignment operator was used. This meant a pointer
to the old audiences was copied, causing a crash when continuing
iteration through a deleted audience.
Todo for later: This could use further improvement, perhaps by
utilizing a QSet in Observers<>. If the observers set is destroyed
in the middle of iterating through a large number of observers,
there will likely still be a crash because the 'next' iterator of
the loop will become invalid (and not just point to the end of the set
as in this instance when there is a single observer).
Observers<>::Loop could also observe the set itself, although in
that case it would be necessary to derive a custom set class that
provides the necessary notifications to Loop.