diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-17 18:38:21 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-17 18:38:21 +0300 |
commit | 198a9ac1c0b93073543858b1d9b311a8006c61d9 (patch) | |
tree | 3ed40154a65cc9eac8091f8493ac6f8ab335abf7 /src/mir_app | |
parent | fe2500aa99137c9ce35907c118745d65a0c0c07e (diff) |
duplicate code removed from Scriver
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 9 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 16 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 25ca0a15f3..d04c2e0d00 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -751,8 +751,10 @@ MIR_APP_DLL(void) Chat_AddMenuItems(HMENU hMenu, int nItems, const gc_item *Item UINT CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszWordText)
{
GCMENUITEMS gcmi = {};
- gcmi.pszID = si->ptszID;
- gcmi.pszModule = si->pszModule;
+ if (si) {
+ gcmi.pszID = si->ptszID;
+ gcmi.pszModule = si->pszModule;
+ }
gcmi.pszUID = (wchar_t*)pszUID;
gcmi.hMenu = hMenu;
@@ -782,7 +784,8 @@ UINT CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_INFO *si, const wcha gcmi.Type = MENU_ON_NICKLIST;
}
- NotifyEventHooks(hevBuildMenuEvent, 0, (WPARAM)&gcmi);
+ if (si)
+ NotifyEventHooks(hevBuildMenuEvent, 0, (WPARAM)&gcmi);
return TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, nullptr);
}
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index ded2e01386..65e2f0e359 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -189,9 +189,6 @@ LRESULT CSrmmBaseDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_CONTEXTMENU: - if (m_si == nullptr) - break; - POINT pt, ptl; m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel); if (lParam == 0xFFFFFFFF) { @@ -208,8 +205,9 @@ LRESULT CSrmmBaseDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) wchar_t *pszWord = (wchar_t*)_alloca(8192); pszWord[0] = '\0'; - if (sel.cpMin == sel.cpMax) { // get a word under cursor - int iCharIndex = m_log.SendMsg(EM_CHARFROMPOS, 0, (LPARAM)& ptl); + // get a word under cursor + if (sel.cpMin == sel.cpMax) { + int iCharIndex = m_log.SendMsg(EM_CHARFROMPOS, 0, (LPARAM)&ptl); if (iCharIndex < 0) break; @@ -256,9 +254,11 @@ LRESULT CSrmmBaseDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) case IDM_CLEAR: m_log.SetText(L""); - g_chatApi.LM_RemoveAll(&m_si->pLog, &m_si->pLogEnd); - m_si->iEventCount = 0; - m_si->LastTime = 0; + if (m_si) { + g_chatApi.LM_RemoveAll(&m_si->pLog, &m_si->pLogEnd); + m_si->iEventCount = 0; + m_si->LastTime = 0; + } PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); break; |