core: avoid crashes lol

This commit is contained in:
Vaxry 2024-10-16 14:51:58 +01:00
parent 2c97f97336
commit e714ed59ac
4 changed files with 17 additions and 11 deletions

View File

@ -5,7 +5,8 @@
#include <QSocketNotifier>
class CSigDaemon : public QObject {
Q_OBJECT;
Q_OBJECT;
public:
CSigDaemon(QObject* parent = nullptr);

View File

@ -37,8 +37,14 @@ bool CAgent::start() {
void CAgent::resetAuthState() {
if (authState.authing) {
authState.authing = false;
authState.qmlEngine.reset();
authState.qmlIntegration.reset();
if (authState.qmlEngine)
authState.qmlEngine->deleteLater();
if (authState.qmlIntegration)
authState.qmlIntegration->deleteLater();
authState.qmlEngine = nullptr;
authState.qmlIntegration = nullptr;
}
}
@ -52,16 +58,15 @@ void CAgent::initAuthPrompt() {
std::print("Spawning qml prompt\n");
authState.qmlEngine.reset();
authState.authing = true;
authState.qmlIntegration = makeShared<CQMLIntegration>();
authState.qmlIntegration = new CQMLIntegration();
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE"))
QQuickStyle::setStyle("org.kde.desktop");
authState.qmlEngine = makeShared<QQmlApplicationEngine>();
authState.qmlEngine->rootContext()->setContextProperty("hpa", authState.qmlIntegration.get());
authState.qmlEngine = new QQmlApplicationEngine();
authState.qmlEngine->rootContext()->setContextProperty("hpa", authState.qmlIntegration);
authState.qmlEngine->load(QUrl{u"qrc:/qt/qml/hpa/qml/main.qml"_qs});
authState.qmlIntegration->focusField();

View File

@ -30,9 +30,9 @@ class CAgent {
private:
struct {
bool authing = false;
SP<QQmlApplicationEngine> qmlEngine;
SP<CQMLIntegration> qmlIntegration;
bool authing = false;
QQmlApplicationEngine* qmlEngine = nullptr;
CQMLIntegration* qmlIntegration = nullptr;
} authState;
struct {

View File

@ -14,7 +14,7 @@ CPolkitListener::CPolkitListener(QObject* parent) : Listener(parent) {
}
void CPolkitListener::initiateAuthentication(const QString& actionId, const QString& message, const QString& iconName, const PolkitQt1::Details& details, const QString& cookie,
const PolkitQt1::Identity::List& identities, AsyncResult* result) {
const PolkitQt1::Identity::List& identities, AsyncResult* result) {
std::print("> New authentication session\n");