summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-08-15 13:49:37 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-08-15 13:49:37 +0300
commitf52b5cc86d9eff2494902157c8fc0a4e019a3c95 (patch)
tree9f668bf7b89decd53757589d74e476aac81eb451 /plugins/TabSRMM
parentd05dd78157058eea348f0d7666c7c6b0570ef25b (diff)
fixes #799 (Crash on receiving msg in FB group chat)
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp7
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp6
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp12
-rw-r--r--plugins/TabSRMM/src/msgs.cpp32
-rw-r--r--plugins/TabSRMM/src/msgs.h8
5 files changed, 24 insertions, 41 deletions
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index 2b2080af00..b682843cd9 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -605,13 +605,10 @@ void CChatRoomDlg::OnDestroy()
m_pContainer->UpdateTabs();
m_iTabID = -1;
}
+
if (m_pWnd) {
delete m_pWnd;
- m_pWnd = 0;
- }
- if (m_sbCustom) {
- delete m_sbCustom;
- m_sbCustom = 0;
+ m_pWnd = nullptr;
}
NotifyEvent(MSG_WINDOW_EVT_CLOSE);
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 3aaf459a05..28aafb0cb5 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -772,9 +772,9 @@ void CTabBaseDlg::DM_UpdateLastMessage() const
SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
mir_snwprintf(szBuf, TranslateT("%s is typing a message..."), m_cache->getNick());
}
- else if (m_sbCustom) {
- SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)m_sbCustom->hIcon);
- SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_sbCustom->tszText);
+ else if (m_bStatusSet) {
+ SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)m_szStatusIcon);
+ SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_szStatusText.c_str());
return;
}
else {
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 6447692995..d28eaad284 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -476,9 +476,9 @@ void CTabBaseDlg::tabUpdateStatusBar() const
SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_wszStatusBar);
}
- else if (m_sbCustom) {
- SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)m_sbCustom->hIcon);
- SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_sbCustom->tszText);
+ else if (m_bStatusSet) {
+ SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)m_szStatusText.c_str());
+ SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_szStatusIcon);
}
else {
SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, 0);
@@ -486,9 +486,9 @@ void CTabBaseDlg::tabUpdateStatusBar() const
}
}
else {
- if (m_sbCustom) {
- SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)m_sbCustom->hIcon);
- SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_sbCustom->tszText);
+ if (m_bStatusSet) {
+ SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)m_szStatusText.c_str());
+ SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)m_szStatusIcon);
}
else SendMessage(m_pContainer->hwndStatus, SB_SETICON, 0, 0);
}
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index 7325c07702..3a88bd7ee1 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -74,7 +74,6 @@ CTabBaseDlg::CTabBaseDlg(int iResource, SESSION_INFO *si)
CTabBaseDlg::~CTabBaseDlg()
{
delete m_pWnd;
- delete m_sbCustom;
mir_free(m_sendBuffer);
mir_free(m_hHistoryEvents);
@@ -278,31 +277,15 @@ void CTabBaseDlg::NotifyDeliveryFailure() const
}
/////////////////////////////////////////////////////////////////////////////////////////
-// service function. Sets a status bar text for a contact
+// Sets a status bar text for a contact
-static INT_PTR SetStatusText(WPARAM hContact, LPARAM lParam)
+void CTabBaseDlg::SetStatusText(const wchar_t *wszText, HICON hIcon)
{
- HWND hwnd = Srmm_FindWindow(hContact);
- if (hwnd == nullptr)
- hwnd = Srmm_FindWindow(db_mc_getMeta(hContact));
- if (hwnd == nullptr)
- return 0;
-
- CTabBaseDlg *pDlg = (CTabBaseDlg*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (pDlg != nullptr) {
- // delete old custom data
- if (pDlg->m_sbCustom) {
- delete pDlg->m_sbCustom;
- pDlg->m_sbCustom = nullptr;
- }
-
- StatusTextData *st = (StatusTextData*)lParam;
- if (st != nullptr)
- pDlg->m_sbCustom = new StatusTextData(*st);
-
- pDlg->tabUpdateStatusBar();
- }
- return 0;
+ m_bStatusSet = true;
+ m_szStatusText = wszText;
+ m_szStatusIcon = hIcon;
+
+ tabUpdateStatusBar();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1023,7 +1006,6 @@ static void TSAPI InitAPI()
{
CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand);
CreateServiceFunction(MS_MSG_SENDMESSAGEW, SendMessageCommand_W);
- CreateServiceFunction(MS_MSG_SETSTATUSTEXT, SetStatusText);
CreateServiceFunction("TabSRMsg/ReloadSkin", ReloadSkin);
CreateServiceFunction("TabSRMsg/ReloadSettings", ReloadSettings);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 2382d0fe86..160f57504a 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -242,6 +242,7 @@ class CTabBaseDlg : public CSrmmBaseDialog
protected:
virtual void LoadSettings() override;
+ virtual void SetStatusText(const wchar_t*, HICON) override;
void DM_AddDivider();
void DM_DismissTip(const POINT& pt);
@@ -278,7 +279,11 @@ protected:
DWORD m_dwTickLastEvent;
HBITMAP m_hOwnPic;
SIZE m_pic;
-
+
+ CMStringW m_szStatusText;
+ HICON m_szStatusIcon;
+ bool m_bStatusSet;
+
bool m_bShowInfoAvatar, m_bShowUIElements;
bool m_bUseOffset;
bool m_bkeyProcessed;
@@ -356,7 +361,6 @@ public:
CInfoPanel m_pPanel;
CContactCache *m_cache;
TContainerData *m_pContainer; // parent container description structure
- StatusTextData *m_sbCustom;
AVATARCACHEENTRY *m_ace, *m_ownAce;
CProxyWindow *m_pWnd; // proxy window object (win7+, for taskbar support).
// ALWAYS check this pointer before using it, it is not guaranteed to exist.