diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-19 18:42:19 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-19 18:42:19 +0000 |
commit | 3d3a8bb209b190732f8530f3dc5b2baa46d3078e (patch) | |
tree | 28afcae563cff29fdd686e1a4874bda0f6aee801 /plugins/Clist_modern/src/modern_clcidents.cpp | |
parent | d67f238b33aa9fae3e877dc579ac9260323219fe (diff) |
fix against recursions in clists
git-svn-id: http://svn.miranda-ng.org/main/trunk@8664 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src/modern_clcidents.cpp')
-rw-r--r-- | plugins/Clist_modern/src/modern_clcidents.cpp | 133 |
1 files changed, 57 insertions, 76 deletions
diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp index e59870b5f3..85d3e3e969 100644 --- a/plugins/Clist_modern/src/modern_clcidents.cpp +++ b/plugins/Clist_modern/src/modern_clcidents.cpp @@ -113,10 +113,8 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro {
int index = 0, i;
int nowVisible = 1;
- ClcGroup *group;
-
- group = &dat->list;
+ ClcGroup *group = &dat->list;
group->scanIndex = 0;
group = &dat->list;
@@ -124,12 +122,12 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro if (group->scanIndex == group->cl.count) {
ClcGroup *tgroup;
group = group->parent;
- if (group == NULL) break;
+ if (group == NULL)
+ break;
+
nowVisible = 1;
- for (tgroup = group;tgroup;tgroup = tgroup->parent)
- {
- if (!tgroup->expanded)
- {
+ for (tgroup = group; tgroup; tgroup = tgroup->parent) {
+ if (!tgroup->expanded) {
nowVisible = 0;
break;
}
@@ -161,24 +159,12 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro return 1;
}
- if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->SubAllocated > 0)
- {
- for (i=0; i < group->cl.items[group->scanIndex]->SubAllocated; i++)
- {
- if (group->cl.items[group->scanIndex]->subcontacts[i].hContact == dwItem)
- {
-#ifdef _DEBUG
- if (IsBadWritePtr(&group->cl.items[group->scanIndex]->subcontacts[i], sizeof(ClcContact)))
- {
- log1("FindIltem->IsBadWritePtr | 2o [%08x]", &group->cl.items[group->scanIndex]->subcontacts[i]);
- PostMessage(hwnd,CLM_AUTOREBUILD, 0, 0);
- return 0;
- }
-#endif
+ if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->SubAllocated > 0) {
+ for (i = 0; i < group->cl.items[group->scanIndex]->SubAllocated; i++) {
+ if (group->cl.items[group->scanIndex]->subcontacts[i].hContact == dwItem) {
if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i];
if (subgroup) *subgroup = group;
-
return 1;
}
}
@@ -201,73 +187,68 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro void ClearRowByIndexCache()
{
- if (!CacheIndexClear)
- {
+ if (!CacheIndexClear) {
memset(CacheIndex, 0, sizeof(CacheIndex));
CacheIndexClear = TRUE;
- };
+ }
}
+
int cliGetRowByIndex(ClcData *dat,int testindex,ClcContact **contact,ClcGroup **subgroup)
{
int index = 0, i;
ClcGroup *group = &dat->list;
if (testindex < 0) return (-1);
- {
- group->scanIndex = 0;
- for (;;) {
- if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL) break;
- group->scanIndex++;
- continue;
- }
- if ((index>0) && (index < CacheArrSize))
- {
- CacheIndex[index] = group;
- CacheIndexClear = FALSE;
- };
-
- if (testindex == index) {
- if (contact) *contact = group->cl.items[group->scanIndex];
- if (subgroup) *subgroup = group;
- return index;
- }
- if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT)
- if (group->cl.items[group->scanIndex]->SubAllocated)
- if (group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta)
- {
- for (i=0; i < group->cl.items[group->scanIndex]->SubAllocated; i++)
- {
- if ((index>0) && (index < CacheArrSize))
- {
- CacheIndex[index] = group;
- CacheIndexClear = FALSE;
- };
- index++;
- if (testindex == index) {
- if (contact)
- {
- *contact = &group->cl.items[group->scanIndex]->subcontacts[i];
- (*contact)->subcontacts = group->cl.items[group->scanIndex];
- }
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ group->scanIndex++;
+ continue;
+ }
+
+ if (index > 0 && index < CacheArrSize) {
+ CacheIndex[index] = group;
+ CacheIndexClear = FALSE;
+ }
- if (subgroup) *subgroup = group;
- return index;
- }
- }
+ if (testindex == index) {
+ if (contact) *contact = group->cl.items[group->scanIndex];
+ if (subgroup) *subgroup = group;
+ return index;
+ }
+ if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT)
+ if (group->cl.items[group->scanIndex]->SubAllocated)
+ if (group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta) {
+ for (i = 0; i < group->cl.items[group->scanIndex]->SubAllocated; i++) {
+ if ((index>0) && (index < CacheArrSize)) {
+ CacheIndex[index] = group;
+ CacheIndexClear = FALSE;
+ }
+ index++;
+ if (testindex == index) {
+ if (contact) {
+ *contact = &group->cl.items[group->scanIndex]->subcontacts[i];
+ (*contact)->subcontacts = group->cl.items[group->scanIndex];
}
- index++;
- if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) {
- group = group->cl.items[group->scanIndex]->group;
- group->scanIndex = 0;
- continue;
- }
- group->scanIndex++;
+
+ if (subgroup) *subgroup = group;
+ return index;
+ }
+ }
+ }
+
+ index++;
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ continue;
}
- };
+ group->scanIndex++;
+ }
return -1;
}
|