From 2bc82e6bbe6141a102c20cd65bfcfb11ea80f303 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 15 Mar 2014 11:51:03 +0000 Subject: crash fix git-svn-id: http://svn.miranda-ng.org/main/trunk@8621 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/protocols/protoaccs.cpp | 14 ++++++++++---- src/modules/protocols/protocols.cpp | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp index 183e72b0f8..9fd416ad78 100644 --- a/src/modules/protocols/protoaccs.cpp +++ b/src/modules/protocols/protoaccs.cpp @@ -32,6 +32,7 @@ void BuildProtoMenus(); HICON Proto_GetIcon(PROTO_INTERFACE *ppro, int iconIndex); static BOOL bModuleInitialized = FALSE; +static HANDLE hHooks[4]; static int CompareAccounts(const PROTOACCOUNT* p1, const PROTOACCOUNT* p2) { @@ -199,6 +200,7 @@ void WriteDbAccounts() } ///////////////////////////////////////////////////////////////////////////////////////// + static int OnContactDeleted(WPARAM hContact, LPARAM lParam) { if (hContact) { @@ -275,10 +277,10 @@ int LoadAccountsModule(void) pa->bDynDisabled = TRUE; } - HookEvent(ME_SYSTEM_MODULESLOADED, InitializeStaticAccounts); - HookEvent(ME_SYSTEM_PRESHUTDOWN, UninitializeStaticAccounts); - HookEvent(ME_DB_CONTACT_DELETED, OnContactDeleted); - HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnDbSettingsChanged); + hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, InitializeStaticAccounts); + hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, UninitializeStaticAccounts); + hHooks[2] = HookEvent(ME_DB_CONTACT_DELETED, OnContactDeleted); + hHooks[3] = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnDbSettingsChanged); return 0; } @@ -582,6 +584,10 @@ void UnloadAccountsModule() UnloadAccount(pa, false, false); accounts.remove(i); } + accounts.destroy(); + + for (int i = 0; i < SIZEOF(hHooks); i++) + UnhookEvent(hHooks[i]); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index ed56413f0a..6d57eb10e9 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -704,10 +704,12 @@ void UnloadProtocolsModule() mir_free(protos[i]->szName); mir_free(protos[i]); } + protos.destroy(); } for (int i=0; i < serviceItems.getCount(); i++) mir_free(serviceItems[i]); + serviceItems.destroy(); } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3