From a1b54aadf426b4ce2ce3c900a889f53f1eec6bce Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Jun 2012 15:05:21 +0000 Subject: patch for crash on exit git-svn-id: http://svn.miranda-ng.org/main/trunk@668 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x/dbevents.cpp | 64 +++++++++++++++++++-------------------------- plugins/Db3x/dbsettings.cpp | 11 +++++++- 2 files changed, 37 insertions(+), 38 deletions(-) (limited to 'plugins/Db3x') diff --git a/plugins/Db3x/dbevents.cpp b/plugins/Db3x/dbevents.cpp index 10d04c180e..be50babe57 100644 --- a/plugins/Db3x/dbevents.cpp +++ b/plugins/Db3x/dbevents.cpp @@ -26,45 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. DWORD GetModuleNameOfs(const char *szName); char *GetModuleNameByOfs(DWORD ofs); -static INT_PTR GetEventCount(WPARAM wParam,LPARAM lParam); -static INT_PTR AddEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR DeleteEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR GetBlobSize(WPARAM wParam,LPARAM lParam); -static INT_PTR GetEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR MarkEventRead(WPARAM wParam,LPARAM lParam); -static INT_PTR GetEventContact(WPARAM wParam,LPARAM lParam); -static INT_PTR FindFirstEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR FindFirstUnreadEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR FindLastEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR FindNextEvent(WPARAM wParam,LPARAM lParam); -static INT_PTR FindPrevEvent(WPARAM wParam,LPARAM lParam); - static HANDLE hEventDeletedEvent,hEventAddedEvent,hEventFilterAddedEvent; -int InitEvents(void) -{ - CreateServiceFunction(MS_DB_EVENT_GETCOUNT,GetEventCount); - CreateServiceFunction(MS_DB_EVENT_ADD,AddEvent); - CreateServiceFunction(MS_DB_EVENT_DELETE,DeleteEvent); - CreateServiceFunction(MS_DB_EVENT_GETBLOBSIZE,GetBlobSize); - CreateServiceFunction(MS_DB_EVENT_GET,GetEvent); - CreateServiceFunction(MS_DB_EVENT_MARKREAD,MarkEventRead); - CreateServiceFunction(MS_DB_EVENT_GETCONTACT,GetEventContact); - CreateServiceFunction(MS_DB_EVENT_FINDFIRST,FindFirstEvent); - CreateServiceFunction(MS_DB_EVENT_FINDFIRSTUNREAD,FindFirstUnreadEvent); - CreateServiceFunction(MS_DB_EVENT_FINDLAST,FindLastEvent); - CreateServiceFunction(MS_DB_EVENT_FINDNEXT,FindNextEvent); - CreateServiceFunction(MS_DB_EVENT_FINDPREV,FindPrevEvent); - hEventDeletedEvent=CreateHookableEvent(ME_DB_EVENT_DELETED); - hEventAddedEvent=CreateHookableEvent(ME_DB_EVENT_ADDED); - hEventFilterAddedEvent=CreateHookableEvent(ME_DB_EVENT_FILTER_ADD); - return 0; -} - -void UninitEvents(void) -{ -} - static INT_PTR GetEventCount(WPARAM wParam,LPARAM lParam) { INT_PTR ret; @@ -433,3 +396,30 @@ static INT_PTR FindPrevEvent(WPARAM wParam,LPARAM lParam) LeaveCriticalSection(&csDbAccess); return ret; } + +int InitEvents(void) +{ + CreateServiceFunction(MS_DB_EVENT_GETCOUNT,GetEventCount); + CreateServiceFunction(MS_DB_EVENT_ADD,AddEvent); + CreateServiceFunction(MS_DB_EVENT_DELETE,DeleteEvent); + CreateServiceFunction(MS_DB_EVENT_GETBLOBSIZE,GetBlobSize); + CreateServiceFunction(MS_DB_EVENT_GET,GetEvent); + CreateServiceFunction(MS_DB_EVENT_MARKREAD,MarkEventRead); + CreateServiceFunction(MS_DB_EVENT_GETCONTACT,GetEventContact); + CreateServiceFunction(MS_DB_EVENT_FINDFIRST,FindFirstEvent); + CreateServiceFunction(MS_DB_EVENT_FINDFIRSTUNREAD,FindFirstUnreadEvent); + CreateServiceFunction(MS_DB_EVENT_FINDLAST,FindLastEvent); + CreateServiceFunction(MS_DB_EVENT_FINDNEXT,FindNextEvent); + CreateServiceFunction(MS_DB_EVENT_FINDPREV,FindPrevEvent); + hEventDeletedEvent=CreateHookableEvent(ME_DB_EVENT_DELETED); + hEventAddedEvent=CreateHookableEvent(ME_DB_EVENT_ADDED); + hEventFilterAddedEvent=CreateHookableEvent(ME_DB_EVENT_FILTER_ADD); + return 0; +} + +void UninitEvents(void) +{ + DestroyHookableEvent(hEventAddedEvent); hEventAddedEvent = 0; + DestroyHookableEvent(hEventDeletedEvent); hEventDeletedEvent = 0; + DestroyHookableEvent(hEventFilterAddedEvent); hEventFilterAddedEvent = 0; +} diff --git a/plugins/Db3x/dbsettings.cpp b/plugins/Db3x/dbsettings.cpp index ad7e470650..c8eb18c208 100644 --- a/plugins/Db3x/dbsettings.cpp +++ b/plugins/Db3x/dbsettings.cpp @@ -941,6 +941,13 @@ static int stringCompare2( DBCachedGlobalValue* p1, DBCachedGlobalValue* p2 ) return strcmp( p1->name, p2->name ); } +static int OnPreShutdown(WPARAM, LPARAM) +{ + DestroyHookableEvent(hSettingChangeEvent); + hSettingChangeEvent = 0; + return 0; +} + int InitSettings(void) { CreateServiceFunction(MS_DB_CONTACT_GETSETTING,GetContactSetting); @@ -951,7 +958,9 @@ int InitSettings(void) CreateServiceFunction(MS_DB_CONTACT_DELETESETTING,DeleteContactSetting); CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS,EnumContactSettings); CreateServiceFunction(MS_DB_SETSETTINGRESIDENT,SetSettingResident); - hSettingChangeEvent=CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED); + + hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED); + HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); mirCp = CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 ); -- cgit v1.2.3