summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2012-12-31 12:32:14 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2012-12-31 12:32:14 +0000
commit6410348ada83ca5fea19f706506ae4afaf8f4a89 (patch)
tree6e8403e314f144504829fb713fbd2673af441ded
parentd73a62b9e037711e47d0ab78df1459de97b7bdc3 (diff)
-Try to fix a crash (fixes #169)
-Translation fix git-svn-id: http://svn.miranda-ng.org/main/trunk@2894 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Ping/src/options.cpp120
-rw-r--r--plugins/Ping/src/pingthread.cpp2
2 files changed, 66 insertions, 56 deletions
diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp
index 1d19a67ded..04fedfbd23 100644
--- a/plugins/Ping/src/options.cpp
+++ b/plugins/Ping/src/options.cpp
@@ -300,10 +300,13 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
}
BOOL Edit(HWND hwnd, PINGADDRESS &addr) {
- add_edit_addr = addr;
- if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK) {
- addr = add_edit_addr;
- return TRUE;
+ if(&addr != NULL)
+ {
+ add_edit_addr = addr;
+ if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK) {
+ addr = add_edit_addr;
+ return TRUE;
+ }
}
return FALSE;
}
@@ -361,7 +364,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
PINGADDRESS temp = *item;
if(Edit(hwndDlg, temp)) {
*item = temp;
- SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, (LPARAM)0);
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0);
SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)item->pszLabel);
SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel, (LPARAM)item);
SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0);
@@ -443,31 +446,34 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if(sel2 != LB_ERR) {
PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2, 0),
*item2 = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2 + 1, 0);
- add_edit_addr = *item;
- *item = *item2;
- *item2 = add_edit_addr;
-
- // keep indexes the same, as they're used for sorting the binary tree
- int index = item->index, index2 = item2->index;
- item->index = index2;
- item2->index = index;
-
- SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0);
- SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
- SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
- SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0);
- SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)item2->pszLabel);
- SendMessage(hw, LB_SETITEMDATA, (WPARAM)(sel2 + 1), (LPARAM)item2);
- SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0);
-
- hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP);
- EnableWindow(hw, (sel2 + 1 > 0));
- hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
- int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
- hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
- EnableWindow(hw, (sel2 + 1 < count - 1));
-
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ if(item && item2)
+ {
+ add_edit_addr = *item;
+ *item = *item2;
+ *item2 = add_edit_addr;
+
+ // keep indexes the same, as they're used for sorting the binary tree
+ int index = item->index, index2 = item2->index;
+ item->index = index2;
+ item2->index = index;
+
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)item2->pszLabel);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)(sel2 + 1), (LPARAM)item2);
+ SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0);
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP);
+ EnableWindow(hw, (sel2 + 1 > 0));
+ hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
+ int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
+ EnableWindow(hw, (sel2 + 1 < count - 1));
+
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
}
}
break;
@@ -478,33 +484,37 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if(sel2 != LB_ERR) {
PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2, 0),
*item2 = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2 - 1, 0);
- add_edit_addr = *item;
- *item = *item2;
- *item2 = add_edit_addr;
- // keep indexes the same, as they're used for sorting the binary tree
- int index = item->index, index2 = item2->index;
- item->index = index2;
- item2->index = index;
-
- SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0);
- SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
- SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
-
- SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0);
- SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)item2->pszLabel);
- SendMessage(hw, LB_SETITEMDATA, (WPARAM)(sel2 - 1), (LPARAM)item2);
-
- SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0);
-
- hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP);
- EnableWindow(hw, (sel2 - 1 > 0));
- hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
- int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
- hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
- EnableWindow(hw, (sel2 - 1 < count - 1));
+ if (item && item2)
+ {
+ add_edit_addr = *item;
+ *item = *item2;
+ *item2 = add_edit_addr;
+
+ // keep indexes the same, as they're used for sorting the binary tree
+ int index = item->index, index2 = item2->index;
+ item->index = index2;
+ item2->index = index;
+
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item);
+
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)item2->pszLabel);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)(sel2 - 1), (LPARAM)item2);
+
+ SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0);
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP);
+ EnableWindow(hw, (sel2 - 1 > 0));
+ hw = GetDlgItem(hwndDlg, IDC_LST_DEST);
+ int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN);
+ EnableWindow(hw, (sel2 - 1 < count - 1));
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
}
}
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index b8c0822bf4..538cb9e5cb 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -489,7 +489,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_GRAYED);
}
- CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0);
+ TranslateMenu(submenu);
//ClientToScreen(list_hwnd, &pt);
GetCursorPos(&pt);