Проблема с регистрацией Singleton в контекст QML
Пытаюсь подключить класс Singleton в контекст QML, который можно было бы использовать и в коде с++.Подключаю следующим образом.
Application.cppp
Application::Application(int &argc, char **argv) : QApplication(argc, argv)
{
engine = new QQmlApplicationEngine(this);
PropertySystem *propertySystem = PropertySystem::GetInstance(this);
ExecAutoDiag *execAutoDiag = new ExecAutoDiag(this);
ExecSwitchPowerSystem *execSwitchPowerSystem = new ExecSwitchPowerSystem(this);
engine->rootContext()->setContextProperty("PropertySystem", propertySystem);
engine->rootContext()->setContextProperty("ExecAutoDiag", execAutoDiag);
engine->rootContext()->setContextProperty("SwitchPowerSystem", execSwitchPowerSystem);
engine->load(QUrl(QLatin1Literal("qrc:/Qml/MainWindow.qml")));
}
PropertySystem.cpp
PropertySystem *PropertySystem::GetInstance(QObject *parent)
{
if (!propertySystemSingleton) {
propertySystemSingleton = new PropertySystem(parent);
}
return propertySystemSingleton;
}
Но при запуске приложение получаю следующее сообщение
The program has unexpectedly finished.