summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-02-22 20:30:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-02-22 20:30:41 +0300
commit833690b17bdf2393d41bf2f08334a7983eefab82 (patch)
tree9d7f9fbedef4a03e9e52d9004bf6049ca5c94456 /src
parentc7b17549ed7029682d9012d3d53d3e34523f699f (diff)
- fix for very rare hangup in chat manager;
- if nothing gets change, we don't fire events
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/chat_svc.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index c7d2eab119..7535345d40 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -469,13 +469,24 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce)
case GC_EVENT_TOPIC:
if (SESSION_INFO *si = chatApi.SM_FindSession(gcd->ptszID, gcd->pszModule)) {
- if (gce->ptszText) {
- replaceStrW(si->ptszTopic, RemoveFormatting(gce->ptszText));
+ wchar_t *pwszNew = RemoveFormatting(gce->ptszText);
+ if (!mir_wstrcmp(si->ptszTopic, pwszNew)) // nothing changed? exiting
+ return 0;
+
+ replaceStrW(si->ptszTopic, pwszNew);
+ if (pwszNew != NULL)
db_set_ws(si->hContact, si->pszModule, "Topic", si->ptszTopic);
- if (chatApi.OnSetTopic)
- chatApi.OnSetTopic(si);
- if (db_get_b(NULL, CHAT_MODULE, "TopicOnClist", 0))
+ else
+ db_unset(si->hContact, si->pszModule, "Topic");
+
+ if (chatApi.OnSetTopic)
+ chatApi.OnSetTopic(si);
+
+ if (db_get_b(NULL, CHAT_MODULE, "TopicOnClist", 0)) {
+ if (pwszNew != NULL)
db_set_ws(si->hContact, "CList", "StatusMsg", si->ptszTopic);
+ else
+ db_unset(si->hContact, "CList", "StatusMsg");
}
}
break;
@@ -616,9 +627,18 @@ MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wsz
if (wszNewName == NULL)
return GC_EVENT_ERROR;
- mir_cslock lck(csChat);
- if (SESSION_INFO *si = chatApi.SM_FindSession(wszId, szModule)) {
+ SESSION_INFO *si;
+ {
+ mir_cslock lck(csChat);
+ si = chatApi.SM_FindSession(wszId, szModule);
+ }
+ if (si != nullptr) {
+ // nothing really changed? exiting
+ if (!mir_wstrcmp(si->ptszName, wszNewName))
+ return 0;
+
replaceStrW(si->ptszName, wszNewName);
+ db_set_ws(si->hContact, szModule, "Nick", wszNewName);
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
}