]> git.mxchange.org Git - flightgear.git/commitdiff
CrashRpt tweaks, checking.
authorJames Turner <zakalawe@mac.com>
Wed, 22 Jan 2014 22:33:30 +0000 (22:33 +0000)
committerJames Turner <zakalawe@mac.com>
Wed, 22 Jan 2014 22:33:30 +0000 (22:33 +0000)
- show a message box if setup fails
- log setup status

src/GUI/MessageBox.cxx
src/Main/bootstrap.cxx
src/Main/main.cxx

index 93563c66d96b800b096f668d0a020c9d3730948c..d57d89e105de73b519059be2afcadaec790f8609 100644 (file)
@@ -37,6 +37,10 @@ namespace {
 
 bool isCanvasImplementationRegistered()
 {
+       if (!globals) {
+               return false;
+       }
+
     SGCommandMgr* cmd = globals->get_commands();
     return (cmd->getCommand("canvas-message-box") != NULL);
 }
@@ -46,7 +50,7 @@ bool isCanvasImplementationRegistered()
 HWND getMainViewerHWND()
 {
        osgViewer::Viewer::Windows windows;
-       if (!globals->get_renderer() || !globals->get_renderer()->getViewer()) {
+       if (!globals || !globals->get_renderer() || !globals->get_renderer()->getViewer()) {
                return 0;
        }
 
index da45058d946275152913d10734bcd0cf9b1f2b0b..326401a7573b3e556d4f93d43de53af31d470afa 100644 (file)
@@ -73,6 +73,9 @@ using std::endl;
 
 #if defined(HAVE_CRASHRPT)
        #include <CrashRpt.h>
+
+bool global_crashRptEnabled = false;
+
 #endif
 
 std::string homedir;
@@ -210,8 +213,14 @@ int main ( int argc, char **argv )
        // Install crash reporting
        int nResult = crInstall(&info);    
        if(nResult!=0) {
-               std::cerr << "failed to install crash reporting engine" << std::endl;
+               char buf[1024];
+               crGetLastErrorMsg(buf, 1024);
+               flightgear::modalMessageBox("CrashRpt setup failed", 
+                       "Failed to setup crash-reporting engine, check the installation is not damaged.",
+                       buf);
        } else {
+               global_crashRptEnabled = true;
+
                crAddProperty("hudson-build-id", HUDSON_BUILD_ID);
                char buf[16];
                ::snprintf(buf, 16, "%d", HUDSON_BUILD_NUMBER);
index 2d3c6485ad340ea39a4a8a05b41d66b89f4a339e..c146a14c1a5e0cb524c8692646ffed96f166251f 100644 (file)
 
 #if defined(HAVE_CRASHRPT)
        #include <CrashRpt.h>
+
+// defined in bootstrap.cxx
+extern bool global_crashRptEnabled;
+
 #endif
 
 // Class references
@@ -346,8 +350,12 @@ static void logToFile()
     sglog().logToFile(logPath, SG_ALL, SG_INFO);
 
 #if defined(HAVE_CRASHRPT)
-       crAddFile2(logPath.c_str(), NULL, "FlightGear Log File", CR_AF_MAKE_FILE_COPY);
-       SG_LOG( SG_GENERAL, SG_INFO, "CrashRpt enabled");
+       if (global_crashRptEnabled) {
+               crAddFile2(logPath.c_str(), NULL, "FlightGear Log File", CR_AF_MAKE_FILE_COPY);
+               SG_LOG( SG_GENERAL, SG_INFO, "CrashRpt enabled");
+       } else {
+               SG_LOG(SG_GENERAL, SG_WARN, "CrashRpt enabled at compile time but failed to install");
+       }
 #endif
 }