| 14823 | |
| 14824 | |
| 14825 | void MsgMonitorList::Dispose() |
| 14826 | { |
| 14827 | // Although other action taken by GuiType::Destroy() ensures the event list isn't |
| 14828 | // reachable from script once destruction begins, we take the careful approach and |
| 14829 | // decrement mCount at each iteration to ensure that if Release() executes external |
| 14830 | // code, this list is always in a valid state. |
| 14831 | while (mCount) |
| 14832 | { |
| 14833 | --mCount; |
| 14834 | if (mMonitor[mCount].is_method) |
| 14835 | free(mMonitor[mCount].method_name); |
| 14836 | else |
| 14837 | mMonitor[mCount].func->Release(); |
| 14838 | } |
| 14839 | free(mMonitor); |
| 14840 | mMonitor = nullptr; |
| 14841 | mCountMax = 0; |
| 14842 | // Dispose all iterator instances to ensure Call() does not continue iterating: |
| 14843 | for (MsgMonitorInstance *inst = mTop; inst; inst = inst->previous) |
| 14844 | inst->Dispose(); |
| 14845 | } |
| 14846 | |
| 14847 | |
| 14848 | BIF_DECL(BIF_On) |