summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-10-15 13:59:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-10-15 13:59:29 +0300
commit918665d9c1c732902c4489ebbf2c67e9d97949cb (patch)
tree6dcb52a8fd11788decb029309ed92b453dc9c54e
parentdac598b94b140b35425cbcc358e0797ad4855f65 (diff)
fix for crash in chat manager in service mode
-rw-r--r--include/m_chat_int.h1
-rw-r--r--src/mir_app/src/chat.h1
-rw-r--r--src/mir_app/src/chat_clist.cpp4
-rw-r--r--src/mir_app/src/chat_log.cpp20
-rw-r--r--src/mir_app/src/chat_manager.cpp145
-rw-r--r--src/mir_app/src/chat_svc.cpp2
6 files changed, 87 insertions, 86 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 472d08cf8c..06c95af4b5 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -290,7 +290,6 @@ struct CHAT_MANAGER
void (*SM_InvalidateLogDirectories)(void);
MODULEINFO* (*MM_CreateModule)(void);
- MODULEINFO* (*MM_FindModule)(const char *pszModule);
void (*MM_FontsChanged)(void);
void (*MM_IconsChanged)(void);
BOOL (*MM_RemoveAll)(void);
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 2172a014b9..ea86c7cea7 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -63,6 +63,7 @@ char* Log_SetStyle(int style);
// chat_manager.cpp
MODULEINFO* MM_AddModule(const char *pszModule);
+MODULEINFO* MM_FindModule(const char *pszModule);
BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted);
BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce);
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp
index 296eb81739..2c6b74cf1f 100644
--- a/src/mir_app/src/chat_clist.cpp
+++ b/src/mir_app/src/chat_clist.cpp
@@ -85,7 +85,7 @@ BOOL SetAllOffline(BOOL, const char *pszModule)
{
for (auto &hContact : Contacts(pszModule)) {
char *szProto = GetContactProto(hContact);
- if (!g_chatApi.MM_FindModule(szProto))
+ if (!MM_FindModule(szProto))
continue;
int i = db_get_b(hContact, szProto, "ChatRoom", 0);
if (i != 0) {
@@ -103,7 +103,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM)
return 0;
char *szProto = GetContactProto(hContact);
- if (g_chatApi.MM_FindModule(szProto) == nullptr)
+ if (MM_FindModule(szProto) == nullptr)
return 0;
if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0)
return 0;
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp
index 32dd87f67c..bfe6433e12 100644
--- a/src/mir_app/src/chat_log.cpp
+++ b/src/mir_app/src/chat_log.cpp
@@ -412,15 +412,17 @@ char* Log_CreateRtfHeader()
// set tabs and indents
int iIndent = 0;
- if (g_Settings->dwIconFlags) {
- iIndent += (14 * 1440) / g_chatApi.logPixelSX;
- buf.AppendFormat("\\tx%u", iIndent);
- }
- if (g_Settings->bShowTime) {
- int iSize = (g_Settings->LogTextIndent * 1440) / g_chatApi.logPixelSX;
- buf.AppendFormat("\\tx%u", iIndent + iSize);
- if (g_Settings->bLogIndentEnabled)
- iIndent += iSize;
+ if (g_Settings) {
+ if (g_Settings->dwIconFlags) {
+ iIndent += (14 * 1440) / g_chatApi.logPixelSX;
+ buf.AppendFormat("\\tx%u", iIndent);
+ }
+ if (g_Settings->bShowTime) {
+ int iSize = (g_Settings->LogTextIndent * 1440) / g_chatApi.logPixelSX;
+ buf.AppendFormat("\\tx%u", iIndent + iSize);
+ if (g_Settings->bLogIndentEnabled)
+ iIndent += iSize;
+ }
}
buf.AppendFormat("\\fi-%u\\li%u", iIndent, iIndent);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index b7404c1e4c..c4566909df 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -50,14 +50,6 @@ LIST<MODULEINFO> g_arModules(5, compareModules);
/////////////////////////////////////////////////////////////////////////////////////////
-CHAT_MANAGER::CHAT_MANAGER() :
- arSessions(g_arSessions)
-{}
-
-MIR_APP_EXPORT CHAT_MANAGER g_chatApi;
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
static void SetActiveSession(SESSION_INFO *si)
{
if (si) {
@@ -523,7 +515,7 @@ MODULEINFO* MM_AddModule(const char *pszModule)
if (pszModule == nullptr)
return nullptr;
- if (g_chatApi.MM_FindModule(pszModule))
+ if (MM_FindModule(pszModule))
return nullptr;
MODULEINFO *node = g_chatApi.MM_CreateModule();
@@ -555,7 +547,7 @@ static void MM_FontsChanged()
mi->pszHeader = g_chatApi.Log_CreateRtfHeader();
}
-static MODULEINFO* MM_FindModule(const char *pszModule)
+MODULEINFO* MM_FindModule(const char *pszModule)
{
if (!pszModule)
return nullptr;
@@ -955,70 +947,77 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit)
g_iFontMode = pInit->iFontMode;
g_pChatPlugin = pInit->pPlugin;
- g_chatApi.SetActiveSession = SetActiveSession;
- g_chatApi.GetActiveSession = GetActiveSession;
- g_chatApi.SM_CreateSession = SM_CreateSession;
- g_chatApi.SM_FindSession = SM_FindSession;
- g_chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
- g_chatApi.SM_BroadcastMessage = SM_BroadcastMessage;
- g_chatApi.SM_AddCommand = SM_AddCommand;
- g_chatApi.SM_GetPrevCommand = SM_GetPrevCommand;
- g_chatApi.SM_GetNextCommand = SM_GetNextCommand;
- g_chatApi.SM_GetCount = SM_GetCount;
- g_chatApi.SM_FindSessionByIndex = SM_FindSessionByIndex;
- g_chatApi.SM_GetUserFromIndex = SM_GetUserFromIndex;
- g_chatApi.SM_InvalidateLogDirectories = SM_InvalidateLogDirectories;
-
- g_chatApi.MM_CreateModule = MM_CreateModule;
- g_chatApi.MM_FindModule = MM_FindModule;
- g_chatApi.MM_FontsChanged = MM_FontsChanged;
- g_chatApi.MM_IconsChanged = MM_IconsChanged;
- g_chatApi.MM_RemoveAll = MM_RemoveAll;
-
- g_chatApi.TM_FindStatus = TM_FindStatus;
- g_chatApi.TM_WordToString = TM_WordToString;
- g_chatApi.TM_RemoveAll = TM_RemoveAll;
-
- g_chatApi.UM_AddUser = UM_AddUser;
- g_chatApi.UM_CompareItem = UM_CompareItem;
- g_chatApi.UM_FindUser = UM_FindUser;
- g_chatApi.UM_FindUserFromIndex = UM_FindUserFromIndex;
- g_chatApi.UM_GiveStatus = UM_GiveStatus;
- g_chatApi.UM_SetContactStatus = UM_SetContactStatus;
- g_chatApi.UM_TakeStatus = UM_TakeStatus;
- g_chatApi.UM_FindUserAutoComplete = UM_FindUserAutoComplete;
- g_chatApi.UM_RemoveUser = UM_RemoveUser;
-
- g_chatApi.LM_AddEvent = LM_AddEvent;
- g_chatApi.LM_TrimLog = LM_TrimLog;
- g_chatApi.LM_RemoveAll = LM_RemoveAll;
-
- g_chatApi.SetOffline = SetOffline;
- g_chatApi.SetAllOffline = SetAllOffline;
- g_chatApi.AddEvent = AddEvent;
- g_chatApi.FindRoom = FindRoom;
- g_chatApi.DoRtfToTags = DoRtfToTags;
-
- g_chatApi.Log_CreateRTF = Log_CreateRTF;
- g_chatApi.Log_CreateRtfHeader = Log_CreateRtfHeader;
- g_chatApi.LoadMsgDlgFont = LoadMsgDlgFont;
- g_chatApi.MakeTimeStamp = MakeTimeStamp;
-
- g_chatApi.DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
- g_chatApi.DoTrayIcon = DoTrayIcon;
- g_chatApi.DoPopup = DoPopup;
- g_chatApi.ShowPopup = ShowPopup;
- g_chatApi.LogToFile = LogToFile;
- g_chatApi.GetChatLogsFilename = GetChatLogsFilename;
- g_chatApi.Log_SetStyle = Log_SetStyle;
-
- g_chatApi.IsHighlighted = IsHighlighted;
- g_chatApi.RemoveFormatting = RemoveFormatting;
- g_chatApi.ReloadSettings = LoadGlobalSettings;
-
- g_chatApi.pLogIconBmpBits = pLogIconBmpBits;
-
RegisterFonts();
OptionsInit();
return &g_chatApi;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CHAT_MANAGER::CHAT_MANAGER() :
+ arSessions(g_arSessions)
+{
+ SetActiveSession = ::SetActiveSession;
+ GetActiveSession = ::GetActiveSession;
+ SM_CreateSession = ::SM_CreateSession;
+ SM_FindSession = ::SM_FindSession;
+ SM_GetStatusIcon = ::SM_GetStatusIcon;
+ SM_BroadcastMessage = ::SM_BroadcastMessage;
+ SM_AddCommand = ::SM_AddCommand;
+ SM_GetPrevCommand = ::SM_GetPrevCommand;
+ SM_GetNextCommand = ::SM_GetNextCommand;
+ SM_GetCount = ::SM_GetCount;
+ SM_FindSessionByIndex = ::SM_FindSessionByIndex;
+ SM_GetUserFromIndex = ::SM_GetUserFromIndex;
+ SM_InvalidateLogDirectories = ::SM_InvalidateLogDirectories;
+
+ MM_CreateModule = ::MM_CreateModule;
+ MM_FontsChanged = ::MM_FontsChanged;
+ MM_IconsChanged = ::MM_IconsChanged;
+ MM_RemoveAll = ::MM_RemoveAll;
+
+ TM_FindStatus = ::TM_FindStatus;
+ TM_WordToString = ::TM_WordToString;
+ TM_RemoveAll = ::TM_RemoveAll;
+
+ UM_AddUser = ::UM_AddUser;
+ UM_CompareItem = ::UM_CompareItem;
+ UM_FindUser = ::UM_FindUser;
+ UM_FindUserFromIndex = ::UM_FindUserFromIndex;
+ UM_GiveStatus = ::UM_GiveStatus;
+ UM_SetContactStatus = ::UM_SetContactStatus;
+ UM_TakeStatus = ::UM_TakeStatus;
+ UM_FindUserAutoComplete = ::UM_FindUserAutoComplete;
+ UM_RemoveUser = ::UM_RemoveUser;
+
+ LM_AddEvent = ::LM_AddEvent;
+ LM_TrimLog = ::LM_TrimLog;
+ LM_RemoveAll = ::LM_RemoveAll;
+
+ SetOffline = ::SetOffline;
+ SetAllOffline = ::SetAllOffline;
+ AddEvent = ::AddEvent;
+ FindRoom = ::FindRoom;
+ DoRtfToTags = ::DoRtfToTags;
+
+ Log_CreateRTF = ::Log_CreateRTF;
+ Log_CreateRtfHeader = ::Log_CreateRtfHeader;
+ LoadMsgDlgFont = ::LoadMsgDlgFont;
+ MakeTimeStamp = ::MakeTimeStamp;
+
+ DoSoundsFlashPopupTrayStuff = ::DoSoundsFlashPopupTrayStuff;
+ DoTrayIcon = ::DoTrayIcon;
+ DoPopup = ::DoPopup;
+ ShowPopup = ::ShowPopup;
+ LogToFile = ::LogToFile;
+ GetChatLogsFilename = ::GetChatLogsFilename;
+ Log_SetStyle = ::Log_SetStyle;
+
+ IsHighlighted = ::IsHighlighted;
+ RemoveFormatting = ::RemoveFormatting;
+ ReloadSettings = ::LoadGlobalSettings;
+
+ pLogIconBmpBits = ::pLogIconBmpBits;
+}
+
+MIR_APP_EXPORT CHAT_MANAGER g_chatApi;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 55d2e56db8..fea2b786e5 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -188,7 +188,7 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession(
void *pItemData) // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call
{
mir_cslockfull lck(csChat);
- MODULEINFO *mi = g_chatApi.MM_FindModule(pszModule);
+ MODULEINFO *mi = MM_FindModule(pszModule);
if (mi == nullptr)
return nullptr;