diff --git a/checkin_notes b/checkin_notes index 975ca9588c..86f6d786fb 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5920,3 +5920,16 @@ David 13 June 2006 user/ am_set_info.php team_quit_action.php + +Rom 14 June 2006 + - Bug Fix: Fix crashing condition with Unicode BOINC Manager. + (From Frank S. Thomas) + - Reduce duplicate code in diagnostics.C. + - Change screensaver logging mechinisms. + + client/win/ + win_screensaver.cpp + clientgui/ + MainFrame.cpp + lib/ + diagnostics.C, .h diff --git a/client/win/win_screensaver.cpp b/client/win/win_screensaver.cpp index efbffc27fe..8d8e322c4c 100755 --- a/client/win/win_screensaver.cpp +++ b/client/win/win_screensaver.cpp @@ -32,8 +32,8 @@ #include #include -#include "diagnostics.h" #include "boinc_ss.h" +#include "diagnostics.h" #include "win_screensaver.h" #include "util.h" @@ -69,23 +69,22 @@ INT WINAPI WinMain( HKEY hKey; -#ifdef _DEBUG - // Initialize Diagnostics when compiled for debug + // Initialize Diagnostics retval = diagnostics_init ( BOINC_DIAG_DUMPCALLSTACKENABLED | BOINC_DIAG_HEAPCHECKENABLED | BOINC_DIAG_MEMORYLEAKCHECKENABLED | - BOINC_DIAG_ARCHIVESTDERR | - BOINC_DIAG_REDIRECTSTDERR | - BOINC_DIAG_TRACETOSTDERR, + BOINC_DIAG_ARCHIVESTDOUT | + BOINC_DIAG_REDIRECTSTDOUTOVERWRITE | + BOINC_DIAG_REDIRECTSTDERROVERWRITE | + BOINC_DIAG_TRACETOSTDOUT, "stdoutscr", "stderrscr" - ); + ); if (retval) { BOINCTRACE("WinMain - BOINC Screensaver Diagnostic Error '%d'\n", retval); MessageBox(NULL, NULL, "BOINC Screensaver Diagnostic Error", MB_OK); } -#endif // Figure out if we're on Win9x OSVERSIONINFO osvi; diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 47015ceb40..f859278385 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -366,11 +366,11 @@ bool CMainFrame::CreateMenu() { } else { strMenuName.Printf( _("&Synchronize with %s"), - ami.acct_mgr_name.c_str() + wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str() ); strMenuDescription.Printf( _("Get current settings from %s"), - ami.acct_mgr_name.c_str() + wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str() ); menuTools->Append( ID_TOOLSAMUPDATENOW, @@ -448,7 +448,7 @@ bool CMainFrame::CreateMenu() { if (is_acct_mgr_detected) { strMenuName.Printf( _("&Defect from %s"), - ami.acct_mgr_name.c_str() + wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str() ); menuAdvanced->Append( ID_ADVANCEDAMDEFECT, @@ -1220,7 +1220,7 @@ void CMainFrame::OnAccountManagerDetach(wxCommandEvent& WXUNUSED(event)) { strTitle.Printf( _("BOINC Manager - Detach from %s"), - ami.acct_mgr_name.c_str() + wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str() ); strMessage.Printf( _("If you defect from %s,\n" @@ -1228,8 +1228,8 @@ void CMainFrame::OnAccountManagerDetach(wxCommandEvent& WXUNUSED(event)) { "but you'll have to manage projects manually.\n" "\n" "Do you want to defect from %s?"), - ami.acct_mgr_name.c_str(), - ami.acct_mgr_name.c_str() + wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str(), + wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str() ); iAnswer = ::wxMessageBox( diff --git a/lib/diagnostics.C b/lib/diagnostics.C index b00d02f0f7..431018ccc4 100644 --- a/lib/diagnostics.C +++ b/lib/diagnostics.C @@ -57,6 +57,16 @@ #define MAX_STDOUT_FILE_SIZE 2048*1024 +#ifdef _WIN32 +int __cdecl boinc_message_reporting(int reportType, char *szMsg, int *retVal); + +static _CrtMemState start_snapshot; +static _CrtMemState finish_snapshot; +static _CrtMemState difference_snapshot; + +#endif + + static int diagnostics_initialized = false; static int flags; static char stdout_log[256]; @@ -72,14 +82,6 @@ static char symstore[256]; static int aborted_via_gui; -#ifdef _WIN32 -int __cdecl boinc_message_reporting(int reportType, char *szMsg, int *retVal); -_CrtMemState start_snapshot; -_CrtMemState finish_snapshot; -_CrtMemState difference_snapshot; -#endif - - // stub function for initializing the diagnostics environment. // int boinc_init_diagnostics(int _flags) { @@ -487,13 +489,20 @@ int __cdecl boinc_message_reporting(int reportType, char *szMsg, int *retVal){ // void boinc_trace(const char *pszFormat, ...) { static char szBuffer[4096]; + static char szDate[64]; + static char szTime[64]; // Trace messages should only be reported if running as a standalone // application or told too. if ((flags & BOINC_DIAG_TRACETOSTDERR) || - (flags & BOINC_DIAG_TRACETOSTDOUT)) { + (flags & BOINC_DIAG_TRACETOSTDOUT)) { memset(szBuffer, 0, sizeof(szBuffer)); + memset(szDate, 0, sizeof(szDate)); + memset(szTime, 0, sizeof(szTime)); + + strdate(szDate); + strtime(szTime); va_list ptr; va_start(ptr, pszFormat); @@ -502,30 +511,11 @@ void boinc_trace(const char *pszFormat, ...) { va_end(ptr); - _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "TRACE[%d]: %s", GetCurrentThreadId(), szBuffer); + _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "[%s %s] TRACE [%d]: %s", szDate, szTime, GetCurrentThreadId(), szBuffer); } } -// Converts the BOINCINFO macro into a single string and report it -// to stderr so it can be reported via the normal means. -// -void boinc_info_debug(const char *pszFormat, ...){ - static char szBuffer[4096]; - - memset(szBuffer, 0, sizeof(szBuffer)); - - va_list ptr; - va_start(ptr, pszFormat); - - vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr); - - va_end(ptr); - - _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "%s", szBuffer); -} - - #endif // _DEBUG @@ -540,6 +530,8 @@ void boinc_info_debug(const char *pszFormat, ...){ // void boinc_trace(const char *pszFormat, ...) { static char szBuffer[4096]; + static char szDate[64]; + static char szTime[64]; // Trace messages should only be reported if running as a standalone // application or told too. @@ -547,6 +539,11 @@ void boinc_trace(const char *pszFormat, ...) { (flags & BOINC_DIAG_TRACETOSTDOUT)) { memset(szBuffer, 0, sizeof(szBuffer)); + memset(szDate, 0, sizeof(szDate)); + memset(szTime, 0, sizeof(szTime)); + + strdate(szDate); + strtime(szTime); va_list ptr; va_start(ptr, pszFormat); @@ -556,37 +553,17 @@ void boinc_trace(const char *pszFormat, ...) { va_end(ptr); if (flags & BOINC_DIAG_TRACETOSTDERR) { - fprintf(stderr, "TRACE: %s", szBuffer); + fprintf(stderr, "[%s %s] TRACE: %s", szDate, szTime, szBuffer); fflush(stderr); } if (flags & BOINC_DIAG_TRACETOSTDOUT) { - fprintf(stdout, "TRACE: %s", szBuffer); + fprintf(stdout, "[%s %s] TRACE: %s", szDate, szTime, szBuffer); fflush(stdout); } } } - -// Converts the BOINCINFO macro into a single string and report it -// to stderr so it can be reported via the normal means. -// -void boinc_info_debug(const char *pszFormat, ...){ - static char szBuffer[4096]; - - memset(szBuffer, 0, sizeof(szBuffer)); - - va_list ptr; - va_start(ptr, pszFormat); - - vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr); - - va_end(ptr); - - fprintf(stderr, "%s", szBuffer); - fflush(stderr); -} - #endif // _DEBUG @@ -678,7 +655,7 @@ void boinc_catch_signal(int signal) { // Converts the BOINCINFO macro into a single string and report it // to stderr so it can be reported via the normal means. // -void boinc_info_release(const char *pszFormat, ...){ +void boinc_info(const char *pszFormat, ...){ #ifdef BOINC_INFOMSGS static char szBuffer[4096]; static char szDate[64]; @@ -698,7 +675,17 @@ void boinc_info_release(const char *pszFormat, ...){ va_end(ptr); - fprintf(stderr, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer); +#if defined(_WIN32) && defined(_DEBUG) + _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer); +#else + if (flags & BOINC_DIAG_TRACETOSTDERR) { + fprintf(stderr, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer); + } + + if (flags & BOINC_DIAG_TRACETOSTDOUT) { + fprintf(stdout, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer); + } +#endif #endif } diff --git a/lib/diagnostics.h b/lib/diagnostics.h index 43724e49e2..976d4719bd 100644 --- a/lib/diagnostics.h +++ b/lib/diagnostics.h @@ -123,8 +123,7 @@ extern void boinc_set_signal_handler_force(int sig, void(*handler)(int)); // These functions are used to log the various messages that are // defined in the BOINC Diagnostics Library extern void boinc_trace(const char *pszFormat, ...); -extern void boinc_info_debug(const char *pszFormat, ...); -extern void boinc_info_release(const char *pszFormat, ...); +extern void boinc_info(const char *pszFormat, ...); #ifdef __cplusplus @@ -149,7 +148,6 @@ extern void boinc_info_release(const char *pszFormat, ...); #define BOINCASSERT(expr) wxASSERT(expr) #define BOINCTRACE wxLogDebug -#define BOINCINFO boinc_info_release #elif defined(_CONSOLE) @@ -158,7 +156,6 @@ extern void boinc_info_release(const char *pszFormat, ...); #define BOINCASSERT(expr) _ASSERTE(expr) #define BOINCTRACE boinc_trace -#define BOINCINFO boinc_info_debug #endif // _CONSOLE @@ -167,11 +164,9 @@ extern void boinc_info_release(const char *pszFormat, ...); #if defined(__MINGW32__) || defined(__CYGWIN32__) #define BOINCASSERT(expr) #define BOINCTRACE(...) -#define BOINCINFO boinc_info_release #else // __MINGW32__ #define BOINCASSERT(expr) __noop #define BOINCTRACE __noop -#define BOINCINFO boinc_info_release #endif // __MINGW32__ #endif // _DEBUG @@ -185,13 +180,11 @@ extern void boinc_info_release(const char *pszFormat, ...); #define BOINCASSERT assert #define BOINCTRACE boinc_trace -#define BOINCINFO boinc_info_debug #else // _DEBUG #define BOINCASSERT(expr) #define BOINCTRACE(...) -#define BOINCINFO boinc_info_release #endif // _DEBUG @@ -212,7 +205,7 @@ extern void boinc_info_release(const char *pszFormat, ...); #endif #ifndef BOINCINFO -#define BOINCINFO +#define BOINCINFO boinc_info #endif #endif