From 45d67406a4f38e9687fb99278e9348ed60976621 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 22 Jan 2014 22:33:30 +0000 Subject: [PATCH] CrashRpt tweaks, checking. - show a message box if setup fails - log setup status --- src/GUI/MessageBox.cxx | 6 +++++- src/Main/bootstrap.cxx | 11 ++++++++++- src/Main/main.cxx | 12 ++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/GUI/MessageBox.cxx b/src/GUI/MessageBox.cxx index 93563c66d..d57d89e10 100644 --- a/src/GUI/MessageBox.cxx +++ b/src/GUI/MessageBox.cxx @@ -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; } diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index da45058d9..326401a75 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -73,6 +73,9 @@ using std::endl; #if defined(HAVE_CRASHRPT) #include + +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); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 2d3c6485a..c146a14c1 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -35,6 +35,10 @@ #if defined(HAVE_CRASHRPT) #include + +// 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 }