diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-20 18:41:56 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-20 18:41:56 +0000 |
commit | 44141ccc8e279bfd390b91f2f0b737b39da6481c (patch) | |
tree | c3cee7cf5fde12c891c834272272b85911328198 /src/modules/extraicons/extraicons.cpp | |
parent | c5c8084eff5beffa9c007de67782b973f2c64fde (diff) |
automatic extra icon removal on dynamic plugin unloading
git-svn-id: http://svn.miranda-ng.org/main/trunk@2399 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/extraicons/extraicons.cpp')
-rw-r--r-- | src/modules/extraicons/extraicons.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp index 71565bb89a..c2d1cb1e1e 100644 --- a/src/modules/extraicons/extraicons.cpp +++ b/src/modules/extraicons/extraicons.cpp @@ -34,7 +34,9 @@ // Prototypes ///////////////////////////////////////////////////////////////////////////
-vector<BaseExtraIcon*> registeredExtraIcons;
+typedef vector<ExtraIcon*>::iterator IconIter;
+
+LIST<BaseExtraIcon> registeredExtraIcons(10);
vector<ExtraIcon*> extraIconsByHandle;
vector<ExtraIcon*> extraIconsBySlot;
@@ -59,6 +61,25 @@ 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 PreShutdown(WPARAM wParam, LPARAM lParam)
{
DefaultExtraIcons_Unload();
@@ -122,7 +143,7 @@ ExtraIcon* GetExtraIconBySlot(int slot) BaseExtraIcon* GetExtraIconByName(const char *name)
{
- for (unsigned int i = 0; i < registeredExtraIcons.size(); i++) {
+ for (int i=0; i < registeredExtraIcons.getCount(); i++) {
BaseExtraIcon *extra = registeredExtraIcons[i];
if (strcmp(name, extra->getName()) == 0)
return extra;
@@ -389,7 +410,7 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) return extra->getID();
}
- int id = (int)registeredExtraIcons.size() + 1;
+ int id = registeredExtraIcons.getCount() + 1;
switch (ei->type) {
case EXTRAICON_TYPE_CALLBACK:
@@ -414,7 +435,9 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) slot = -1;
extra->setSlot(slot);
- registeredExtraIcons.push_back(extra);
+ extra->hLangpack = (int)lParam;
+
+ registeredExtraIcons.insert(extra);
extraIconsByHandle.push_back(extra);
vector<ExtraIconGroup *> groups;
@@ -546,6 +569,8 @@ void LoadExtraIconsModule() void UnloadExtraIconsModule(void)
{
- for (size_t i=0; i < registeredExtraIcons.size(); i++)
+ for (int i=0; i < registeredExtraIcons.getCount(); i++)
delete registeredExtraIcons[i];
+
+ registeredExtraIcons.destroy();
}
|