diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-27 15:02:54 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-27 15:02:54 +0000 |
commit | 8a3b60207162ad0d6540531c6ede0696370b75b3 (patch) | |
tree | 7b26d4eb5a104e7fb357523785e3745649ac85ba /src/modules/extraicons | |
parent | 57a672e41da2cba46722e337a80f9c080b39305d (diff) |
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
Diffstat (limited to 'src/modules/extraicons')
-rw-r--r-- | src/modules/extraicons/extraicons.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
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<const ExtraIcon *, const ExtraIcon *, void RebuildListsBasedOnGroups(vector<ExtraIconGroup *> &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<ExtraIconGroup *> &groups) ///////////////////////////////////////////////////////////////////////////////
+void KillModuleExtraIcons(int hLangpack)
+{
+ LIST<ExtraIcon> 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<ExtraIconGroup*> 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;
|