diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-23 21:53:44 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-23 21:53:44 +0000 |
commit | 10fa9a24ced9d0a37722c53846c1a0bd94047412 (patch) | |
tree | 448093c2b54b1056054c7e8da626a573b45c1430 | |
parent | 34930aff095fe54011f9a42b47b1ad61145d48b9 (diff) |
- fix for LIST<T>.ListCopy()
- minor fix for TTB options
git-svn-id: http://svn.miranda-ng.org/main/trunk@593 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_system_cpp.h | 22 | ||||
-rw-r--r-- | plugins/TopToolBar/toolbar.cpp | 3 | ||||
-rw-r--r-- | plugins/TopToolBar/ttbopt.cpp | 51 | ||||
-rw-r--r-- | src/modules/database/dblists.cpp | 14 |
4 files changed, 37 insertions, 53 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 33f4640579..a04898e427 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -54,16 +54,6 @@ template<class T> struct LIST sortFunc = FTSortFunc(id);
}
- __inline LIST& operator=(const LIST& x)
- { destroy();
- #if defined(_STATIC)
- List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #else
- li.List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #endif
- return *this;
- }
-
__inline T* operator[](int idx) const { return (idx >= 0 && idx < count) ? items[idx] : NULL; }
__inline int getCount(void) const { return count; }
__inline T** getArray(void) const { return items; }
@@ -74,6 +64,12 @@ template<class T> struct LIST List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
}
+ __inline LIST& operator=(const LIST& x)
+ { destroy();
+ List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
+ return *this;
+ }
+
__inline int getIndex(T* p) const
{ int idx;
return ( !List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
@@ -94,6 +90,12 @@ template<class T> struct LIST li.List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
}
+ __inline LIST& operator=(const LIST& x)
+ { destroy();
+ li.List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
+ return *this;
+ }
+
__inline int getIndex(T* p) const
{ int idx;
return ( !li.List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index 5999e34ca3..e23da5649b 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -891,9 +891,6 @@ int UnloadToolbarModule() DeleteObject(hBmpSeparator);
DeleteCriticalSection(&csButtonsHook);
- arServices.destroy();
- arHooks.destroy();
-
for (int i=0; i < Buttons.getCount(); i++)
delete Buttons[i];
Buttons.destroy();
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp index 95619172fe..8ff338bc28 100644 --- a/plugins/TopToolBar/ttbopt.cpp +++ b/plugins/TopToolBar/ttbopt.cpp @@ -85,9 +85,7 @@ int SaveTree(HWND hwndDlg) TVITEM tvi = { 0 };
tvi.hItem = TreeView_GetRoot(hTree);
- int count = 0;
-
- LIST<TopButtonInt> LocalButtons(TreeView_GetCount(hTree));
+ LIST<TopButtonInt> tmpList(8);
while(tvi.hItem != NULL) {
tvi.stateMask = TVIS_STATEIMAGEMASK;
@@ -95,34 +93,25 @@ int SaveTree(HWND hwndDlg) TreeView_GetItem(hTree, &tvi);
TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
-
-// Buttons.remove(btn);
- int idx = Buttons.indexOf(btn);
- if (idx != -1)
- Buttons.remove(idx);
+ Buttons.remove(btn);
if (TreeView_GetCheckState(hTree,tvi.hItem))
btn->dwFlags |= TTBBF_VISIBLE;
else
btn->dwFlags &= ~TTBBF_VISIBLE;
+ btn->dwFlags &= ~TTBBF_OPTIONAL;
+ btn->arrangedpos = tmpList.getCount();
- btn->dwFlags &=~TTBBF_OPTIONAL;
-
- btn->arrangedpos = count;
-
- LocalButtons.insert(btn);
+ tmpList.insert(btn);
tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
- count++;
}
lockbut();
- for (int i=0;i<Buttons.getCount();i++)
+ for (int i=0; i < Buttons.getCount(); i++)
delete Buttons[i];
- Buttons.destroy();
-
- Buttons = LocalButtons;
-// LocalButtons.destroy();
+ Buttons = tmpList;
+ tmpList.destroy();
ulockbut();
SaveAllButtonsOptions();
@@ -213,20 +202,20 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // probably, condition not needs
if (btn->dwFlags & TTBBF_ISLBUTTON) {
if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
- // create button
+ // create button
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = NULL;
ttb.program = NULL;
- btn = CreateButton(&ttb);
+ btn = CreateButton(&ttb);
tvi.lParam = (LPARAM)btn;
TreeView_SetItem(hTree, &tvi);
}
- if (btn->name) free(btn->name);
+ if (btn->name) free(btn->name);
GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255);
btn->name = _strdup( _T2A(buf));
@@ -235,21 +224,21 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR btn->program = _tcsdup(buf);
tvi.mask = TVIF_TEXT;
- tvi.pszText = mir_a2t( btn->name );
+ tvi.pszText = mir_a2t( btn->name );
TreeView_SetItem(hTree, &tvi);
}
break;
}
if (ctrlid == IDC_ADDLBUTTON) {
- // create button
+ // create button
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = LPGEN("Default");
ttb.program = _T("Execute Path");
- TopButtonInt* b = CreateButton(&ttb);
+ TopButtonInt* b = CreateButton(&ttb);
// get selection for insert
TVITEM tvi = {0};
@@ -265,11 +254,11 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR //----- Separators -----
if (ctrlid == IDC_ADDSEP) {
- // create button
+ // create button
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL;
- TopButtonInt* b = CreateButton(&ttb);
+ TopButtonInt* b = CreateButton(&ttb);
// get selection for insert
TVITEM tvi = {0};
@@ -295,9 +284,9 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // if button enabled for separator and launch only, no need condition
// except possible service button introducing
if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) {
- // delete if was added in options
- if (btn->dwFlags & TTBBF_OPTIONAL)
- delete btn;
+ // delete if was added in options
+ if (btn->dwFlags & TTBBF_OPTIONAL)
+ delete btn;
TreeView_DeleteItem(hTree,tvi.hItem);
@@ -313,7 +302,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- BUTTHEIGHT = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE);
+ BUTTHEIGHT = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE);
BUTTWIDTH = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE);
BUTTGAP = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE);
DBWriteContactSettingByte(0, TTB_OPTDIR, "BUTTHEIGHT", BUTTHEIGHT);
diff --git a/src/modules/database/dblists.cpp b/src/modules/database/dblists.cpp index 1dd802c196..bd1d352641 100644 --- a/src/modules/database/dblists.cpp +++ b/src/modules/database/dblists.cpp @@ -257,16 +257,12 @@ int List_RemovePtr(SortedList* list, void* p) void List_Copy(SortedList* s, SortedList* d, size_t itemSize)
{
- int i;
-
d->increment = s->increment;
- d->sortFunc = s->sortFunc;
-
- for (i = 0; i < s->realCount; i++) {
- void* item = mir_alloc(itemSize);
- memcpy(item, s->items[i], itemSize);
- List_Insert(d, item, i);
-} }
+ d->limit = s->limit;
+ d->realCount = s->realCount;
+ d->items = (void**)mir_alloc( sizeof(void*) * d->realCount);
+ memcpy(d->items, s->items, sizeof(void*) * d->realCount);
+}
void List_ObjCopy(SortedList* s, SortedList* d, size_t itemSize)
{
|