summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-14 20:22:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-14 20:22:55 +0000
commit60adc0705ec417756a3e86d436ad21b5265a1da2 (patch)
tree112f226275020791c6d390d8413c517f96ef085c
parent6c11adb0b8ca512ffa8a2604ab2f7226a2214cc9 (diff)
fixes #592 (Crash on exit if LoadDefaultModules(void) not executed all)
git-svn-id: http://svn.miranda-ng.org/main/trunk@8604 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/modules/chat/chat_svc.cpp61
-rw-r--r--src/modules/chat/log.cpp40
-rw-r--r--src/modules/chat/manager.cpp20
3 files changed, 64 insertions, 57 deletions
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index 37fa9f3c06..1239b624b0 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -47,26 +47,26 @@ static HANDLE
void LoadChatIcons(void)
{
- ci.hIcons[ICON_ACTION] = LoadIconEx("log_action", FALSE);
- ci.hIcons[ICON_ADDSTATUS] = LoadIconEx("log_addstatus", FALSE);
- ci.hIcons[ICON_HIGHLIGHT] = LoadIconEx("log_highlight", FALSE);
- ci.hIcons[ICON_INFO] = LoadIconEx("log_info", FALSE);
- ci.hIcons[ICON_JOIN] = LoadIconEx("log_join", FALSE);
- ci.hIcons[ICON_KICK] = LoadIconEx("log_kick", FALSE);
- ci.hIcons[ICON_MESSAGE] = LoadIconEx("log_message_in", FALSE);
+ ci.hIcons[ICON_ACTION] = LoadIconEx("log_action", FALSE);
+ ci.hIcons[ICON_ADDSTATUS] = LoadIconEx("log_addstatus", FALSE);
+ ci.hIcons[ICON_HIGHLIGHT] = LoadIconEx("log_highlight", FALSE);
+ ci.hIcons[ICON_INFO] = LoadIconEx("log_info", FALSE);
+ ci.hIcons[ICON_JOIN] = LoadIconEx("log_join", FALSE);
+ ci.hIcons[ICON_KICK] = LoadIconEx("log_kick", FALSE);
+ ci.hIcons[ICON_MESSAGE] = LoadIconEx("log_message_in", FALSE);
ci.hIcons[ICON_MESSAGEOUT] = LoadIconEx("log_message_out", FALSE);
- ci.hIcons[ICON_NICK] = LoadIconEx("log_nick", FALSE);
- ci.hIcons[ICON_NOTICE] = LoadIconEx("log_notice", FALSE);
- ci.hIcons[ICON_PART] = LoadIconEx("log_part", FALSE);
- ci.hIcons[ICON_QUIT] = LoadIconEx("log_quit", FALSE);
- ci.hIcons[ICON_REMSTATUS] = LoadIconEx("log_removestatus", FALSE);
- ci.hIcons[ICON_TOPIC] = LoadIconEx("log_topic", FALSE);
- ci.hIcons[ICON_STATUS0] = LoadIconEx("status0", FALSE);
- ci.hIcons[ICON_STATUS1] = LoadIconEx("status1", FALSE);
- ci.hIcons[ICON_STATUS2] = LoadIconEx("status2", FALSE);
- ci.hIcons[ICON_STATUS3] = LoadIconEx("status3", FALSE);
- ci.hIcons[ICON_STATUS4] = LoadIconEx("status4", FALSE);
- ci.hIcons[ICON_STATUS5] = LoadIconEx("status5", FALSE);
+ ci.hIcons[ICON_NICK] = LoadIconEx("log_nick", FALSE);
+ ci.hIcons[ICON_NOTICE] = LoadIconEx("log_notice", FALSE);
+ ci.hIcons[ICON_PART] = LoadIconEx("log_part", FALSE);
+ ci.hIcons[ICON_QUIT] = LoadIconEx("log_quit", FALSE);
+ ci.hIcons[ICON_REMSTATUS] = LoadIconEx("log_removestatus", FALSE);
+ ci.hIcons[ICON_TOPIC] = LoadIconEx("log_topic", FALSE);
+ ci.hIcons[ICON_STATUS0] = LoadIconEx("status0", FALSE);
+ ci.hIcons[ICON_STATUS1] = LoadIconEx("status1", FALSE);
+ ci.hIcons[ICON_STATUS2] = LoadIconEx("status2", FALSE);
+ ci.hIcons[ICON_STATUS3] = LoadIconEx("status3", FALSE);
+ ci.hIcons[ICON_STATUS4] = LoadIconEx("status4", FALSE);
+ ci.hIcons[ICON_STATUS5] = LoadIconEx("status5", FALSE);
LoadMsgLogBitmaps();
}
@@ -262,7 +262,7 @@ static void SetInitDone(SESSION_INFO *si)
{
if (si->bInitDone)
return;
-
+
si->bInitDone = true;
for (STATUSINFO *p = si->pStatuses; p; p = p->next)
if ((UINT_PTR)p->hIcon < STATUSICONCOUNT)
@@ -410,7 +410,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
if (!IsEventSupported(gcd->iType))
return GC_EVENT_ERROR;
- NotifyEventHooks(hHookEvent,wParam,lParam);
+ NotifyEventHooks(hHookEvent, wParam, lParam);
SESSION_INFO *si;
mir_cslock lck(cs);
@@ -418,11 +418,11 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
// Do different things according to type of event
switch (gcd->iType) {
case GC_EVENT_ADDGROUP:
- {
- STATUSINFO *si = ci.SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
- if (si && gce->dwItemData)
- si->hIcon = CopyIcon((HICON)gce->dwItemData);
- }
+ {
+ STATUSINFO *si = ci.SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
+ if (si && gce->dwItemData)
+ si->hIcon = CopyIcon((HICON)gce->dwItemData);
+ }
return 0;
case GC_EVENT_CHUID:
@@ -451,7 +451,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
}
}
break;
-
+
case GC_EVENT_ADDSTATUS:
ci.SM_GiveStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
bIsHighlighted = ci.IsHighlighted(NULL, gce);
@@ -579,6 +579,8 @@ static int ModulesLoaded(WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
// Service creation
+static bool bInited = false;
+
int LoadChatModule(void)
{
InitializeCriticalSection(&cs);
@@ -606,11 +608,16 @@ int LoadChatModule(void)
HookEvent(ME_FONT_RELOAD, FontsChanged);
HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
+
+ bInited = true;
return 0;
}
void UnloadChatModule(void)
{
+ if (!bInited)
+ return;
+
FreeMsgLogBitmaps();
OptionsUnInit();
DeleteCriticalSection(&cs);
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index 3a6ef5d0ac..c0d96658c9 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -107,7 +107,7 @@ static void Log_Append(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, co
static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const TCHAR *fmt, ...)
{
va_list va;
- int lineLen, textCharsCount=0;
+ int lineLen, textCharsCount = 0;
TCHAR* line = (TCHAR*)alloca(8001 * sizeof(TCHAR));
char* d;
@@ -117,10 +117,10 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
line[lineLen] = 0;
va_end(va);
- lineLen = lineLen*20 + 8;
+ lineLen = lineLen * 20 + 8;
if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced);
}
d = *buffer + *cbBufferEnd;
@@ -135,11 +135,11 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
CopyMemory(d, "\\line ", 6);
d += 6;
}
- else if (*line == '%' && !simpleMode ) {
+ else if (*line == '%' && !simpleMode) {
char szTemp[200];
szTemp[0] = '\0';
- switch ( *++line ) {
+ switch (*++line) {
case '\0':
case '%':
*d++ = '%';
@@ -150,7 +150,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
if (g_Settings->bStripFormat || streamData->bStripFormat)
line += 2;
- else if ( line[1] != '\0' && line[2] != '\0') {
+ else if (line[1] != '\0' && line[2] != '\0') {
TCHAR szTemp3[3], c = *line;
int col;
szTemp3[0] = line[1];
@@ -160,15 +160,15 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
col = _ttoi(szTemp3);
col += (OPTIONS_FONTCOUNT + 1);
- mir_snprintf(szTemp, SIZEOF(szTemp), ( c == 'c' ) ? "\\cf%u " : "\\highlight%u ", col);
+ mir_snprintf(szTemp, SIZEOF(szTemp), (c == 'c') ? "\\cf%u " : "\\highlight%u ", col);
}
break;
case 'C':
case 'F':
if (!g_Settings->bStripFormat && !streamData->bStripFormat) {
int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin);
- if ( *line == 'C' )
- mir_snprintf(szTemp, SIZEOF(szTemp), "\\cf%u ", j+1);
+ if (*line == 'C')
+ mir_snprintf(szTemp, SIZEOF(szTemp), "\\cf%u ", j + 1);
else
mir_snprintf(szTemp, SIZEOF(szTemp), "\\highlight0 ");
}
@@ -176,30 +176,30 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
case 'b':
case 'u':
case 'i':
- if (!streamData->bStripFormat )
- mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'u') ? "\\%cl " : "\\%c ", *line );
+ if (!streamData->bStripFormat)
+ mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'u') ? "\\%cl " : "\\%c ", *line);
break;
case 'B':
case 'U':
case 'I':
- if (!streamData->bStripFormat ) {
- mir_snprintf( szTemp, SIZEOF(szTemp), (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line );
- CharLowerA( szTemp );
+ if (!streamData->bStripFormat) {
+ mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line);
+ CharLowerA(szTemp);
}
break;
case 'r':
- if (!streamData->bStripFormat ) {
+ if (!streamData->bStripFormat) {
int index = EventToIndex(streamData->lin);
mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index));
}
break;
}
- if ( szTemp[0] ) {
+ if (szTemp[0]) {
int iLen = lstrlenA(szTemp);
- memcpy( d, szTemp, iLen );
+ memcpy(d, szTemp, iLen);
d += iLen;
}
}
@@ -209,15 +209,15 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
}
else if ((*line == '\\' || *line == '{' || *line == '}') && !streamData->bStripFormat) {
*d++ = '\\';
- *d++ = (char) *line;
+ *d++ = (char)*line;
}
else if (*line > 0 && *line < 128) {
- *d++ = (char) *line;
+ *d++ = (char)*line;
}
else d += sprintf(d, "\\u%u ?", (WORD)*line); //!!!!!!!!!!!
}
- *cbBufferEnd = (int) (d - *buffer);
+ *cbBufferEnd = (int)(d - *buffer);
return textCharsCount;
}
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index 9a5e0fcf83..41cc818af3 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -774,7 +774,7 @@ static char* SM_GetUsers(SESSION_INFO *si)
lstrcpyA(p + pLen + nameLen, " ");
utemp = utemp->next;
}
- while (utemp != NULL);
+ while (utemp != NULL);
return p;
}
@@ -833,7 +833,7 @@ static void MM_IconsChanged(void)
if (ci.OnCreateModule) // recreate icons
ci.OnCreateModule(pTemp);
-
+
pTemp = pTemp->next;
}
}
@@ -1221,8 +1221,8 @@ static TCHAR* UM_FindUserAutoComplete(USERINFO* pUserList, const TCHAR* pszOrigi
USERINFO *pTemp = pUserList;
while (pTemp != NULL) {
if (pTemp->pszNick && my_strstri(pTemp->pszNick, pszOriginal) == pTemp->pszNick)
- if (lstrcmpi(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->pszNick, pszName) < 0))
- pszName = pTemp->pszNick;
+ if (lstrcmpi(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->pszNick, pszName) < 0))
+ pszName = pTemp->pszNick;
pTemp = pTemp->next;
}
@@ -1414,14 +1414,14 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam)
ci.SM_GetUsers = SM_GetUsers;
ci.SM_GetUserFromIndex = SM_GetUserFromIndex;
ci.SM_InvalidateLogDirectories = SM_InvalidateLogDirectories;
-
+
ci.MM_AddModule = MM_AddModule;
ci.MM_FindModule = MM_FindModule;
ci.MM_FixColors = MM_FixColors;
ci.MM_FontsChanged = MM_FontsChanged;
ci.MM_IconsChanged = MM_IconsChanged;
ci.MM_RemoveAll = MM_RemoveAll;
-
+
ci.TM_AddStatus = TM_AddStatus;
ci.TM_FindStatus = TM_FindStatus;
ci.TM_StringToWord = TM_StringToWord;
@@ -1440,7 +1440,7 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam)
ci.UM_RemoveUser = UM_RemoveUser;
ci.UM_RemoveAll = UM_RemoveAll;
ci.UM_CompareItem = UM_CompareItem;
-
+
ci.LM_AddEvent = LM_AddEvent;
ci.LM_TrimLog = LM_TrimLog;
ci.LM_RemoveAll = LM_RemoveAll;
@@ -1450,15 +1450,15 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam)
ci.SetAllOffline = SetAllOffline;
ci.AddEvent = AddEvent;
ci.FindRoom = FindRoom;
-
+
ci.Log_CreateRTF = Log_CreateRTF;
ci.Log_CreateRtfHeader = Log_CreateRtfHeader;
ci.LoadMsgDlgFont = LoadMsgDlgFont;
ci.MakeTimeStamp = MakeTimeStamp;
-
+
ci.DoEventHook = DoEventHook;
ci.DoEventHookAsync = DoEventHookAsync;
-
+
ci.DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
ci.DoTrayIcon = DoTrayIcon;
ci.DoPopup = DoPopup;