M
Morten Aune Lyrstad
Here's the deal: I'm looping through a collection of listener class
objects like this: (illustration code only)
AClass::ThrowEvent()
{
for (int i = 0; i < numListeners; i++)
{
listener.OnEvent();
}
}
AClass:estroy()
{
if (listener) {
numListeners = 0;
delete listener;
listener = null;
}
}
The listener array consists of a derivation of a listener class.
The OnEvent call may actually end up destroying the AClass object, by a
call to AClass:estroy().
What I need is a way to end the loop if this function is called, because
the Destroy will invalidate the listener array. In worst case scenarios,
even the AClass object itself might be invalidated. Does anyone have an
idea on how I can accomplish this? I would prefer that the creator of
the listener classes did not have to consider this.
Yours,
Morten Aune Lyrstad
objects like this: (illustration code only)
AClass::ThrowEvent()
{
for (int i = 0; i < numListeners; i++)
{
listener.OnEvent();
}
}
AClass:estroy()
{
if (listener) {
numListeners = 0;
delete listener;
listener = null;
}
}
The listener array consists of a derivation of a listener class.
The OnEvent call may actually end up destroying the AClass object, by a
call to AClass:estroy().
What I need is a way to end the loop if this function is called, because
the Destroy will invalidate the listener array. In worst case scenarios,
even the AClass object itself might be invalidated. Does anyone have an
idea on how I can accomplish this? I would prefer that the creator of
the listener classes did not have to consider this.
Yours,
Morten Aune Lyrstad