mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-15 06:52:34 +02:00
Fix crash on exit which was caused by trying to delete the QQmlApplicationEngine. I still unsure about the reason of the crash...
This commit is contained in:
parent
ef623a8b0b
commit
77a48d11a5
@ -13,7 +13,7 @@ App::App()
|
||||
qRegisterMetaType<GlobalVariables*>();
|
||||
qRegisterMetaType<ScreenPlayManager*>();
|
||||
qRegisterMetaType<Create*>();
|
||||
qRegisterMetaType<Util*>();
|
||||
qRegisterMetaType<Util*>();
|
||||
qRegisterMetaType<SDKConnector*>();
|
||||
qRegisterMetaType<Settings*>();
|
||||
|
||||
@ -21,11 +21,9 @@ App::App()
|
||||
qRegisterMetaType<InstalledListFilter*>();
|
||||
qRegisterMetaType<MonitorListModel*>();
|
||||
qRegisterMetaType<ProfileListModel*>();
|
||||
}
|
||||
|
||||
void App::init()
|
||||
{
|
||||
QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
|
||||
|
||||
// Qt < 6.0 needs this init QtWebEngine
|
||||
QtWebEngine::initialize();
|
||||
|
||||
@ -36,24 +34,19 @@ void App::init()
|
||||
m_profileListModel = make_shared<ProfileListModel>(m_globalVariables);
|
||||
m_sdkConnector = make_shared<SDKConnector>();
|
||||
m_settings = make_shared<Settings>(m_globalVariables);
|
||||
m_create = make_shared<Create>(m_globalVariables);
|
||||
m_util = make_shared<Util>(new QNetworkAccessManager(this));
|
||||
m_screenPlayManager = make_shared<ScreenPlayManager>(m_globalVariables, m_monitorListModel, m_sdkConnector);
|
||||
|
||||
QObject::connect(m_settings.get(), &Settings::resetInstalledListmodel, m_installedListModel.get(), &InstalledListModel::reset);
|
||||
|
||||
m_create = std::make_shared<Create>(m_globalVariables);
|
||||
|
||||
mainWindowEngine = std::make_unique<QQmlApplicationEngine>();
|
||||
m_util = std::make_shared<Util>(mainWindowEngine->networkAccessManager());
|
||||
|
||||
m_screenPlayManager = std::make_shared<ScreenPlayManager>(m_globalVariables, m_monitorListModel, m_sdkConnector);
|
||||
|
||||
mainWindowEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
|
||||
// Instead of setting "renderType: Text.NativeRendering" every time
|
||||
// we can set it here once :)
|
||||
QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
||||
|
||||
// Set visible if the -silent parameter was not set
|
||||
if (!QGuiApplication::instance()->arguments().contains("-silent")) {
|
||||
m_settings->setMainWindowVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_installedListModel->init();
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,9 @@
|
||||
#include "src/settings.h"
|
||||
#include "src/util.h"
|
||||
|
||||
using std::make_shared,
|
||||
using std::make_unique,
|
||||
std::unique_ptr,
|
||||
std::make_shared,
|
||||
std::shared_ptr,
|
||||
ScreenPlay::Util,
|
||||
ScreenPlay::InstalledListModel,
|
||||
@ -53,7 +55,6 @@ class App : public QObject {
|
||||
|
||||
public:
|
||||
explicit App();
|
||||
void init();
|
||||
|
||||
static App* instance()
|
||||
{
|
||||
@ -212,14 +213,12 @@ public slots:
|
||||
emit sdkConnectorChanged(m_sdkConnector.get());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::unique_ptr<QQmlApplicationEngine> mainWindowEngine;
|
||||
shared_ptr<Create> m_create;
|
||||
shared_ptr<ScreenPlayManager> m_screenPlayManager;
|
||||
shared_ptr<Util> m_util;
|
||||
|
||||
shared_ptr<GlobalVariables> m_globalVariables;
|
||||
shared_ptr<ScreenPlayManager> m_screenPlayManager;
|
||||
shared_ptr<Create> m_create;
|
||||
shared_ptr<Util> m_util;
|
||||
shared_ptr<Settings> m_settings;
|
||||
shared_ptr<SDKConnector> m_sdkConnector;
|
||||
|
||||
|
@ -4,9 +4,6 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Needs to be created before
|
||||
App* app = App::instance();
|
||||
|
||||
QGuiApplication qtGuiApp(argc, argv);
|
||||
|
||||
qmlRegisterSingletonType<App>("ScreenPlay", 1, 0, "ScreenPlay", [](QQmlEngine* engine, QJSEngine*) -> QObject* {
|
||||
@ -14,7 +11,13 @@ int main(int argc, char* argv[])
|
||||
return App::instance();
|
||||
});
|
||||
|
||||
app->init();
|
||||
QQmlApplicationEngine m_mainWindowEngine;
|
||||
m_mainWindowEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
|
||||
// Set visible if the -silent parameter was not set
|
||||
if (!QGuiApplication::instance()->arguments().contains("-silent")) {
|
||||
App::instance()->settings()->setMainWindowVisible(true);
|
||||
}
|
||||
|
||||
return qtGuiApp.exec();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user