From cc89eff6f778090dd959e204980762ce217f3ef7 Mon Sep 17 00:00:00 2001 From: Nick Gammon Date: Thu, 28 Oct 2010 16:58:25 +1100 Subject: [PATCH] Improvement to plugin deletion problem --- doc_construct.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/doc_construct.cpp b/doc_construct.cpp index 652de692..d7575153 100644 --- a/doc_construct.cpp +++ b/doc_construct.cpp @@ -522,25 +522,20 @@ int i; udpSocketIterator++) delete udpSocketIterator->second; -// delete chat sessions + // delete chat sessions DELETE_LIST (m_ChatList); -// delete plugins - - PluginListIterator pit = m_PluginList.begin (); + // delete plugins // we have to do it this way, because otherwise if a plugin attempts to access the // plugin list (eg. BroadcastPlugin, Trace) during the delete operation, then it // may call a plugin that was deleted a moment ago, but is still in the list. - while (pit != m_PluginList.end ()) - { - CPlugin * pPlugin = *pit; // get this one - pit = m_PluginList.erase (pit); // remove from list, move onto next one - delete pPlugin; // delete *this* one - } - + for (PluginListIterator pit = m_PluginList.begin (); + pit != m_PluginList.end (); + pit = m_PluginList.erase (pit)) // erase from list and get next one + delete *pit; // delete *this* one CloseLog (); // this writes out the log file postamble as well