From 8a3b60207162ad0d6540531c6ede0696370b75b3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 27 Sep 2013 15:02:54 +0000 Subject: fix for a crash on dynamic extra icons unload git-svn-id: http://svn.miranda-ng.org/main/trunk@6251 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/extraicons/extraicons.cpp | 58 +++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'src/modules/extraicons') diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp index 1a34874b83..c362115a0f 100644 --- a/src/modules/extraicons/extraicons.cpp +++ b/src/modules/extraicons/extraicons.cpp @@ -56,25 +56,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) return 0; } -void KillModuleExtraIcons(int hLangpack) -{ - for (IconIter p1 = extraIconsByHandle.begin(); p1 != extraIconsByHandle.end(); p1++) - if ((*p1)->hLangpack == hLangpack) - extraIconsByHandle.erase(p1--); - - for (IconIter p2 = extraIconsBySlot.begin(); p2 != extraIconsBySlot.end(); p2++) - if ((*p2)->hLangpack == hLangpack) - extraIconsBySlot.erase(p2--); - - for (int i=registeredExtraIcons.getCount()-1; i >= 0; i--) { - BaseExtraIcon *p = registeredExtraIcons[i]; - if (p->hLangpack == hLangpack) { - registeredExtraIcons.remove(i); - delete p; - } - } -} - int GetNumberOfSlots() { return clistSlotCount; @@ -202,16 +183,15 @@ struct compareFunc : std::binary_function &groups) { - unsigned int i; - for (i = 0; i < extraIconsByHandle.size(); i++) - extraIconsByHandle[i] = registeredExtraIcons[i]; + extraIconsByHandle.clear(); + for (int k = 0; k < registeredExtraIcons.getCount(); k++) + extraIconsByHandle.push_back(registeredExtraIcons[k]); + unsigned int i; for (i = 0; i < extraIconsBySlot.size(); i++) { ExtraIcon *extra = extraIconsBySlot[i]; - if (extra->getType() != EXTRAICON_TYPE_GROUP) - continue; - - delete extra; + if (extra->getType() == EXTRAICON_TYPE_GROUP) + delete extra; } extraIconsBySlot.clear(); @@ -235,6 +215,32 @@ void RebuildListsBasedOnGroups(vector &groups) /////////////////////////////////////////////////////////////////////////////// +void KillModuleExtraIcons(int hLangpack) +{ + LIST arDeleted(1); + + for (int i=registeredExtraIcons.getCount()-1; i >= 0; i--) { + BaseExtraIcon *p = registeredExtraIcons[i]; + if (p->hLangpack == hLangpack) { + registeredExtraIcons.remove(i); + arDeleted.insert(p); + } + } + + if (arDeleted.getCount() == 0) + return; + + vector groups; + LoadGroups(groups); + RebuildListsBasedOnGroups(groups); + + for (int k=0; k < arDeleted.getCount(); k++) + delete arDeleted[k]; + arDeleted.destroy(); +} + +/////////////////////////////////////////////////////////////////////////////// + int ClistExtraListRebuild(WPARAM wParam, LPARAM lParam) { clistRebuildAlreadyCalled = TRUE; -- cgit v1.2.3