From e2760a3c40e97c14bee952f39b4381cd0b0c939c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Aug 2013 20:55:03 +0000 Subject: crash fix git-svn-id: http://svn.miranda-ng.org/main/trunk@5619 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/StatusPlugins/KeepStatus/keepstatus.cpp | 39 ++++++++++++------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'plugins/StatusPlugins') diff --git a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp index d2f58536bb..bad7eeebe4 100644 --- a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp +++ b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp @@ -909,44 +909,41 @@ static VOID CALLBACK CheckContinueslyTimer(HWND hwnd, UINT message, UINT_PTR idE } // =============== popup ====================== +static TCHAR* GetHumanName(LPARAM lParam) +{ + PROTOACCOUNT *ProtoAccount = ProtoGetAccount((char*)lParam); + return (ProtoAccount != NULL) ? ProtoAccount->tszAccountName : TranslateT("Protocol"); +} + static int ProcessPopup(int reason, LPARAM lParam) { HICON hIcon = NULL; - PROTOACCOUNT *ProtoAccount; - TCHAR text[MAX_SECONDLINE], ProtoName[128] = {0}; + TCHAR text[MAX_SECONDLINE]; if ( !db_get_b(NULL, MODULENAME, SETTING_SHOWCONNECTIONPOPUPS,FALSE) || !ServiceExists(MS_POPUP_ADDPOPUP)) return -1; - // Get human readable account name. - if (lParam) - if (ProtoAccount = ProtoGetAccount((char*)lParam)) - _tcscpy(ProtoName, ProtoAccount->tszAccountName); - switch(reason) { case KS_CONN_STATE_OTHERLOCATION: // lParam = 1 proto if (!db_get_b(NULL, MODULENAME, SETTING_PUOTHER, TRUE)) return -1; hIcon = LoadSkinnedProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE); - mir_sntprintf(text, SIZEOF(text), TranslateT("%s connected from another location"), ProtoName); + mir_sntprintf(text, SIZEOF(text), TranslateT("%s connected from another location"), GetHumanName(lParam)); break; case KS_CONN_STATE_LOGINERROR: // lParam = 1 proto - /******************* - rethink this - ********************/ if (!db_get_b(NULL, MODULENAME, SETTING_PUOTHER, TRUE)) return -1; - - hIcon = LoadSkinnedProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE); - if ( db_get_b(NULL, MODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_CANCEL) - mir_sntprintf(text, SIZEOF(text), TranslateT("%s login error, cancel reconnecting"), ProtoName); - else if ( db_get_b(NULL, MODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_SETDELAY) - mir_sntprintf(text, SIZEOF(text), TranslateT("%s login error (next retry (%d) in %d s)"), ProtoName, retryCount+1, db_get_dw(NULL, MODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY)); - else - return -1; - + else { + hIcon = LoadSkinnedProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE); + if ( db_get_b(NULL, MODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_CANCEL) + mir_sntprintf(text, SIZEOF(text), TranslateT("%s login error, cancel reconnecting"), GetHumanName(lParam)); + else if ( db_get_b(NULL, MODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_SETDELAY) + mir_sntprintf(text, SIZEOF(text), TranslateT("%s login error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount+1, db_get_dw(NULL, MODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY)); + else + return -1; + } break; case KS_CONN_STATE_LOST: // lParam = 1 proto, or NULL @@ -955,7 +952,7 @@ static int ProcessPopup(int reason, LPARAM lParam) if (lParam) { // Указатель на имя модуля. hIcon = LoadSkinnedProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE); - mir_sntprintf(text, SIZEOF(text), TranslateT("%s status error (next retry (%d) in %d s)"), ProtoName, retryCount+1, currentDelay/1000); + mir_sntprintf(text, SIZEOF(text), TranslateT("%s status error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount+1, currentDelay/1000); } else mir_sntprintf(text, SIZEOF(text), TranslateT("Status error (next retry (%d) in %d s)"), retryCount+1, currentDelay/1000); break; -- cgit v1.2.3