mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
WIP: fix bridge-gui linux crash.
QGuiApplication is now allocated on the stack in main() to avoid a crash on linux.
This commit is contained in:
@ -26,26 +26,19 @@
|
|||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// // initialize the Qt application.
|
/// // initialize the Qt application.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
std::shared_ptr<QGuiApplication> initQtApplication(int argc, char *argv[])
|
void initQtApplication()
|
||||||
{
|
{
|
||||||
if (QSysInfo::productType() != "windows")
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
|
||||||
|
|
||||||
QString const qsgInfo = QProcessEnvironment::systemEnvironment().value("QSG_INFO");
|
QString const qsgInfo = QProcessEnvironment::systemEnvironment().value("QSG_INFO");
|
||||||
if ((!qsgInfo.isEmpty()) && (qsgInfo != "0"))
|
if ((!qsgInfo.isEmpty()) && (qsgInfo != "0"))
|
||||||
QLoggingCategory::setFilterRules("qt.scenegraph.general=true");
|
QLoggingCategory::setFilterRules("qt.scenegraph.general=true");
|
||||||
|
|
||||||
auto app = std::make_shared<QGuiApplication>(argc, argv);
|
|
||||||
|
|
||||||
/// \todo GODT-1670 Get version from go backend.
|
/// \todo GODT-1670 Get version from go backend.
|
||||||
QGuiApplication::setApplicationName("Proton Mail Bridge");
|
QGuiApplication::setApplicationName("Proton Mail Bridge");
|
||||||
QGuiApplication::setApplicationVersion("3.0");
|
QGuiApplication::setApplicationVersion("3.0");
|
||||||
QGuiApplication::setOrganizationName("Proton AG");
|
QGuiApplication::setOrganizationName("Proton AG");
|
||||||
QGuiApplication::setOrganizationDomain("proton.ch");
|
QGuiApplication::setOrganizationDomain("proton.ch");
|
||||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
}
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
@ -160,9 +153,13 @@ void closeBridgeApp()
|
|||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::shared_ptr<QGuiApplication> guiApp = initQtApplication(argc, argv);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (QSysInfo::productType() != "windows")
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||||
|
|
||||||
|
QGuiApplication guiApp(argc, argv);
|
||||||
|
initQtApplication();
|
||||||
|
|
||||||
bool attach = false;
|
bool attach = false;
|
||||||
QString exePath;
|
QString exePath;
|
||||||
@ -177,11 +174,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
std::unique_ptr<QQmlComponent> rootComponent(createRootQmlComponent(engine));
|
std::unique_ptr<QQmlComponent> rootComponent(createRootQmlComponent(engine));
|
||||||
std::unique_ptr<QObject> rootObject(rootComponent->beginCreate(engine.rootContext()));
|
std::unique_ptr<QObject>rootObject(rootComponent->create(engine.rootContext()));
|
||||||
if (!rootObject)
|
if (!rootObject)
|
||||||
throw Exception("Could not create root object.");
|
throw Exception("Could not create root object.");
|
||||||
rootObject->setProperty("backend", QVariant::fromValue(&app().backend()));
|
|
||||||
rootComponent->completeCreate();
|
|
||||||
|
|
||||||
BridgeMonitor *bridgeMonitor = app().bridgeMonitor();
|
BridgeMonitor *bridgeMonitor = app().bridgeMonitor();
|
||||||
bool bridgeExited = false;
|
bool bridgeExited = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user