summaryrefslogtreecommitdiff
path: root/plugins/AVS/src/main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-02-21 20:08:19 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-02-21 20:08:19 +0300
commit447334def7efa0eafe421cf12ad7490b35f775bc (patch)
treedee845b4d4812970b9d0105cd1f299f992ad0d3a /plugins/AVS/src/main.cpp
parentb107dc2d3a5b7119aedbb3a28bb6c7d3ea177bf8 (diff)
fixes #3025 (occasional crash in AVS)
Diffstat (limited to 'plugins/AVS/src/main.cpp')
-rw-r--r--plugins/AVS/src/main.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp
index 489a830901..9fd4421229 100644
--- a/plugins/AVS/src/main.cpp
+++ b/plugins/AVS/src/main.cpp
@@ -35,7 +35,7 @@ HWND hwndSetMyAvatar = nullptr;
HANDLE hMyAvatarsFolder;
HANDLE hGlobalAvatarFolder;
-HANDLE hLoaderEvent, hShutdownEvent;
+HANDLE hLoaderEvent, hLoaderThread, hShutdownEvent;
HANDLE hEventChanged, hEventContactAvatarChanged, hMyAvatarChanged;
char *g_szMetaName = nullptr;
@@ -209,7 +209,6 @@ static int ShutdownProc(WPARAM, LPARAM)
g_shutDown = true;
SetEvent(hLoaderEvent);
SetEvent(hShutdownEvent);
- CloseHandle(hShutdownEvent); hShutdownEvent = nullptr;
return 0;
}
@@ -376,6 +375,8 @@ int CMPlugin::Load()
int CMPlugin::Unload()
{
+ UnregisterClassW(AVATAR_CONTROL_CLASS, 0);
+
UninitPolls();
UnloadCache();
@@ -383,7 +384,10 @@ int CMPlugin::Unload()
DestroyHookableEvent(hEventContactAvatarChanged);
DestroyHookableEvent(hMyAvatarChanged);
+ if (hLoaderThread)
+ WaitForSingleObject(hLoaderThread, INFINITE);
+
CloseHandle(hLoaderEvent);
- UnregisterClassW(AVATAR_CONTROL_CLASS, 0);
+ CloseHandle(hShutdownEvent);
return 0;
}