From 447334def7efa0eafe421cf12ad7490b35f775bc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 21 Feb 2022 20:08:19 +0300 Subject: fixes #3025 (occasional crash in AVS) --- plugins/AVS/src/main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins/AVS/src/main.cpp') 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; } -- cgit v1.2.3