diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-09-07 01:12:53 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-09-07 01:12:53 +0000 |
commit | f1e1fb4bdef878c8fc1564fa418d44e7541a7e83 (patch) | |
tree | 1f3dcb611059e60f2faa5d75d72186aacfff18df /util.cpp | |
parent | d743f0355269e2e03fe3f982e250d07999d72b98 (diff) |
cleanup,
catch some recoverable exceptions and continue
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@148 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.cpp')
-rw-r--r-- | util.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -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)); |