diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-11 14:39:15 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-11 14:39:15 +0000 |
commit | 16f34087d04db189c0d204540c873ebc910c0fa2 (patch) | |
tree | d68c9a197903648d7fa53be6331929d67826db0e /plugins | |
parent | d6738c3c5796bd7f0def65eb7b3236bbf6d8373e (diff) |
trap #3 for a crash
git-svn-id: http://svn.miranda-ng.org/main/trunk@5653 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/manager.cpp | 184 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sidebar.cpp | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/srmm.cpp | 6 |
5 files changed, 83 insertions, 112 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index 38ca3e9bd9..f64b71728c 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -154,7 +154,7 @@ struct STATUSINFO {
TCHAR *pszGroup;
HICON hIcon;
- DWORD Status;
+ WORD Status;
STATUSINFO *next;
};
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp index 8171ea2dcc..651c7945ef 100644 --- a/plugins/TabSRMM/src/chat/manager.cpp +++ b/plugins/TabSRMM/src/chat/manager.cpp @@ -71,6 +71,12 @@ SESSION_INFO* SM_AddSession(const TCHAR* pszID, const char* pszModule) node->ptszID = mir_tstrdup(pszID);
node->pszModule = mir_strdup(pszModule);
+ {
+ char *p = (char*)node;
+ _DebugTraceA("SESSION_INFO allocated: crashes at %lp %lp %lp %lp",
+ p + offsetof(SESSION_INFO, wStatus), p + offsetof(SESSION_INFO, wState), p + offsetof(SESSION_INFO, wCommandsNum), p + offsetof(SESSION_INFO, szSearch));
+ }
+
MODULEINFO *mi = MM_FindModule(pszModule);
if (mi) {
mi->idleTimeStamp = time(0);
@@ -903,6 +909,10 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int if (!TM_FindStatus(*ppStatusList, pszStatus)) {
STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
+ {
+ char *p = (char*)node;
+ _DebugTraceA("STATUSINFO allocated: crashes at %lp", p + offsetof(STATUSINFO, Status));
+ }
replaceStrT(node->pszGroup, pszStatus);
node->hIcon = (HICON)(*iCount);
while ((int)node->hIcon > STATUSICONCOUNT - 1)
@@ -1012,40 +1022,32 @@ static int sttCompareNicknames(const TCHAR *s1, const TCHAR *s2) static int UM_CompareItem(USERINFO * u1, const TCHAR* pszNick, WORD wStatus)
{
- int i;
-
WORD dw1 = u1->Status;
WORD dw2 = wStatus;
- for (i=0; i < 8; i++) {
+ for (int i=0; i < 8; i++) {
if ((dw1 & 1) && !(dw2 & 1))
return -1;
+
if ((dw2 & 1) && !(dw1 & 1))
return 1;
- if ((dw1 & 1) && (dw2 & 1))
- //
- {
+
+ if ((dw1 & 1) && (dw2 & 1)) {
if (g_Settings.bAlternativeSorting)
return sttCompareNicknames(u1->pszNick, pszNick);
- else
- return lstrcmp(u1->pszNick, pszNick);
- }//
+ return lstrcmp(u1->pszNick, pszNick);
+ }
dw1 = dw1 >> 1;
dw2 = dw2 >> 1;
}
if (g_Settings.bAlternativeSorting)
- //
return sttCompareNicknames(u1->pszNick, pszNick);
- else
- return lstrcmp(u1->pszNick, pszNick);
- //
+ return lstrcmp(u1->pszNick, pszNick);
}
-USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID)
+USERINFO* UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID)
{
- USERINFO * pTemp = *ppUserList, *pLast = NULL;
- USERINFO * node = NULL;
-
+ USERINFO *pTemp = *ppUserList, *pLast = NULL;
if (!pTemp || !pszUID)
return NULL;
@@ -1054,140 +1056,124 @@ USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID) pTemp = pTemp->next;
}
- if (pTemp) {
- node = pTemp;
- if (pLast)
- pLast->next = pTemp->next;
- else
- *ppUserList = pTemp->next;
- pTemp = *ppUserList;
+ if (pTemp == NULL)
+ return NULL;
- pLast = NULL;
+ USERINFO *node = pTemp;
+ if (pLast)
+ pLast->next = pTemp->next;
+ else
+ *ppUserList = pTemp->next;
+ pTemp = *ppUserList;
- while (pTemp && UM_CompareItem(pTemp, node->pszNick, node->Status) <= 0) {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
+ pLast = NULL;
- if (*ppUserList == NULL) { // list is empty
- *ppUserList = node;
- node->next = NULL;
- } else {
- if (pLast) {
- node->next = pTemp;
- pLast->next = node;
- } else {
- node->next = *ppUserList;
- *ppUserList = node;
- }
- }
+ while (pTemp && UM_CompareItem(pTemp, node->pszNick, node->Status) <= 0) {
+ pLast = pTemp;
+ pTemp = pTemp->next;
+ }
- return node;
+ if (*ppUserList == NULL) { // list is empty
+ *ppUserList = node;
+ node->next = NULL;
}
- return NULL;
+ else if (pLast) {
+ node->next = pTemp;
+ pLast->next = node;
+ }
+ else {
+ node->next = *ppUserList;
+ *ppUserList = node;
+ }
+
+ return node;
}
USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
{
- USERINFO * pTemp = *ppUserList, *pLast = NULL;
-
if (!pStatusList || !ppUserList || !ppUserList)
return NULL;
+ USERINFO *pTemp = *ppUserList, *pLast = NULL;
while (pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0) {
pLast = pTemp;
pTemp = pTemp->next;
}
- // if (!UM_FindUser(*ppUserList, pszUI, wStatus)
+ USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO));
{
- USERINFO *node = (USERINFO*) mir_alloc(sizeof(USERINFO));
- ZeroMemory(node, sizeof(USERINFO));
- replaceStrT(node->pszUID, pszUID);
-
- if (*ppUserList == NULL) { // list is empty
- *ppUserList = node;
- node->next = NULL;
- } else {
- if (pLast) {
- node->next = pTemp;
- pLast->next = node;
- } else {
- node->next = *ppUserList;
- *ppUserList = node;
- }
- }
+ char *p = (char*)node;
+ _DebugTraceA("USERINFO allocated: crashes at %lp",
+ p + offsetof(USERINFO, Status), p + offsetof(USERINFO, ContactStatus));
+ }
+ replaceStrT(node->pszUID, pszUID);
- return node;
+ if (*ppUserList == NULL) { // list is empty
+ *ppUserList = node;
+ node->next = NULL;
}
- return NULL;
+ else if (pLast) {
+ node->next = pTemp;
+ pLast->next = node;
+ }
+ else {
+ node->next = *ppUserList;
+ *ppUserList = node;
+ }
+
+ return node;
}
USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID)
{
- USERINFO *pTemp = pUserList;
-
if (!pUserList || !pszUID)
return NULL;
- while (pTemp != NULL) {
+ for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
if (!lstrcmpi(pTemp->pszUID, pszUID))
return pTemp;
- pTemp = pTemp->next;
- }
return 0;
}
USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index)
{
- int i=0;
- USERINFO *pTemp = pUserList;
-
if (!pUserList)
return NULL;
- while (pTemp != NULL) {
- if (i == index) {
+ int i=0;
+ for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next, i++)
+ if (i == index)
return pTemp;
- }
- pTemp = pTemp->next;
- i++;
- }
+
return NULL;
}
USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
{
- USERINFO *pTemp = pUserList;
-
if (!pUserList || !pszUID)
return NULL;
- while (pTemp != NULL) {
+ for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
if (!lstrcmpi(pTemp->pszUID, pszUID)) {
pTemp->Status |= status;
return pTemp;
}
- pTemp = pTemp->next;
- }
+
return 0;
}
USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
{
- USERINFO *pTemp = pUserList;
-
if (!pUserList || !pszUID)
return NULL;
- while (pTemp != NULL) {
+ for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
if (!lstrcmpi(pTemp->pszUID, pszUID)) {
pTemp->ContactStatus = status;
return pTemp;
}
- pTemp = pTemp->next;
- }
+
return 0;
}
@@ -1223,36 +1209,29 @@ BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags) USERINFO* UM_TakeStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
{
- USERINFO *pTemp = pUserList;
-
if (!pUserList || !pszUID)
return NULL;
- while (pTemp != NULL) {
+ for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
if (!lstrcmpi(pTemp->pszUID, pszUID)) {
pTemp->Status &= ~status;
return pTemp;
}
- pTemp = pTemp->next;
- }
+
return 0;
}
TCHAR* UM_FindUserAutoComplete(USERINFO* pUserList, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
- TCHAR* pszName = NULL;
- USERINFO *pTemp = pUserList;
-
if (!pUserList || !pszOriginal || !pszCurrent)
return NULL;
- while (pTemp != NULL) {
+ TCHAR *pszName = NULL;
+ for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
if (my_strstri(pTemp->pszNick, pszOriginal) == pTemp->pszNick)
if (lstrcmpi(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->pszNick, pszName) < 0))
pszName = pTemp->pszNick;
- pTemp = pTemp->next;
- }
return pszName;
}
@@ -1305,15 +1284,10 @@ BOOL UM_RemoveAll(USERINFO** ppUserList) LOGINFO * LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd)
{
-
- LOGINFO *node = NULL;
-
if (!ppLogListStart || !ppLogListEnd)
return NULL;
- node = (LOGINFO*) mir_alloc(sizeof(LOGINFO));
- ZeroMemory(node, sizeof(LOGINFO));
-
+ LOGINFO *node = (LOGINFO*)mir_calloc(sizeof(LOGINFO));
if (*ppLogListStart == NULL) { // list is empty
*ppLogListStart = node;
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 71cd93d012..ef0416e3bd 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -1985,7 +1985,7 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) else
StretchBlt(hdcDraw, xy_off, top + xy_off, (int)dNewWidth + width_off,
iMaxHeight + width_off, hdcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY);
- //_DebugTraceA("metrics: %d, %d %d, %d", (int)dNewWidth + width_off, iMaxHeight + width_off, bminfo.bmWidth, bminfo.bmHeight);
+
SelectObject(hdcMem, hbmMem);
DeleteObject(hbmMem);
DeleteDC(hdcMem);
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp index 16210a08e3..d304d8965a 100644 --- a/plugins/TabSRMM/src/sidebar.cpp +++ b/plugins/TabSRMM/src/sidebar.cpp @@ -793,7 +793,6 @@ void CSideBar::Layout(const RECT *rc, bool fOnlyCalc) bottomEnabled = (m_totalItemHeight - m_firstVisibleOffset > rc->bottom);
::EndDeferWindowPos(hdwp);
- //_DebugTraceA("layout: total %d, used: %d, first visible: %d", m_totalItemHeight, spaceUsed, m_firstVisibleOffset);
if (!fOnlyCalc) {
RECT rcContainer;
::GetClientRect(m_pContainer->hwnd, &rcContainer);
diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp index a85912ad55..2770a3ec73 100644 --- a/plugins/TabSRMM/src/srmm.cpp +++ b/plugins/TabSRMM/src/srmm.cpp @@ -166,11 +166,9 @@ int _DebugTraceA(const char *fmt, ...) #else
{
char szLogFileName[MAX_PATH], szDataPath[MAX_PATH];
- FILE *f;
-
CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szDataPath);
- mir_snprintf(szLogFileName, MAX_PATH, "%s\\%s", szDataPath, "tabsrmm_debug.log");
- f = fopen(szLogFileName, "a+");
+ mir_snprintf(szLogFileName, MAX_PATH, "%s\\tabsrmm_debug.log", szDataPath);
+ FILE *f = fopen(szLogFileName, "a+");
if (f) {
fputs(debug, f);
fputs("\n", f);
|