Merge branch '0.5.x' into 0.6.0.x
[novacoin.git] / src / qt / bitcoin.cpp
index 71e2daf..c7f0092 100644 (file)
@@ -9,6 +9,7 @@
 #include "headers.h"
 #include "init.h"
 #include "qtipcserver.h"
+#include "util.h"
 
 #include <QApplication>
 #include <QMessageBox>
@@ -40,7 +41,7 @@ int ThreadSafeMessageBox(const std::string& message, const std::string& caption,
 
     if (modal)
         while (!guiref)
-            sleep(1);
+            Sleep(1000);
 
     // Message from network thread
     if(guiref)
@@ -130,6 +131,15 @@ std::string _(const char* psz)
     return QCoreApplication::translate("bitcoin-core", psz).toStdString();
 }
 
+/* Handle runaway exceptions. Shows a message box with the problem and quits the program.
+ */
+static void handleRunawayException(std::exception *e)
+{
+    PrintExceptionContinue(e, "Runaway exception");
+    QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occured. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
+    exit(1);
+}
+
 #ifndef BITCOIN_QT_TEST
 int main(int argc, char *argv[])
 {
@@ -286,9 +296,9 @@ int main(int argc, char *argv[])
             return 1;
         }
     } catch (std::exception& e) {
-        PrintException(&e, "Runaway exception");
+        handleRunawayException(&e);
     } catch (...) {
-        PrintException(NULL, "Runaway exception");
+        handleRunawayException(NULL);
     }
     return 0;
 }