From 123dcff490b3acaf2ce1bab93c08ccdaea43775a Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Sun, 6 Sep 2009 23:29:03 +0000 Subject: Fixed crash on popup dismiss git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@470 4f64403b-2f21-0410-a795-97e2b3489a10 --- yapp/message_pump.cpp | 3 +++ yapp/message_pump.h | 1 + yapp/notify_imp.cpp | 9 +++++++++ yapp/popups2.cpp | 6 ------ yapp/popwin.cpp | 5 ----- yapp/popwin.h | 3 ++- 6 files changed, 15 insertions(+), 12 deletions(-) (limited to 'yapp') diff --git a/yapp/message_pump.cpp b/yapp/message_pump.cpp index 426d0ab..a03dae3 100644 --- a/yapp/message_pump.cpp +++ b/yapp/message_pump.cpp @@ -125,6 +125,9 @@ DWORD CALLBACK MessagePumpThread(LPVOID param) { BroadcastMessage(PUM_KILLNOTIFY, (WPARAM)hNotify, 0); } break; + case MUM_NMAVATAR: + RepositionWindows(); + break; default: { TranslateMessage(&hwndMsg); diff --git a/yapp/message_pump.h b/yapp/message_pump.h index 487c17e..52f7970 100644 --- a/yapp/message_pump.h +++ b/yapp/message_pump.h @@ -9,6 +9,7 @@ void PostMPMessage(UINT msg, WPARAM, LPARAM); #define MUM_NMUPDATE (WM_USER + 0x013) #define MUM_NMREMOVE (WM_USER + 0x014) +#define MUM_NMAVATAR (WM_USER + 0x015) // given a popup data pointer, and a handle to an event, this function // will post a message to the message queue which will set the hwnd value diff --git a/yapp/notify_imp.cpp b/yapp/notify_imp.cpp index 9dc0b2e..89fde14 100644 --- a/yapp/notify_imp.cpp +++ b/yapp/notify_imp.cpp @@ -30,6 +30,12 @@ int Popup2Update(WPARAM wParam, LPARAM lParam) { return 0; } +int AvatarChanged(WPARAM wParam, LPARAM lParam) { + PostMPMessage(MUM_NMAVATAR, (WPARAM)0, (LPARAM)0); + return 0; +} + + INT_PTR svcPopup2Update(WPARAM wParam, LPARAM lParam) { return Popup2Update(wParam, lParam); } @@ -102,10 +108,12 @@ int NotifyOptionsInitialize(WPARAM wParam,LPARAM lParam) } HANDLE hEventNotifyOptInit, hEventNotifyModulesLoaded; +HANDLE hAvChangeEvent; int NotifyModulesLoaded(WPARAM wParam,LPARAM lParam) { hEventNotifyOptInit = HookEvent(ME_NOTIFY_OPT_INITIALISE, NotifyOptionsInitialize); + hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); return 0; } @@ -129,6 +137,7 @@ void DeinitNotify() { UnhookEvent(hhkUpdate); UnhookEvent(hhkRemove); + UnhookEvent(hAvChangeEvent); UnhookEvent(hEventNotifyOptInit); UnhookEvent(hEventNotifyModulesLoaded); diff --git a/yapp/popups2.cpp b/yapp/popups2.cpp index 134e648..a800af7 100644 --- a/yapp/popups2.cpp +++ b/yapp/popups2.cpp @@ -30,9 +30,6 @@ HFONT hFontFirstLine = 0, hFontSecondLine = 0, hFontTime = 0; COLORREF colFirstLine = RGB(255, 0, 0), colSecondLine = 0, colTime = RGB(0, 0, 255), colBorder = RGB(0, 0, 0), colSidebar = RGB(128, 128, 128), colTitleUnderline = GetSysColor(COLOR_3DSHADOW); -// hooked here so it's in the main thread -HANDLE hAvChangeEvent = 0; - PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -309,8 +306,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { hFontTime = CreateFontIndirect(&lf); } - hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); - LoadModuleDependentOptions(); if(GetModuleHandle(_T("neweventnotify"))) @@ -322,7 +317,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { } int PreShutdown(WPARAM wParam, LPARAM lParam) { - if(hAvChangeEvent) UnhookEvent(hAvChangeEvent); DeinitMessagePump(); DeinitNotify(); return 0; diff --git a/yapp/popwin.cpp b/yapp/popwin.cpp index 8ef25fd..64496c8 100644 --- a/yapp/popwin.cpp +++ b/yapp/popwin.cpp @@ -740,11 +740,6 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa } } -int AvatarChanged(WPARAM wParam, LPARAM lParam) { - RepositionWindows(); - return 0; -} - void InitWindowStack() { hUserDll = LoadLibrary(_T("user32.dll")); if (hUserDll) { diff --git a/yapp/popwin.h b/yapp/popwin.h index d532108..63038c4 100644 --- a/yapp/popwin.h +++ b/yapp/popwin.h @@ -19,7 +19,8 @@ void InitWindowStack(); void DeinitWindowStack(); void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam); -int AvatarChanged(WPARAM wParam, LPARAM lParam); // exposed so hook/unhook is in main thread + +void RepositionWindows(); LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -- cgit v1.2.3