diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2013-02-10 20:15:00 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2013-02-10 20:15:00 +0000 |
commit | 8b3120de336f515ffd715c7939b4dc63770c32bd (patch) | |
tree | e9d000a4755130f4dc738c6eea132e4603e19227 /plugins/ModernOpt | |
parent | 5feac927bfb6db11a138b6ce773b8704396c569c (diff) |
fixed crash on unloading plugin (fixes #47)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3543 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ModernOpt')
-rw-r--r-- | plugins/ModernOpt/src/main.cpp | 7 | ||||
-rw-r--r-- | plugins/ModernOpt/src/modernopt.cpp | 72 | ||||
-rw-r--r-- | plugins/ModernOpt/src/mopt_home.cpp | 2 | ||||
-rw-r--r-- | plugins/ModernOpt/src/mopt_ignore.cpp | 2 | ||||
-rw-r--r-- | plugins/ModernOpt/src/mopt_selector.cpp | 6 |
5 files changed, 43 insertions, 46 deletions
diff --git a/plugins/ModernOpt/src/main.cpp b/plugins/ModernOpt/src/main.cpp index 758c117e3d..4177a82724 100644 --- a/plugins/ModernOpt/src/main.cpp +++ b/plugins/ModernOpt/src/main.cpp @@ -26,7 +26,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) /////////////////////////////////////////////////////////////////////////////////////////
// MirandaPluginInfoEx - returns an information about a plugin
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
@@ -34,7 +34,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda /////////////////////////////////////////////////////////////////////////////////////////
// Performs a primary set of actions upon plugin loading
-int LoadModernOptsModule();
+void LoadModernOptsModule();
extern "C" int __declspec(dllexport) Load(void)
{
@@ -48,7 +48,10 @@ extern "C" int __declspec(dllexport) Load(void) /////////////////////////////////////////////////////////////////////////////////////////
// Unload a plugin
+void UnloadModernOptsModule();
+
extern "C" int __declspec(dllexport) Unload(void)
{
+ UnloadModernOptsModule();
return 0;
}
diff --git a/plugins/ModernOpt/src/modernopt.cpp b/plugins/ModernOpt/src/modernopt.cpp index af0dbc3898..b8a2937a43 100644 --- a/plugins/ModernOpt/src/modernopt.cpp +++ b/plugins/ModernOpt/src/modernopt.cpp @@ -63,12 +63,6 @@ struct ModernOptionsData : public MZeroedObject ////////////////////////////////////////////////////////////////////////////////
// Forwards
-static INT_PTR svcModernOpt_Show(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcModernOpt_Restore(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcModernOpt_SelectPage(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcModernOpt_AddObject(WPARAM wParam, LPARAM lParam);
-static int hookModernOpt_Initialize(WPARAM wParam, LPARAM lParam);
-
static void ModernOptUI_ShowPage(HWND hwndDlg, struct ModernOptionsData *dat, int iPage);
static void ModernOptUI_SelectSection(HWND hwndDlg, struct ModernOptionsData *dat, int iSection);
@@ -117,8 +111,8 @@ static void ModernOptionsObject_Dtor(void *ptr) static int ModernOptionsObject_Comparator(const ModernOptionsObject *ptr1, const ModernOptionsObject *ptr2)
{
-#define obj1 ((struct ModernOptionsObject *)ptr1)
-#define obj2 ((struct ModernOptionsObject *)ptr2)
+ struct ModernOptionsObject *obj1 = ((struct ModernOptionsObject *)ptr1);
+ struct ModernOptionsObject *obj2 = ((struct ModernOptionsObject *)ptr2);
if (obj1->optObject.iSection < obj2->optObject.iSection) return -1;
if (obj1->optObject.iSection > obj2->optObject.iSection) return +1;
@@ -135,31 +129,14 @@ static int ModernOptionsObject_Comparator(const ModernOptionsObject *ptr1, const if (obj1->dwIdx < obj2->dwIdx) return -1;
if (obj1->dwIdx > obj2->dwIdx) return +1;
return 0;
-
-#undef obj1
-#undef obj2
}
void li_List_Destruct(LIST<ModernOptionsObject> &pList, ItemDestuctor pItemDestructor)
{
- int i=0;
- for (i=0; i<pList.getCount(); i++) pItemDestructor(pList[i]);
+ for (int i=0; i<pList.getCount(); i++)
+ pItemDestructor(pList[i]);
pList.destroy();
}
-
-////////////////////////////////////////////////////////////////////////////////
-// Load module
-int LoadModernOptsModule()
-{
- CreateServiceFunction(MS_MODERNOPT_SHOW, svcModernOpt_Show);
- CreateServiceFunction(MS_MODERNOPT_RESTORE, svcModernOpt_Restore);
- CreateServiceFunction(MS_MODERNOPT_SELECTPAGE, svcModernOpt_SelectPage);
- CreateServiceFunction(MS_MODERNOPT_ADDOBJECT, svcModernOpt_AddObject);
- hevtModernOpt_Initialize = CreateHookableEvent(ME_MODERNOPT_INITIALIZE);
- HookEvent(ME_MODERNOPT_INITIALIZE, hookModernOpt_Initialize);
- return 0;
-}
-
////////////////////////////////////////////////////////////////////////////////
// Main dlgproc
static void sttNotifyPages(struct ModernOptionsData *dat, int code)
@@ -189,7 +166,6 @@ static INT_PTR CALLBACK ModernOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
- HIMAGELIST himl = 0;
dat = (struct ModernOptionsData *)lParam;
dat->iPage = -1;
@@ -201,7 +177,7 @@ static INT_PTR CALLBACK ModernOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, dat->hfntBold = CreateFontIndirect(&lf);
hwndCtrl = GetDlgItem(hwndDlg, IDC_TV_SUBSECTIONS);
- himl = ImageList_Create(16, 16, ILC_MASK + ( IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 ), 2, 1);
+ HIMAGELIST himl = ImageList_Create(16, 16, ILC_MASK + ( IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 ), 2, 1);
TreeView_SetImageList(hwndCtrl, himl, TVSIL_NORMAL);
for (i = 0; i < dat->pObjectList.getCount(); ++i) {
@@ -222,7 +198,6 @@ static INT_PTR CALLBACK ModernOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, }
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- hwndModernOpt = hwndDlg;
if (g_iSectionRestore)
CallService(MS_MODERNOPT_SELECTPAGE, g_iSectionRestore, 0);
@@ -257,7 +232,7 @@ static INT_PTR CALLBACK ModernOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, {
struct ModernOptionsObject *obj = (struct ModernOptionsObject *)dat->pObjectList[dat->iPage];
if (obj->optObject.lpzHelpUrl)
- ShellExecuteA(hwndDlg, "open", obj->optObject.lpzHelpUrl, "", "", SW_SHOW);
+ CallService(MS_UTILS_OPENURL,0,(LPARAM)obj->optObject.lpzHelpUrl);
}
break;
@@ -432,7 +407,6 @@ static void ModernOptUI_ShowPage(HWND hwndDlg, struct ModernOptionsData *dat, in static void ModernOptUI_SelectSection(HWND hwndDlg, struct ModernOptionsData *dat, int iSection)
{
- int i;
int iPageType = -1;
HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_SUBSECTIONS);
@@ -440,7 +414,7 @@ static void ModernOptUI_SelectSection(HWND hwndDlg, struct ModernOptionsData *da SendMessage(hwndTree, WM_SETREDRAW, FALSE, 0);
TreeView_DeleteAllItems(hwndTree);
- for (i = 0; i < dat->pObjectList.getCount(); ++i) {
+ for (int i = 0; i < dat->pObjectList.getCount(); ++i) {
struct ModernOptionsObject *obj = (struct ModernOptionsObject *)dat->pObjectList[i];
if (obj->optObject.iSection != iSection) continue;
@@ -510,14 +484,12 @@ static INT_PTR svcModernOpt_Restore(WPARAM wParam, LPARAM lParam) return svcModernOpt_Impl(wParam, lParam);
}
-static INT_PTR svcModernOpt_SelectPage(WPARAM wParam, LPARAM lParam)
+static INT_PTR svcModernOpt_SelectPage(WPARAM wParam, LPARAM)
{
- struct ModernOptionsData *dat;
-
if (!hwndModernOpt)
return 0;
- dat = (struct ModernOptionsData *)GetWindowLongPtr(hwndModernOpt, GWLP_USERDATA);
+ struct ModernOptionsData *dat = (struct ModernOptionsData *)GetWindowLongPtr(hwndModernOpt, GWLP_USERDATA);
if (!dat)
return 0;
@@ -602,7 +574,7 @@ static INT_PTR svcModernOpt_AddObject(WPARAM wParam, LPARAM lParam) return 0;
}
-static int hookModernOpt_Initialize(WPARAM wParam, LPARAM lParam)
+static int hookModernOpt_Initialize(WPARAM wParam, LPARAM)
{
static int iBoldControls[] =
{
@@ -700,3 +672,27 @@ static int hookModernOpt_Initialize(WPARAM wParam, LPARAM lParam) return 0;
}
+
+////////////////////////////////////////////////////////////////////////////////
+// Load module
+void LoadModernOptsModule()
+{
+ CreateServiceFunction(MS_MODERNOPT_SHOW, svcModernOpt_Show);
+ CreateServiceFunction(MS_MODERNOPT_RESTORE, svcModernOpt_Restore);
+ CreateServiceFunction(MS_MODERNOPT_SELECTPAGE, svcModernOpt_SelectPage);
+ CreateServiceFunction(MS_MODERNOPT_ADDOBJECT, svcModernOpt_AddObject);
+ hevtModernOpt_Initialize = CreateHookableEvent(ME_MODERNOPT_INITIALIZE);
+ HookEvent(ME_MODERNOPT_INITIALIZE, hookModernOpt_Initialize);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Unload module
+void UnloadModernOptsModule()
+{
+ if(hwndModernOpt)
+ {
+ DestroyWindow(hwndModernOpt);
+ hwndModernOpt = 0;
+ }
+}
+
diff --git a/plugins/ModernOpt/src/mopt_home.cpp b/plugins/ModernOpt/src/mopt_home.cpp index d76d03e7ca..0a74e0b4c5 100644 --- a/plugins/ModernOpt/src/mopt_home.cpp +++ b/plugins/ModernOpt/src/mopt_home.cpp @@ -53,7 +53,7 @@ INT_PTR CALLBACK ModernOptHome_DlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_COMMAND:
switch ( LOWORD(wParam)) {
case IDC_BTN_HELP:
- ShellExecuteA(hwndDlg, "open", "http://miranda-ng.org/", "", "", SW_SHOW);
+ CallService(MS_UTILS_OPENURL,OUF_TCHAR,(LPARAM)_T("http://miranda-ng.org/"));
break;
default:
diff --git a/plugins/ModernOpt/src/mopt_ignore.cpp b/plugins/ModernOpt/src/mopt_ignore.cpp index 1d2ed1a202..9c0e429cae 100644 --- a/plugins/ModernOpt/src/mopt_ignore.cpp +++ b/plugins/ModernOpt/src/mopt_ignore.cpp @@ -54,7 +54,7 @@ static void SetAllContactIcons(HWND hwndList, int count) DWORD hItem = SendMessage(hwndList,CLM_FINDCONTACT,(WPARAM)hContact,0);
for (int i = 0; i < count; ++i)
SendMessage(hwndList,CLM_SETEXTRAIMAGE,hItem,MAKELPARAM(i, i+1));
- if (!DBGetContactSettingByte(hContact,"CList","Hidden",0))
+ if (!db_get_b(hContact,"CList","Hidden",0))
SendMessage(hwndList,CLM_SETCHECKMARK,hItem,1);
}
while(hContact=db_find_next(hContact));
diff --git a/plugins/ModernOpt/src/mopt_selector.cpp b/plugins/ModernOpt/src/mopt_selector.cpp index 42b15f51bb..563a6779ef 100644 --- a/plugins/ModernOpt/src/mopt_selector.cpp +++ b/plugins/ModernOpt/src/mopt_selector.cpp @@ -183,9 +183,6 @@ static void CreatePreview(TSelectorData *sd, TCHAR *fn, LPDRAWITEMSTRUCT lps) sd->hbmpPreview = CreateCompatibleBitmap(lps->hDC, lps->rcItem.right - lps->rcItem.left, lps->rcItem.bottom - lps->rcItem.top);
SelectObject(hdc, sd->hbmpPreview);
- RECT rc;
- HBRUSH hbr;
-
BITMAPINFO bi = {0};
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biWidth = 8;
@@ -197,7 +194,8 @@ static void CreatePreview(TSelectorData *sd, TCHAR *fn, LPDRAWITEMSTRUCT lps) HBITMAP hBmpBrush = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, 0, 0, 0);
HDC dcBmp = CreateCompatibleDC(0);
HBITMAP hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmpBrush);
- hbr = CreateSolidBrush(RGB(0xcc, 0xcc, 0xcc));
+ HBRUSH hbr = CreateSolidBrush(RGB(0xcc, 0xcc, 0xcc));
+ RECT rc;
SetRect(&rc, 0, 0, 8, 8);
FillRect(dcBmp, &rc, hbr);
DeleteObject(hbr);
|