mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 16:32:33 +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<GlobalVariables*>();
|
||||||
qRegisterMetaType<ScreenPlayManager*>();
|
qRegisterMetaType<ScreenPlayManager*>();
|
||||||
qRegisterMetaType<Create*>();
|
qRegisterMetaType<Create*>();
|
||||||
qRegisterMetaType<Util*>();
|
qRegisterMetaType<Util*>();
|
||||||
qRegisterMetaType<SDKConnector*>();
|
qRegisterMetaType<SDKConnector*>();
|
||||||
qRegisterMetaType<Settings*>();
|
qRegisterMetaType<Settings*>();
|
||||||
|
|
||||||
@ -21,11 +21,9 @@ App::App()
|
|||||||
qRegisterMetaType<InstalledListFilter*>();
|
qRegisterMetaType<InstalledListFilter*>();
|
||||||
qRegisterMetaType<MonitorListModel*>();
|
qRegisterMetaType<MonitorListModel*>();
|
||||||
qRegisterMetaType<ProfileListModel*>();
|
qRegisterMetaType<ProfileListModel*>();
|
||||||
}
|
|
||||||
|
|
||||||
void App::init()
|
|
||||||
{
|
|
||||||
QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
|
QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
|
||||||
|
|
||||||
// Qt < 6.0 needs this init QtWebEngine
|
// Qt < 6.0 needs this init QtWebEngine
|
||||||
QtWebEngine::initialize();
|
QtWebEngine::initialize();
|
||||||
|
|
||||||
@ -36,24 +34,19 @@ void App::init()
|
|||||||
m_profileListModel = make_shared<ProfileListModel>(m_globalVariables);
|
m_profileListModel = make_shared<ProfileListModel>(m_globalVariables);
|
||||||
m_sdkConnector = make_shared<SDKConnector>();
|
m_sdkConnector = make_shared<SDKConnector>();
|
||||||
m_settings = make_shared<Settings>(m_globalVariables);
|
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);
|
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
|
// Instead of setting "renderType: Text.NativeRendering" every time
|
||||||
// we can set it here once :)
|
// we can set it here once :)
|
||||||
QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
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();
|
m_installedListModel->init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#include "src/settings.h"
|
#include "src/settings.h"
|
||||||
#include "src/util.h"
|
#include "src/util.h"
|
||||||
|
|
||||||
using std::make_shared,
|
using std::make_unique,
|
||||||
|
std::unique_ptr,
|
||||||
|
std::make_shared,
|
||||||
std::shared_ptr,
|
std::shared_ptr,
|
||||||
ScreenPlay::Util,
|
ScreenPlay::Util,
|
||||||
ScreenPlay::InstalledListModel,
|
ScreenPlay::InstalledListModel,
|
||||||
@ -53,7 +55,6 @@ class App : public QObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit App();
|
explicit App();
|
||||||
void init();
|
|
||||||
|
|
||||||
static App* instance()
|
static App* instance()
|
||||||
{
|
{
|
||||||
@ -212,14 +213,12 @@ public slots:
|
|||||||
emit sdkConnectorChanged(m_sdkConnector.get());
|
emit sdkConnectorChanged(m_sdkConnector.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
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<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<Settings> m_settings;
|
||||||
shared_ptr<SDKConnector> m_sdkConnector;
|
shared_ptr<SDKConnector> m_sdkConnector;
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Needs to be created before
|
|
||||||
App* app = App::instance();
|
|
||||||
|
|
||||||
QGuiApplication qtGuiApp(argc, argv);
|
QGuiApplication qtGuiApp(argc, argv);
|
||||||
|
|
||||||
qmlRegisterSingletonType<App>("ScreenPlay", 1, 0, "ScreenPlay", [](QQmlEngine* engine, QJSEngine*) -> QObject* {
|
qmlRegisterSingletonType<App>("ScreenPlay", 1, 0, "ScreenPlay", [](QQmlEngine* engine, QJSEngine*) -> QObject* {
|
||||||
@ -14,7 +11,13 @@ int main(int argc, char* argv[])
|
|||||||
return App::instance();
|
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();
|
return qtGuiApp.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user