#include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
+#include <osg/Texture>
+#include <osg/BufferObject>
+
#include <cstring>
#include <iostream>
using std::cerr;
#include <Viewer/fgviewer.hxx>
#include "main.hxx"
+#include <Include/version.h>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <GUI/MessageBox.hxx>
#include "fg_os.hxx"
#if defined(SG_MAC)
-#include <Carbon/Carbon.h>
+ #include <GUI/CocoaHelpers.h> // for transformToForegroundApp
+#endif
+
+#if defined(HAVE_CRASHRPT)
+ #include <CrashRpt.h>
+
+bool global_crashRptEnabled = false;
+
#endif
std::string homedir;
#if defined(SG_MAC)
// required so native messages boxes work prior to osgViewer init
// (only needed when not running as a bundled app)
- ProcessSerialNumber sn = { 0, kCurrentProcess };
- TransformProcessType(&sn,kProcessTransformToForegroundApplication);
- SetFrontProcess(&sn);
+ transformToForegroundApp();
#endif
#ifdef PTW32_STATIC_LIB
#endif
_bootstrap_OSInit = 0;
+#if defined(HAVE_CRASHRPT)
+ // Define CrashRpt configuration parameters
+ CR_INSTALL_INFO info;
+ memset(&info, 0, sizeof(CR_INSTALL_INFO));
+ info.cb = sizeof(CR_INSTALL_INFO);
+ info.pszAppName = "FlightGear";
+ info.pszAppVersion = FLIGHTGEAR_VERSION;
+ info.pszEmailSubject = "FlightGear " FLIGHTGEAR_VERSION " crash report";
+ info.pszEmailTo = "fgcrash@goneabitbursar.com";
+ info.pszUrl = "http://fgfs.goneabitbursar.com/crashreporter/crashrpt.php";
+ info.uPriorities[CR_HTTP] = 3;
+ info.uPriorities[CR_SMTP] = 2;
+ info.uPriorities[CR_SMAPI] = 1;
+
+ // Install all available exception handlers
+ info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS;
+
+ // Restart the app on crash
+ info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS;
+
+ // automatically install handlers for all threads
+ info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS;
+
+ // Define the Privacy Policy URL
+ info.pszPrivacyPolicyURL = "http://flightgear.org/crash-privacypolicy.html";
+
+ // Install crash reporting
+ int nResult = crInstall(&info);
+ if(nResult!=0) {
+ 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);
+ crAddProperty("hudson-build-number", buf);
+ }
+#endif
+
#if defined(__FreeBSD__)
// Ignore floating-point exceptions on FreeBSD
signal(SIGFPE, SIG_IGN);
// is possible inside fgExitCleanup
sglog();
+ // similar to above, ensure some static maps inside OSG exist before
+ // we register our at-exit handler, otherwise the statics are gone
+ // when fg_terminate runs, which causes crashes.
+ osg::Texture::getTextureObjectManager(0);
+ osg::GLBufferObjectManager::getGLBufferObjectManager(0);
+
std::set_terminate(fg_terminate);
atexit(fgExitCleanup);
if (fgviewer)
fgviewerMain(argc, argv);
else
fgMainInit(argc, argv);
-
-
+
} catch (const sg_throwable &t) {
std::string info;
if (std::strlen(t.getOrigin()) != 0)
perror("Possible cause");
}
+#if defined(HAVE_CRASHRPT)
+ crUninstall();
+#endif
+
return 0;
}
// so OpenAL device and context are released cleanly
void fgExitCleanup() {
- if (_bootstrap_OSInit != 0)
+ if (_bootstrap_OSInit != 0) {
fgSetMouseCursor(MOUSE_CURSOR_POINTER);
+ fgOSCloseWindow();
+ }
+
// on the common exit path globals is already deleted, and NULL,
// so this only happens on error paths.
delete globals;