From f1e1fb4bdef878c8fc1564fa418d44e7541a7e83 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Tue, 7 Sep 2010 01:12:53 +0000 Subject: cleanup, catch some recoverable exceptions and continue git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@148 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- util.cpp | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'util.cpp') diff --git a/util.cpp b/util.cpp index 2a3e964afb..ef2e68344d 100644 --- a/util.cpp +++ b/util.cpp @@ -79,7 +79,7 @@ instance_of_cinit; void RandAddSeed() { // Seed with CPU performance counter - int64 nCounter = PerformanceCounter(); + int64 nCounter = GetPerformanceCounter(); RAND_add(&nCounter, sizeof(nCounter), 1.5); memset(&nCounter, 0, sizeof(nCounter)); } @@ -499,23 +499,47 @@ void FormatException(char* pszMessage, std::exception* pex, const char* pszThrea void LogException(std::exception* pex, const char* pszThread) { - char pszMessage[1000]; + char pszMessage[10000]; FormatException(pszMessage, pex, pszThread); printf("\n%s", pszMessage); } void PrintException(std::exception* pex, const char* pszThread) { - char pszMessage[1000]; + char pszMessage[10000]; FormatException(pszMessage, pex, pszThread); printf("\n\n************************\n%s\n", pszMessage); fprintf(stderr, "\n\n************************\n%s\n", pszMessage); + strMiscWarning = pszMessage; #ifdef GUI if (wxTheApp && !fDaemon) - MyMessageBox(pszMessage, "Error", wxOK | wxICON_ERROR); + MyMessageBox(pszMessage, "Bitcoin", wxOK | wxICON_ERROR); #endif throw; - //DebugBreak(); +} + +void ThreadOneMessageBox(string strMessage) +{ + // Skip message boxes if one is already open + static bool fMessageBoxOpen; + if (fMessageBoxOpen) + return; + fMessageBoxOpen = true; + ThreadSafeMessageBox(strMessage, "Bitcoin", wxOK | wxICON_EXCLAMATION); + fMessageBoxOpen = false; +} + +void PrintExceptionContinue(std::exception* pex, const char* pszThread) +{ + char pszMessage[10000]; + FormatException(pszMessage, pex, pszThread); + printf("\n\n************************\n%s\n", pszMessage); + fprintf(stderr, "\n\n************************\n%s\n", pszMessage); + strMiscWarning = pszMessage; +#ifdef GUI + if (wxTheApp && !fDaemon) + boost::thread(bind(ThreadOneMessageBox, string(pszMessage))); +#endif } @@ -749,7 +773,7 @@ void AddTimeData(unsigned int ip, int64 nTime) if (!fMatch && !fDone) { fDone = true; - string strMessage = _("Warning: Check your system date and time, you may not be able to generate or receive the most recent blocks!"); + string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly."); strMiscWarning = strMessage; printf("*** %s\n", strMessage.c_str()); boost::thread(bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1)); -- cgit v1.2.3