diff options
author | George Hazan <ghazan@miranda.im> | 2020-06-10 20:46:19 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-06-10 20:46:19 +0300 |
commit | e9167fdb38669870baf1a5f4255f0b0a043fa267 (patch) | |
tree | 6058256a5a9c2b06974d6612efd8068057b5c399 /plugins | |
parent | f435c6b618bfded57d65bb46aa91d94f2cf404dd (diff) |
New_GPG: more accurate version of RemoveHandlers()
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/New_GPG/src/init.cpp | 11 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 6 |
2 files changed, 12 insertions, 5 deletions
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index b2450f06dc..e327931e26 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -31,6 +31,7 @@ int onIconPressed(WPARAM, LPARAM); void InitCheck(); void FirstRun(); +void RemoveHandlers(); // global variables CMPlugin g_plugin; @@ -124,6 +125,12 @@ static int OnModulesLoaded(WPARAM, LPARAM) return 0; } +static int OnShutdown(WPARAM, LPARAM) +{ + RemoveHandlers(); + return 0; +} + int CMPlugin::Load() { HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); @@ -131,6 +138,7 @@ int CMPlugin::Load() HookEvent(ME_OPT_INITIALISE, GpgOptInit); HookEvent(ME_PROTO_ACK, onProtoAck); HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown); InitIconLib(); init_vars(); @@ -191,12 +199,9 @@ int CMPlugin::Load() ///////////////////////////////////////////////////////////////////////////////////////// -void RemoveHandlers(); extern list<wstring> transfers; int CMPlugin::Unload() { - RemoveHandlers(); - for (auto p : transfers) if (!p.empty()) boost::filesystem::remove(p); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index e89d01eff1..168c66931d 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -784,8 +784,10 @@ void RemoveHandlers() if (pApi == nullptr) continue; - pApi->RemoveHandler(it->getMessageHandler()); - pApi->RemoveHandler(it->getPresenceHandler()); + if (it->getMessageHandler() != INVALID_HANDLE_VALUE) + pApi->RemoveHandler(it->getMessageHandler()); + if (it->getPresenceHandler() != INVALID_HANDLE_VALUE) + pApi->RemoveHandler(it->getPresenceHandler()); pApi->RemoveFeatures("GPG_Encrypted_FileTransfers:0\0\0"); pApi->RemoveFeatures("GPG_Key_Auto_Exchange:0\0\0"); } |