diff options
author | George Hazan <george.hazan@gmail.com> | 2015-07-15 21:27:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-07-15 21:27:18 +0000 |
commit | 0d65ec3aab2c63b9a55fbabc811b0e23447fd4a1 (patch) | |
tree | 2536fcb552fcf4eb00fa2ae322d0a7fa6a547bcb | |
parent | 31591520f0dfefa04a9e4379f1a25be80298ea1e (diff) |
- fix for memory corruption;
- code cleaning;
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@14577 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/DbEditorPP/src/Version.h | 4 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/main.cpp | 14 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/main_window.cpp | 111 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/options.cpp | 6 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/stdafx.h | 6 |
5 files changed, 72 insertions, 69 deletions
diff --git a/plugins/DbEditorPP/src/Version.h b/plugins/DbEditorPP/src/Version.h index 1065e6fbb0..4a61fe7783 100644 --- a/plugins/DbEditorPP/src/Version.h +++ b/plugins/DbEditorPP/src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 4
#define __MINOR_VERSION 0
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 0
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index dbf1610cb6..8f6b19d14c 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -5,8 +5,8 @@ HINSTANCE hInst = NULL; MIDatabase *g_db;
HANDLE hTTBButt = NULL;
-BOOL bServiceMode = FALSE;
-BOOL usePopups;
+bool g_bServiceMode = false;
+bool g_bUsePopups;
int hLangpack;
BYTE nameOrder[NAMEORDERCOUNT];
@@ -63,11 +63,11 @@ int DBSettingChanged(WPARAM hContact, LPARAM lParam) settingChanged(hContact, cws->szModule, cws->szSetting, &(cws->value));
// watch list
- if (!hwnd2watchedVarsWindow && !usePopups)
+ if (!hwnd2watchedVarsWindow && !g_bUsePopups)
return 0;
if (WatchedArrayIndex(hContact, cws->szModule, cws->szSetting, 0) >= 0) {
- if (usePopups) popupWatchedVar(hContact, cws->szModule, cws->szSetting);
+ if (g_bUsePopups) popupWatchedVar(hContact, cws->szModule, cws->szSetting);
PopulateWatchedWindow();
}
@@ -138,7 +138,7 @@ int ModulesLoaded(WPARAM, LPARAM) hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_EXT, 'D');
Hotkey_Register(&hkd);
- usePopups = db_get_b(NULL, modname, "UsePopUps", 0);
+ g_bUsePopups = db_get_b(NULL, modname, "UsePopUps", 0) != 0;
// Load the name order
for (int i = 0; i < NAMEORDERCOUNT; i++)
@@ -152,7 +152,7 @@ int ModulesLoaded(WPARAM, LPARAM) HookEvent(ME_TTB_MODULELOADED, OnTTBLoaded);
- if (bServiceMode)
+ if (g_bServiceMode)
CallService("DBEditorpp/MenuCommand", 0, 0);
return 0;
}
@@ -167,7 +167,7 @@ int PreShutdown(WPARAM, LPARAM) INT_PTR ServiceMode(WPARAM, LPARAM)
{
IcoLibRegister();
- bServiceMode = TRUE;
+ g_bServiceMode = true;
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChanged);
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 12966c19c3..9200506b93 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -60,12 +60,12 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return HTCLIENT;
case WM_SETCURSOR:
- {
- RECT rc;
- GetClientRect(hwnd, &rc);
- SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE));
- }
- return TRUE;
+ {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE));
+ }
+ return TRUE;
case WM_LBUTTONDOWN:
SetCapture(hwnd);
@@ -91,18 +91,18 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR {
switch (msg) {
case WM_RBUTTONDOWN:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(hwnd, &hti.pt);
-
- if (TreeView_HitTest(hwnd, &hti)) {
- if (hti.flags&TVHT_ONITEM)
- TreeView_SelectItem(hwnd, hti.hItem);
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(hwnd, &hti.pt);
+
+ if (TreeView_HitTest(hwnd, &hti)) {
+ if (hti.flags&TVHT_ONITEM)
+ TreeView_SelectItem(hwnd, hti.hItem);
+ }
}
- }
- break;
+ break;
case WM_CHAR:
if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6)
@@ -122,7 +122,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR MCONTACT hContact = mtis->hContact;
if (wParam == VK_DELETE) {
if ((mtis->type) & MODULE) {
- if (deleteModule(hContact,_T2A(text), 1)) {
+ if (deleteModule(hContact, _T2A(text), 1)) {
mir_free(mtis);
TreeView_DeleteItem(hwnd, tvi.hItem);
}
@@ -172,20 +172,20 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wPar else if (wParam == VK_F3)
newFindWindow();
else
- if (wParam == VK_DELETE || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) {
-
- char setting[FLD_SIZE];
- int idx = ListView_GetSelectionMark(hwnd);
- if (idx == -1 ) return 0;
- ListView_GetItemTextA(hwnd, idx, 0, setting, _countof(setting));
+ if (wParam == VK_DELETE || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) {
- if (wParam == VK_F2)
- editSetting(info.hContact, info.module, setting);
- else if (wParam == VK_DELETE)
- DeleteSettingsFromList(info.hContact, info.module, setting);
+ char setting[FLD_SIZE];
+ int idx = ListView_GetSelectionMark(hwnd);
+ if (idx == -1) return 0;
+ ListView_GetItemTextA(hwnd, idx, 0, setting, _countof(setting));
- return 0;
- }
+ if (wParam == VK_F2)
+ editSetting(info.hContact, info.module, setting);
+ else if (wParam == VK_DELETE)
+ DeleteSettingsFromList(info.hContact, info.module, setting);
+
+ return 0;
+ }
break;
}
return mir_callNextSubclass(hwnd, SettingListSubclassProc, msg, wParam, lParam);
@@ -205,7 +205,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // image list
hImg = LoadIcons();
-
+
// do the icon
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)));
SetWindowText(hwnd, TranslateT("Database Editor++"));
@@ -218,10 +218,10 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // module tree
mir_subclassWindow(hwnd2Tree, ModuleTreeSubclassProc);
TreeView_SetImageList(hwnd2Tree, hImg, TVSIL_NORMAL);
-
+
//setting list
mir_subclassWindow(hwnd2List, SettingListSubclassProc);
- ListView_SetExtendedListViewStyle(hwnd2List, 32 | LVS_EX_SUBITEMIMAGES | LVS_EX_LABELTIP ); //LVS_EX_GRIDLINES
+ ListView_SetExtendedListViewStyle(hwnd2List, 32 | LVS_EX_SUBITEMIMAGES | LVS_EX_LABELTIP); //LVS_EX_GRIDLINES
loadListSettings(hwnd2List, csSettingList);
ListView_SetImageList(hwnd2List, hImg, LVSIL_SMALL);
@@ -232,10 +232,10 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) Utils_RestoreWindowPosition(hwnd, NULL, modname, "Main_");
if (db_get_b(NULL, modname, "Maximized", 0))
- ShowWindow(hwnd,SW_SHOWMAXIMIZED);
+ ShowWindow(hwnd, SW_SHOWMAXIMIZED);
g_Inline = !db_get_b(NULL, modname, "DontAllowInLineEdit", 1);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED: MF_UNCHECKED));
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
g_Mode = MODE_ALL;
CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_CHECKED);
@@ -304,7 +304,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_DESTROY: // free our shit!
if (db_get_b(NULL, modname, "RestoreOnOpen", 1)) {
HTREEITEM item;
-
+
if (item = TreeView_GetSelection(hwnd2Tree)) {
int type = MODULE;
TCHAR text[FLD_SIZE];
@@ -356,35 +356,37 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (wp.flags == WPF_RESTORETOMAXIMIZED) {
db_set_b(NULL, modname, "Maximized", 1);
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
- } else
- db_set_b(NULL, modname, "Maximized", 0);
+ }
+ else db_set_b(NULL, modname, "Maximized", 0);
+
Utils_SaveWindowPosition(hwnd, NULL, modname, "Main_");
ShowWindow(hwnd, SW_HIDE);
}
-
+
saveListSettings(hwnd2List, csSettingList);
ClearListView();
-
+
freeTree(0);
hwnd2mainWindow = NULL;
hwnd2Tree = NULL;
hwnd2List = NULL;
-
+
if (hImg) {
ImageList_Destroy(hImg);
hImg = NULL;
}
-
- FreeResidentSettings();
-
- if (bServiceMode)
+
+ FreeResidentSettings();
+
+ if (g_bServiceMode)
PostQuitMessage(0);
return 0;
case WM_COMMAND:
if (GetKeyState(VK_ESCAPE) & 0x8000)
return TRUE; // this needs to be changed to c if htere is a label edit happening..
+
switch (LOWORD(wParam)) {
case MENU_REFRESH_MODS:
refreshTree(1);
@@ -407,7 +409,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
break;
- ///////////////////////// // watches
+ ///////////////////////// // watches
case MENU_VIEW_WATCHES:
openWatchedVarWindow();
break;
@@ -490,15 +492,15 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
break;
case MENU_SAVE_POSITION:
- {
- BOOL save = !db_get_b(NULL, modname, "RestoreOnOpen", 1);
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED));
- db_set_b(NULL, modname, "RestoreOnOpen", (byte)save);
- }
- break;
+ {
+ BOOL save = !db_get_b(NULL, modname, "RestoreOnOpen", 1);
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED));
+ db_set_b(NULL, modname, "RestoreOnOpen", (byte)save);
+ }
+ break;
case MENU_INLINE_EDIT:
g_Inline = !g_Inline;
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED: MF_UNCHECKED));
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
case MENU_SORT_ORDER:
g_Order = !g_Order;
CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
@@ -541,6 +543,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
-void openMainWindow() {
+void openMainWindow()
+{
CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc);
}
diff --git a/plugins/DbEditorPP/src/options.cpp b/plugins/DbEditorPP/src/options.cpp index 3736751f94..8879d0f4a5 100644 --- a/plugins/DbEditorPP/src/options.cpp +++ b/plugins/DbEditorPP/src/options.cpp @@ -11,7 +11,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckDlgButton(hwnd, IDC_EXPANDSETTINGS, db_get_b(NULL, modname, "ExpandSettingsOnOpen", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_RESTORESETTINGS, db_get_b(NULL, modname, "RestoreOnOpen", 1) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_WARNONDEL, db_get_b(NULL, modname, "WarnOnDelete", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_POPUPS, usePopups ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_POPUPS, g_bUsePopups ? BST_CHECKED : BST_UNCHECKED);
SetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, db_get_w(NULL, modname, "PopupDelay", 4), 0);
SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)db_get_dw(NULL, modname, "PopupColour", RGB(255, 0, 0)));
TranslateDialogDefault(hwnd);
@@ -45,8 +45,8 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) db_set_b(NULL, modname, "ExpandSettingsOnOpen", (BYTE)IsDlgButtonChecked(hwnd, IDC_EXPANDSETTINGS));
db_set_b(NULL, modname, "RestoreOnOpen", (BYTE)IsDlgButtonChecked(hwnd, IDC_RESTORESETTINGS));
db_set_b(NULL, modname, "WarnOnDelete", (BYTE)IsDlgButtonChecked(hwnd, IDC_WARNONDEL));
- usePopups = IsDlgButtonChecked(hwnd, IDC_POPUPS);
- db_set_b(NULL, modname, "UsePopUps", (BYTE)usePopups);
+ g_bUsePopups = IsDlgButtonChecked(hwnd, IDC_POPUPS) != 0;
+ db_set_b(NULL, modname, "UsePopUps", (BYTE)g_bUsePopups);
db_set_w(NULL, modname, "PopupDelay", (WORD)GetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, NULL, 0));
db_set_dw(NULL, modname, "PopupColour", (DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0));
}
diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h index 8c5cf8eaa8..cc345714a5 100644 --- a/plugins/DbEditorPP/src/stdafx.h +++ b/plugins/DbEditorPP/src/stdafx.h @@ -182,10 +182,10 @@ extern MCONTACT hRestore; extern MIDatabase *g_db;
-extern BOOL bServiceMode;
-extern BOOL usePopups;
+extern bool g_bServiceMode;
+extern bool g_bUsePopups;
-#define NAMEORDERCOUNT 8
+#define NAMEORDERCOUNT 9
#define MODE_UNLOADED 1
#define MODE_LOADED 2
|