diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-11 13:53:04 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-11 13:53:04 +0000 |
commit | 5f4dfea172962d33442546739976edf7023a1a7c (patch) | |
tree | 92d6e1ba9c4d47122effce9e6d82508039f1fe56 | |
parent | 95b2fb2835c60505cefcbbaeb9c53875b6687993 (diff) |
attempt to discover the crash place in chats
git-svn-id: http://svn.miranda-ng.org/main/trunk@5651 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Popup/src/popup_wnd2.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/clist.cpp | 119 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/main.cpp | 50 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/manager.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 2 |
6 files changed, 80 insertions, 105 deletions
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 15dadb8db6..1616aa3f4a 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -1182,7 +1182,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara char* sztext;
if ((this->m_lpwzText) || (this->m_lpwzTitle))
{
- int size = _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle) + 3;
+ size_t size = _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle) + 3;
text = (TCHAR*)mir_alloc(size * sizeof(TCHAR));
mir_sntprintf(text, size, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText);
}
diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index 78c5c5600c..7667cc7d7a 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -38,50 +38,36 @@ char *szChatIconString = "chaticon"; static HANDLE Clist_GroupExists(TCHAR *tszGroup)
{
- unsigned int i=0;
- TCHAR* _t = 0;
- char str[10];
- INT_PTR result = 0;
- DBVARIANT dbv = {0};
- int match;
-
- do {
+ for (int i=0; ; i++) {
+ char str[10];
_itoa(i, str, 10);
- result = db_get_ts(0, "CListGroups", str, &dbv);
- if (!result) {
- match = (!_tcscmp(tszGroup, &dbv.ptszVal[1]) && (lstrlen(tszGroup) == lstrlen(&dbv.ptszVal[1])));
- db_free(&dbv);
- if (match)
- return((HANDLE)(i + 1));
- }
- i++;
+ ptrT groupName( db_get_tsa(0, "CListGroups", str));
+ if (groupName == NULL)
+ return NULL;
+
+ if (!_tcscmp(tszGroup, &groupName[1]) && lstrlen(tszGroup) == lstrlen(&groupName[1]))
+ return HANDLE(i + 1);
}
- while(result == 0);
- return 0;
}
HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
{
- HANDLE hContact = CList_FindRoom(pszModule, pszRoom);
- DBVARIANT dbv;
- TCHAR pszGroup[50];
-
- *pszGroup = '\0';
- if (!db_get_ts(NULL, "Chat", "AddToGroup", &dbv)) {
- if (lstrlen(dbv.ptszVal) > 0)
- lstrcpyn(pszGroup, dbv.ptszVal, 50);
- db_free(&dbv);
- }
- else lstrcpyn(pszGroup, _T("Chat rooms"), 50);
+ TCHAR pszGroup[50]; *pszGroup = '\0';
+
+ ptrT groupName( db_get_tsa(NULL, "Chat", "AddToGroup"));
+ if (groupName)
+ _tcsncpy_s(pszGroup, SIZEOF(pszGroup), groupName, _TRUNCATE);
+ else
+ _tcscpy(pszGroup, _T("Chat rooms"));
if (pszGroup[0])
CList_CreateGroup(pszGroup);
+ HANDLE hContact = CList_FindRoom(pszModule, pszRoom);
if (hContact)
return hContact;
// here we create a new one since no one is to be found
-
if ((hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL)
return NULL;
@@ -105,7 +91,7 @@ BOOL CList_SetOffline(HANDLE hContact, BOOL bHide) if (szProto == NULL)
return FALSE;
- db_set_w(hContact, szProto, "ApparentMode", (LPARAM)0);
+ db_set_w(hContact, szProto, "ApparentMode", 0);
db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
return TRUE;
}
@@ -136,43 +122,38 @@ int CList_RoomDoubleclicked(WPARAM wParam, LPARAM lParam) return 0;
char *szProto = GetContactProto(hContact);
- if (MM_FindModule(szProto)) {
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0)
- return 0;
-
- DBVARIANT dbv;
- if (!db_get_ts(hContact, szProto, "ChatRoomID", &dbv)) {
- SESSION_INFO *si = SM_FindSession(dbv.ptszVal, szProto);
- if (si) {
- // is the "toggle visibility option set, so we need to close the window?
- if (si->hWnd != NULL
- && M.GetByte("Chat", "ToggleVisibility", 0) == 1
- && !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0)
- && IsWindowVisible(si->hWnd)
- && !IsIconic(si->pContainer->hwnd)) {
- PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
- db_free(&dbv);
- return 1;
- }
+ if ( !MM_FindModule(szProto) || !db_get_b(hContact, szProto, "ChatRoom", 0))
+ return 0;
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
- if (lParam) {
- SendMessage(si->hWnd, DM_ACTIVATEME, 0, 0);
- if (si->dat)
- SetForegroundWindow(si->dat->pContainer->hwnd);
- }
- }
- db_free(&dbv);
+ ptrT roomid( db_get_tsa(hContact, szProto, "ChatRoomID"));
+ if (roomid == NULL)
+ return 0;
+
+ SESSION_INFO *si = SM_FindSession(roomid, szProto);
+ if (si) {
+ // is the "toggle visibility option set, so we need to close the window?
+ if (si->hWnd != NULL &&
+ M.GetByte("Chat", "ToggleVisibility", 0) == 1 &&
+ !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0) &&
+ IsWindowVisible(si->hWnd) && !IsIconic(si->pContainer->hwnd))
+ {
+ PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
return 1;
}
- }
- return 0;
+ ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ if (lParam) {
+ SendMessage(si->hWnd, DM_ACTIVATEME, 0, 0);
+ if (si->dat)
+ SetForegroundWindow(si->dat->pContainer->hwnd);
+ }
+ }
+ return 1;
}
INT_PTR CList_EventDoubleclicked(WPARAM wParam, LPARAM lParam)
{
- return CList_RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, (LPARAM)0);
+ return CList_RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, 0);
}
INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam)
@@ -182,10 +163,11 @@ INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam) char *szProto = GetContactProto(hContact);
if (szProto) {
if ( db_get_w(hContact, szProto, "Status", 0) == ID_STATUS_OFFLINE)
- CallProtoService( szProto, PS_JOINCHAT, wParam, lParam );
+ CallProtoService(szProto, PS_JOINCHAT, wParam, lParam);
else
- CList_RoomDoubleclicked( wParam, 0 );
- } }
+ CList_RoomDoubleclicked(wParam, 0);
+ }
+ }
return 0;
}
@@ -289,14 +271,9 @@ HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom) if ( !db_get_b(hContact, pszModule, "ChatRoom", 0))
continue;
- DBVARIANT dbv;
- if (!db_get_ts(hContact, pszModule, "ChatRoomID", &dbv)) {
- if (!lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free(&dbv);
- return hContact;
- }
- db_free(&dbv);
- }
+ ptrT roomid( db_get_tsa(hContact, pszModule, "ChatRoomID"));
+ if (roomid != NULL && !lstrcmpi(roomid, pszRoom))
+ return hContact;
}
return 0;
}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index 7fd80940b1..4a90cf5717 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -36,17 +36,17 @@ #include "..\commonheaders.h"
-HANDLE g_hWindowList;
-HMENU g_hMenu = NULL;
+HANDLE g_hWindowList;
+HMENU g_hMenu = NULL;
FONTINFO aFonts[OPTIONS_FONTCOUNT];
-HICON hIcons[30];
-HBRUSH hListBkgBrush = NULL;
+HICON hIcons[30];
+HBRUSH hListBkgBrush = NULL;
TMUCSettings g_Settings;
-TCHAR *pszActiveWndID = 0;
-char *pszActiveWndModule = 0;
+TCHAR *pszActiveWndID = 0;
+char *pszActiveWndModule = 0;
/*
* load the group chat module
@@ -95,26 +95,26 @@ int Chat_Unload(void) void LoadLogIcons(void)
{
ZeroMemory(hIcons, sizeof(HICON) * (ICON_STATUS5 - ICON_ACTION));
- hIcons[ICON_ACTION] = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
- hIcons[ICON_ADDSTATUS] = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
- hIcons[ICON_HIGHLIGHT] = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
- hIcons[ICON_INFO] = LoadIconEx(IDI_INFO, "log_info", 16, 16);
- hIcons[ICON_JOIN] = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
- hIcons[ICON_KICK] = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
- hIcons[ICON_MESSAGE] = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
+ hIcons[ICON_ACTION] = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
+ hIcons[ICON_ADDSTATUS] = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
+ hIcons[ICON_HIGHLIGHT] = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
+ hIcons[ICON_INFO] = LoadIconEx(IDI_INFO, "log_info", 16, 16);
+ hIcons[ICON_JOIN] = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
+ hIcons[ICON_KICK] = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
+ hIcons[ICON_MESSAGE] = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
hIcons[ICON_MESSAGEOUT] = LoadIconEx(IDI_MESSAGEOUT, "log_message_out", 16, 16);
- hIcons[ICON_NICK] = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
- hIcons[ICON_NOTICE] = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
- hIcons[ICON_PART] = LoadIconEx(IDI_PART, "log_part", 16, 16);
- hIcons[ICON_QUIT] = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
- hIcons[ICON_REMSTATUS] = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
- hIcons[ICON_TOPIC] = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
- hIcons[ICON_STATUS1] = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
- hIcons[ICON_STATUS2] = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
- hIcons[ICON_STATUS3] = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
- hIcons[ICON_STATUS4] = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
- hIcons[ICON_STATUS0] = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
- hIcons[ICON_STATUS5] = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
+ hIcons[ICON_NICK] = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
+ hIcons[ICON_NOTICE] = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
+ hIcons[ICON_PART] = LoadIconEx(IDI_PART, "log_part", 16, 16);
+ hIcons[ICON_QUIT] = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
+ hIcons[ICON_REMSTATUS] = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
+ hIcons[ICON_TOPIC] = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
+ hIcons[ICON_STATUS1] = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
+ hIcons[ICON_STATUS2] = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
+ hIcons[ICON_STATUS3] = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
+ hIcons[ICON_STATUS4] = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
+ hIcons[ICON_STATUS0] = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
+ hIcons[ICON_STATUS5] = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
}
void LoadIcons(void)
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp index 986cabdc47..fcb5daf808 100644 --- a/plugins/TabSRMM/src/chat/manager.cpp +++ b/plugins/TabSRMM/src/chat/manager.cpp @@ -352,12 +352,11 @@ BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI for (SESSION_INFO *si = s_WndList; si; si = si->next) {
if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- DWORD dw;
USERINFO *ui = UM_FindUser(si->pUsers, pszUID);
if (ui) {
si->nUsersInNicklist--;
- dw = UM_RemoveUser(&si->pUsers, pszUID);
+ UM_RemoveUser(&si->pUsers, pszUID);
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
@@ -507,12 +506,11 @@ BOOL SM_ReconfigureFilters() BOOL SM_InvalidateLogDirectories()
{
- EnterCriticalSection(&cs);
+ mir_cslock lck(cs);
for (SESSION_INFO *si = s_WndList; si; si = si->next)
- si->pszLogFileName[0] = 0;
+ si->pszLogFileName[0] = si->pszLogFileName[1] = 0;
- LeaveCriticalSection(&cs);
return TRUE;
}
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 29941c9312..0998d699a3 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -279,7 +279,7 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) if (dat->iTabID >= 0) {
if (db_get_w(si->hContact, si->pszModule , "ApparentMode", 0) != 0)
- db_set_w(si->hContact, si->pszModule , "ApparentMode", (LPARAM)0);
+ db_set_w(si->hContact, si->pszModule , "ApparentMode", 0);
if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)szChatIconString);
@@ -2417,7 +2417,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar si->wState &= ~STATE_TALK;
dat->bWasDeleted = 1;
- db_set_w(si->hContact, si->pszModule , "ApparentMode", (LPARAM)0);
+ db_set_w(si->hContact, si->pszModule , "ApparentMode", 0);
SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, lParam == 2 ? lParam : 1);
return TRUE;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 73bfba143d..80cf9d1eda 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -340,7 +340,7 @@ INT_PTR SendMessageCommand_W(WPARAM wParam, LPARAM lParam) SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(TCHAR *) lParam);
}
- SendMessage(hwnd, DM_ACTIVATEME, 0, (LPARAM)0);
+ SendMessage(hwnd, DM_ACTIVATEME, 0, 0);
} else {
TCHAR szName[CONTAINER_NAMELEN + 1];
|