From c2cb7db85cbd67c5b95c2735d9b917eb0ac1d234 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 Aug 2013 15:30:21 +0000 Subject: - fix for a rare crash on tabsrmm tooltips; - toolbar buttons added to a log git-svn-id: http://svn.miranda-ng.org/main/trunk@5659 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/log.cpp | 8 ++-- plugins/TabSRMM/src/chat/manager.cpp | 5 ++- plugins/TabSRMM/src/chat/muchighlight.cpp | 2 +- plugins/TabSRMM/src/chat/options.cpp | 4 +- plugins/TabSRMM/src/chat/window.cpp | 66 ++++++++++++++++--------------- 5 files changed, 45 insertions(+), 40 deletions(-) (limited to 'plugins/TabSRMM/src/chat') diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 25ff4df187..ee7830c91d 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -100,7 +100,7 @@ static int Log_AppendIEView(LOGSTREAMDATA* streamData, BOOL simpleMode, TCHAR ** lineLen = lineLen*9 + 8; if (*cbBufferEnd + lineLen > *cbBufferAlloced) { cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024); - *buffer = (TCHAR *) mir_realloc(*buffer, *cbBufferAlloced * sizeof(TCHAR)); + *buffer = (TCHAR*) mir_realloc(*buffer, *cbBufferAlloced * sizeof(TCHAR)); } d = *buffer + *cbBufferEnd; @@ -444,9 +444,9 @@ static TCHAR * _tcsrplc(TCHAR **src, const TCHAR *ptrn, const TCHAR *rplc) lRplc = lstrlen(rplc); if (lPtrn && lSrc && lSrc >= lPtrn && (tszFound = _tcsstr(*src, ptrn)) != NULL) { if (lRplc > lPtrn) - *src = (TCHAR *) realloc((void*) * src, + *src = (TCHAR*) realloc((void*) * src, sizeof(TCHAR) * (lSrc + lRplc - lPtrn + 1)); - if (tszTail = (TCHAR *) malloc(sizeof(TCHAR) * + if (tszTail = (TCHAR*) malloc(sizeof(TCHAR) * (lSrc - (tszFound - *src) - lPtrn + 1))) { /* save tail */ _tcscpy(tszTail, tszFound + lPtrn); @@ -476,7 +476,7 @@ static TCHAR * _tcsnrplc(TCHAR *src, size_t n, const TCHAR *ptrn, const TCHAR *r if (lPtrn && lSrc && lSrc >= lPtrn && /* lengths are ok */ (tszFound = _tcsstr(src, ptrn)) != NULL && /* pattern was found in string */ (n < 0 || lSrc - lPtrn + lRplc < n) && /* there is enough room in the string */ - (tszTail = (TCHAR *) malloc(sizeof(TCHAR) * + (tszTail = (TCHAR*) malloc(sizeof(TCHAR) * (lSrc - (tszFound - src) - lPtrn + 1))) != NULL) { /* save tail */ _tcscpy(tszTail, tszFound + lPtrn); diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp index 651c7945ef..3458ae87c3 100644 --- a/plugins/TabSRMM/src/chat/manager.cpp +++ b/plugins/TabSRMM/src/chat/manager.cpp @@ -657,7 +657,8 @@ void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewC if (si->lpCommands == NULL) { node->next = NULL; si->lpCommands = node; - } else { + } + else { node->next = si->lpCommands; si->lpCommands->last = node; // hmm, weird si->lpCommands = node; @@ -1189,7 +1190,7 @@ BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags) if (pszText == NULL) continue; - TCHAR* s = (TCHAR *)_tcsstr(pszText, p->pszUID); + TCHAR* s = (TCHAR*)_tcsstr(pszText, p->pszUID); if (s == NULL) continue; diff --git a/plugins/TabSRMM/src/chat/muchighlight.cpp b/plugins/TabSRMM/src/chat/muchighlight.cpp index c0d11ae716..1777657801 100644 --- a/plugins/TabSRMM/src/chat/muchighlight.cpp +++ b/plugins/TabSRMM/src/chat/muchighlight.cpp @@ -105,7 +105,7 @@ void CMUCHighlight::tokenize(TCHAR *tszString, TCHAR**& patterns, UINT& nr) } p++; } - patterns = (TCHAR **)mir_alloc(nr * sizeof(TCHAR *)); + patterns = (TCHAR **)mir_alloc(nr * sizeof(TCHAR*)); p = tszString; nr = 0; diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 2f042a249e..bcbea06b5c 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -580,7 +580,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP)); if (iLen > 0) { - pszText = (TCHAR *)realloc(pszText, (iLen + 2) * sizeof(TCHAR)); + pszText = (TCHAR*)realloc(pszText, (iLen + 2) * sizeof(TCHAR)); GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen + 1); db_set_ts(NULL, "Chat", "AddToGroup", pszText); } else @@ -1029,7 +1029,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM if (PluginConfig.m_chat_enabled) { int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY)); if (iLen > 0) { - TCHAR *pszText1 = (TCHAR *)malloc(iLen*sizeof(TCHAR) + 2); + TCHAR *pszText1 = (TCHAR*)malloc(iLen*sizeof(TCHAR) + 2); GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText1, iLen + 1); db_set_ts(NULL, "Chat", "LogDirectory", pszText1); free(pszText1); diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index a835a40098..20a0eb9d54 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -233,9 +233,12 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) if (dat == NULL) return; + SESSION_INFO *si = dat->si; + if (si == NULL) + return; + HWND hwndDlg = dat->hwnd; HWND hwndTab = GetParent(hwndDlg); - SESSION_INFO *si = dat->si; if (msg == WM_ACTIVATE) { if (dat->pContainer->dwFlags & CNT_TRANSPARENCY && CMimAPI::m_pSetLayeredWindowAttributes != NULL) { @@ -246,8 +249,9 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) if (si->hwndFilter) { POINT pt; - RECT rcFilter; GetCursorPos(&pt); + + RECT rcFilter; GetWindowRect(si->hwndFilter, &rcFilter); if (!PtInRect(&rcFilter, pt)) { SendMessage(si->hwndFilter, WM_CLOSE, 1, 1); @@ -1860,14 +1864,12 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case WM_INITDIALOG: { TNewWindowData *newData = (TNewWindowData*)lParam; - SESSION_INFO *psi = (SESSION_INFO*)newData->hdbEvent; - RECT rc; + si = (SESSION_INFO*)newData->hdbEvent; TWindowData *dat = (TWindowData*)calloc( sizeof(TWindowData), 1); - si = psi; - dat->si = psi; - dat->hContact = psi->hContact; - dat->szProto = GetContactProto(psi->hContact); + dat->si = si; + dat->hContact = si->hContact; + dat->szProto = GetContactProto(si->hContact); dat->bType = SESSIONTYPE_CHAT; dat->Panel = new CInfoPanel(dat); @@ -1879,25 +1881,25 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TabCtrl_SetItem(hwndTab, newData->iTabID, &newData->item); dat->iTabID = newData->iTabID; dat->pContainer = newData->pContainer; - psi->pContainer = newData->pContainer; + si->pContainer = newData->pContainer; dat->hwnd = hwndDlg; - psi->hWnd = hwndDlg; - psi->dat = dat; + si->hWnd = hwndDlg; + si->dat = dat; dat->fIsAutosizingInput = IsAutoSplitEnabled(dat); dat->fLimitedUpdate = false; dat->iInputAreaHeight = -1; if (!dat->pContainer->settings->fPrivate) - psi->iSplitterY = g_Settings.iSplitterY; + si->iSplitterY = g_Settings.iSplitterY; else { if (M.GetByte("Chat", "SyncSplitter", 0)) - psi->iSplitterY = dat->pContainer->settings->splitterPos - DPISCALEY_S(23); + si->iSplitterY = dat->pContainer->settings->splitterPos - DPISCALEY_S(23); else - psi->iSplitterY = g_Settings.iSplitterY; + si->iSplitterY = g_Settings.iSplitterY; } -#if defined(__FEAT_EXP_AUTOSPLITTER) - if (dat->fIsAutosizingInput) - psi->iSplitterY = GetDefaultMinimumInputHeight(dat); -#endif + #if defined(__FEAT_EXP_AUTOSPLITTER) + if (dat->fIsAutosizingInput) + si->iSplitterY = GetDefaultMinimumInputHeight(dat); + #endif dat->pWnd = 0; CProxyWindow::add(dat); @@ -1933,11 +1935,11 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar int mask = (int)SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_GETEVENTMASK, 0, 0); SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS | ENM_KEYEVENTS); -#if defined(__FEAT_EXP_AUTOSPLITTER) - SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETEVENTMASK, 0, ENM_REQUESTRESIZE | ENM_MOUSEEVENTS | ENM_SCROLL | ENM_KEYEVENTS | ENM_CHANGE); -#else - SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_SCROLL | ENM_KEYEVENTS | ENM_CHANGE); -#endif + #if defined(__FEAT_EXP_AUTOSPLITTER) + SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETEVENTMASK, 0, ENM_REQUESTRESIZE | ENM_MOUSEEVENTS | ENM_SCROLL | ENM_KEYEVENTS | ENM_CHANGE); + #else + SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_SCROLL | ENM_KEYEVENTS | ENM_CHANGE); + #endif SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_LIMITTEXT, (WPARAM)0x7FFFFFFF, 0); SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3)); @@ -1967,6 +1969,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar SendMessage(hwndDlg, GC_SETWNDPROPS, 0, 0); SendMessage(hwndDlg, GC_UPDATESTATUSBAR, 0, 0); SendMessage(hwndDlg, GC_UPDATETITLE, 0, 1); + + RECT rc; SendMessage(dat->pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); SetWindowPos(hwndDlg, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), 0); ShowWindow(hwndDlg, SW_SHOW); @@ -2002,10 +2006,10 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar DM_InitRichEdit(dat); SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETASNORMAL, TRUE, 0); - { - SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_SETITEMHEIGHT, 0, (LPARAM)g_Settings.iNickListFontHeight); - InvalidateRect(GetDlgItem(hwndDlg, IDC_LIST), NULL, TRUE); - } + + SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_SETITEMHEIGHT, 0, (LPARAM)g_Settings.iNickListFontHeight); + InvalidateRect(GetDlgItem(hwndDlg, IDC_LIST), NULL, TRUE); + SendDlgItemMessage(hwndDlg, IDC_FILTER, BUTTONSETOVERLAYICON, (LPARAM)(si->bFilterEnabled ? PluginConfig.g_iconOverlayEnabled : PluginConfig.g_iconOverlayDisabled), 0); SendMessage(hwndDlg, WM_SIZE, 0, 0); @@ -2065,7 +2069,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TCITEM item = { 0 }; item.mask = TCIF_TEXT; - lstrcpyn(dat->szStatus, (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)dat->wStatus, GSMDF_TCHAR), 50); + lstrcpyn(dat->szStatus, (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)dat->wStatus, GSMDF_TCHAR), 50); dat->szStatus[49] = 0; item.pszText = dat->newtitle; item.cchTextMax = 120; @@ -2680,7 +2684,7 @@ LABEL_SHOWWINDOW: TEXTRANGE tr = { 0 }; tr.chrg = cr; - tr.lpstrText = (TCHAR *)pszWord; + tr.lpstrText = (TCHAR*)pszWord; int iRes = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_GETTEXTRANGE, 0, (LPARAM)&tr); if (iRes > 0) { @@ -2786,7 +2790,7 @@ LABEL_SHOWWINDOW: TEXTRANGE tr; tr.lpstrText = NULL; tr.chrg = ((ENLINK *) lParam)->chrg; - tr.lpstrText = (TCHAR *)mir_alloc(sizeof(TCHAR) * (tr.chrg.cpMax - tr.chrg.cpMin + 2)); + tr.lpstrText = (TCHAR*)mir_alloc(sizeof(TCHAR) * (tr.chrg.cpMax - tr.chrg.cpMin + 2)); SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr); BOOL isLink = IsStringValidLink(tr.lpstrText); @@ -3350,7 +3354,7 @@ LABEL_SHOWWINDOW: case DM_CONTAINERSELECTED: { TContainerData *pNewContainer = 0; - TCHAR *szNewName = (TCHAR *)lParam; + TCHAR *szNewName = (TCHAR*)lParam; if (!_tcscmp(szNewName, TranslateT("Default container"))) szNewName = CGlobals::m_default_container_name; int iOldItems = TabCtrl_GetItemCount(hwndTab); -- cgit v1.2.3