feat(GODT-2382): Added bridge-gui settings file with 'UseSoftwareRenderer' value.

This commit is contained in:
Xavier Michelon
2023-02-28 11:30:03 +01:00
parent 4a6460f3ed
commit d7bfee2414
6 changed files with 145 additions and 21 deletions

View File

@ -19,6 +19,7 @@
#include "AppController.h"
#include "QMLBackend.h"
#include "SentryUtils.h"
#include "Settings.h"
#include <bridgepp/GRPC/GRPCClient.h>
#include <bridgepp/Exception/Exception.h>
#include <bridgepp/ProcessMonitor.h>
@ -32,6 +33,7 @@ namespace {
QString const noWindowFlag = "--no-window"; ///< The no-window command-line flag.
}
//****************************************************************************************************************************************************
/// \return The AppController instance.
//****************************************************************************************************************************************************
@ -47,10 +49,19 @@ AppController &app() {
AppController::AppController()
: backend_(std::make_unique<QMLBackend>())
, grpc_(std::make_unique<GRPCClient>())
, log_(std::make_unique<Log>()) {
, log_(std::make_unique<Log>())
, settings_(new Settings) {
}
//****************************************************************************************************************************************************
// The following is in the implementation file because of unique pointers with incomplete types in headers.
// See https://stackoverflow.com/questions/6012157/is-stdunique-ptrt-required-to-know-the-full-definition-of-t
//****************************************************************************************************************************************************
AppController::~AppController() = default;
//****************************************************************************************************************************************************
/// \return The bridge worker, which can be null if the application was run in 'attach' mode (-a command-line switch).
//****************************************************************************************************************************************************
@ -70,15 +81,24 @@ ProcessMonitor *AppController::bridgeMonitor() const {
}
//****************************************************************************************************************************************************
/// \return A reference to the application settings.
//****************************************************************************************************************************************************
Settings &AppController::settings() {
return *settings_;
}
//****************************************************************************************************************************************************
/// \param[in] function The function that caught the exception.
/// \param[in] message The error message.
/// \param[in] details The details for the error.
//****************************************************************************************************************************************************
void AppController::onFatalError(QString const &function, QString const &message, QString const& details) {
void AppController::onFatalError(QString const &function, QString const &message, QString const &details) {
QString fullMessage = QString("%1(): %2").arg(function, message);
if (!details.isEmpty())
if (!details.isEmpty()) {
fullMessage += "\n\nDetails:\n" + details;
}
sentry_uuid_s const uuid = reportSentryException(SENTRY_LEVEL_ERROR, "AppController got notified of a fatal error", "Exception",
fullMessage.toLocal8Bit());
QMessageBox::critical(nullptr, tr("Error"), message);
@ -87,20 +107,23 @@ void AppController::onFatalError(QString const &function, QString const &message
qApp->exit(EXIT_FAILURE);
}
void AppController::restart(bool isCrashing) {
if (!launcher_.isEmpty()) {
QProcess p;
log_->info(QString("Restarting - App : %1 - Args : %2").arg(launcher_,launcherArgs_.join(" ")));
log_->info(QString("Restarting - App : %1 - Args : %2").arg(launcher_, launcherArgs_.join(" ")));
QStringList args = launcherArgs_;
if (isCrashing)
if (isCrashing) {
args.append(noWindowFlag);
}
p.startDetached(launcher_, args);
p.waitForStarted();
}
}
void AppController::setLauncherArgs(const QString& launcher, const QStringList& args){
void AppController::setLauncherArgs(const QString &launcher, const QStringList &args) {
launcher_ = launcher;
launcherArgs_ = args;
}
}