mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
Add crash reporting to Oven
This commit is contained in:
parent
2babda5263
commit
69f1ddcec0
4 changed files with 87 additions and 23 deletions
|
@ -11,6 +11,9 @@ include_hifi_library_headers(script-engine)
|
||||||
|
|
||||||
setup_memory_debugger()
|
setup_memory_debugger()
|
||||||
setup_thread_debugger()
|
setup_thread_debugger()
|
||||||
|
add_crashpad()
|
||||||
|
target_breakpad()
|
||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
package_libraries_for_deployment()
|
package_libraries_for_deployment()
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <image/TextureProcessing.h>
|
#include <image/TextureProcessing.h>
|
||||||
#include <TextureBaker.h>
|
#include <TextureBaker.h>
|
||||||
|
#include <crash-handler/CrashHandler.h>
|
||||||
#include "BakerCLI.h"
|
#include "BakerCLI.h"
|
||||||
|
|
||||||
static const QString CLI_INPUT_PARAMETER = "i";
|
static const QString CLI_INPUT_PARAMETER = "i";
|
||||||
|
@ -38,7 +38,7 @@ OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) :
|
||||||
Q_ARG(QString, _outputUrlParameter.toString()), Q_ARG(QString, _typeParameter));
|
Q_ARG(QString, _outputUrlParameter.toString()), Q_ARG(QString, _typeParameter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OvenCLIApplication::parseCommandLine(int argc, char* argv[]) {
|
OvenCLIApplication::parseResult OvenCLIApplication::parseCommandLine(int argc, char* argv[], bool *enableCrashHandler) {
|
||||||
// parse the command line parameters
|
// parse the command line parameters
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
|
|
||||||
|
@ -50,6 +50,11 @@ void OvenCLIApplication::parseCommandLine(int argc, char* argv[]) {
|
||||||
{ CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER, "Disable texture compression." }
|
{ CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER, "Disable texture compression." }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize.");
|
||||||
|
parser.addOption(forceCrashReportingOption);
|
||||||
|
|
||||||
|
|
||||||
auto versionOption = parser.addVersionOption();
|
auto versionOption = parser.addVersionOption();
|
||||||
auto helpOption = parser.addHelpOption();
|
auto helpOption = parser.addHelpOption();
|
||||||
|
|
||||||
|
@ -65,6 +70,10 @@ void OvenCLIApplication::parseCommandLine(int argc, char* argv[]) {
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(forceCrashReportingOption)) {
|
||||||
|
*enableCrashHandler = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (parser.isSet(versionOption)) {
|
if (parser.isSet(versionOption)) {
|
||||||
parser.showVersion();
|
parser.showVersion();
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
|
@ -75,20 +84,27 @@ void OvenCLIApplication::parseCommandLine(int argc, char* argv[]) {
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parser.isSet(CLI_INPUT_PARAMETER) || !parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
// If one argument is given, so must be the other
|
||||||
|
if ((parser.isSet(CLI_INPUT_PARAMETER) != parser.isSet(CLI_OUTPUT_PARAMETER)) || !parser.positionalArguments().empty()) {
|
||||||
std::cout << "Error: Input and Output not set" << std::endl; // Avoid Qt log spam
|
std::cout << "Error: Input and Output not set" << std::endl; // Avoid Qt log spam
|
||||||
QCoreApplication mockApp(argc, argv); // required for call to showHelp()
|
QCoreApplication mockApp(argc, argv); // required for call to showHelp()
|
||||||
parser.showHelp();
|
parser.showHelp();
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
_inputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER));
|
if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
||||||
_outputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER));
|
_inputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER));
|
||||||
|
_outputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER));
|
||||||
|
|
||||||
_typeParameter = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString();
|
_typeParameter = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString();
|
||||||
|
|
||||||
if (parser.isSet(CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER)) {
|
if (parser.isSet(CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER)) {
|
||||||
qDebug() << "Disabling texture compression";
|
qDebug() << "Disabling texture compression";
|
||||||
TextureBaker::setCompressionEnabled(false);
|
TextureBaker::setCompressionEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OvenCLIApplication::CLIMode;
|
||||||
|
} else {
|
||||||
|
return OvenCLIApplication::GUIMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,12 @@ class OvenCLIApplication : public QCoreApplication, public Oven {
|
||||||
public:
|
public:
|
||||||
OvenCLIApplication(int argc, char* argv[]);
|
OvenCLIApplication(int argc, char* argv[]);
|
||||||
|
|
||||||
static void parseCommandLine(int argc, char* argv[]);
|
enum parseResult {
|
||||||
|
GUIMode,
|
||||||
|
CLIMode
|
||||||
|
};
|
||||||
|
|
||||||
|
static parseResult parseCommandLine(int argc, char* argv[], bool *enableCrashHandler);
|
||||||
|
|
||||||
static OvenCLIApplication* instance() { return dynamic_cast<OvenCLIApplication*>(QCoreApplication::instance()); }
|
static OvenCLIApplication* instance() { return dynamic_cast<OvenCLIApplication*>(QCoreApplication::instance()); }
|
||||||
|
|
||||||
|
|
|
@ -14,24 +14,64 @@
|
||||||
#include <BuildInfo.h>
|
#include <BuildInfo.h>
|
||||||
#include <SettingInterface.h>
|
#include <SettingInterface.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
#include <SettingManager.h>
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
#include <crash-handler/CrashHandler.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
// This needs to be run after a QApplication has been created
|
||||||
|
void postAppInit(QCoreApplication *app, bool enableCrashHandler) {
|
||||||
|
Setting::init();
|
||||||
|
|
||||||
|
auto &ch = CrashHandler::getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QObject::connect(&ch, &CrashHandler::enabledChanged, [](bool enabled) {
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup("Crash");
|
||||||
|
s.setValue("ReportingEnabled", enabled);
|
||||||
|
s.endGroup();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Settings crashSettings;
|
||||||
|
crashSettings.beginGroup("Crash");
|
||||||
|
ch.setEnabled(crashSettings.value("ReportingEnabled").toBool() || enableCrashHandler);
|
||||||
|
ch.startMonitor(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char** argv) {
|
int main (int argc, char** argv) {
|
||||||
setupHifiApplication("Oven");
|
setupHifiApplication("Oven");
|
||||||
|
|
||||||
|
|
||||||
|
DependencyManager::set<Setting::Manager>();
|
||||||
|
|
||||||
|
auto &ch = CrashHandler::getInstance();
|
||||||
|
ch.setPath(argv[0]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// figure out if we're launching our GUI application or just the simple command line interface
|
// figure out if we're launching our GUI application or just the simple command line interface
|
||||||
if (argc > 1) {
|
bool enableCrashHandler = false;
|
||||||
OvenCLIApplication::parseCommandLine(argc, argv);
|
OvenCLIApplication::parseResult res = OvenCLIApplication::parseCommandLine(argc, argv, &enableCrashHandler);
|
||||||
|
|
||||||
// init the settings interface so we can save and load settings
|
switch(res) {
|
||||||
Setting::init();
|
case OvenCLIApplication::CLIMode:
|
||||||
|
{
|
||||||
OvenCLIApplication app { argc, argv };
|
OvenCLIApplication app { argc, argv };
|
||||||
return app.exec();
|
postAppInit(&app, enableCrashHandler);
|
||||||
} else {
|
return app.exec();
|
||||||
// init the settings interface so we can save and load settings
|
break;
|
||||||
Setting::init();
|
}
|
||||||
|
case OvenCLIApplication::GUIMode:
|
||||||
OvenGUIApplication app { argc, argv };
|
{
|
||||||
return app.exec();
|
OvenGUIApplication app { argc, argv };
|
||||||
|
postAppInit(&app, enableCrashHandler);
|
||||||
|
return app.exec();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue