summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-16 20:15:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-16 20:15:21 +0300
commit4eb749780954e748b365818b9678ad8894e373db (patch)
treec4a2a01e3f2a81d1588f11750d4ac9db69e155d5 /src/core
parent355a48796511abc6c3e9c43e22e25464adf7b6e4 (diff)
crash fix
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdmsg/src/chat_window.cpp11
-rw-r--r--src/core/stdmsg/src/tabs.cpp33
2 files changed, 9 insertions, 35 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index 155fc9e75b..fd098224a4 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -378,7 +378,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == 0x57 && isCtrl && !isAlt) { // ctrl-w (close window)
- PostMessage(hwndDlg, WM_CLOSE, 0, 0);
+ SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0);
return TRUE;
}
@@ -691,7 +691,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case WM_KEYDOWN:
if (wParam == 0x57 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w (close window)
- PostMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
+ PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0);
return TRUE;
}
break;
@@ -747,7 +747,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_KEYDOWN:
if (wParam == 0x57 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w (close window)
- PostMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
+ PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0);
return TRUE;
}
break;
@@ -946,9 +946,6 @@ void CChatRoomDlg::OnDestroy()
NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING);
SaveWindowPosition(true);
- if (g_Settings.bTabsEnable)
- SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this);
-
m_si->pDlg = NULL;
m_si->hWnd = NULL;
m_si->wState &= ~STATE_TALK;
@@ -1585,6 +1582,8 @@ LABEL_SHOWWINDOW:
break;
case GC_CLOSEWINDOW:
+ if (g_Settings.bTabsEnable)
+ SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this);
Close();
break;
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index f037e7132e..136b512fef 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -209,33 +209,9 @@ void CTabbedWindow::OnInitDialog()
void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt)
{
- int indexfound = -1;
- int lastlocked = -1;
- BOOL bFound = FALSE;
-
- TCITEM tci;
- tci.mask = TCIF_PARAM;
- int tabCount = m_tab.GetCount();
-
// does the tab already exist?
- for (int i = 0; i < tabCount; i++) {
- TabCtrl_GetItem(m_tab.GetHwnd(), i, &tci);
- SESSION_INFO *s2 = (SESSION_INFO*)tci.lParam;
- if (s2) {
- if (si == s2 && !bFound) {
- if (!bFound) {
- bFound = TRUE;
- indexfound = i;
- }
- }
-
- int w = db_get_w(s2->hContact, s2->pszModule, "TabPosition", 0);
- if (w)
- lastlocked = w;
- }
- }
-
- if (!bFound) { // create a new tab
+ int indexfound = (si->pDlg) ? m_tab.GetDlgIndex(si->pDlg) : -1;
+ if (indexfound == -1) { // create a new tab
wchar_t szTemp[30];
mir_wstrncpy(szTemp, si->ptszName, 21);
if (mir_wstrlen(si->ptszName) > 20)
@@ -250,9 +226,8 @@ void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt)
m_tab.ActivatePage(m_tab.GetCount() - 1);
}
-
- if (insertAt == -1 && bFound)
- TabCtrl_SetCurSel(m_tab.GetHwnd(), indexfound);
+ else if (insertAt == -1)
+ m_tab.ActivatePage(indexfound);
}
void CTabbedWindow::TabClicked()