mirror of
https://github.com/hyprwm/hyprpolkitagent.git
synced 2024-11-21 18:05:59 +01:00
core: avoid crashes lol
This commit is contained in:
parent
2c97f97336
commit
e714ed59ac
4 changed files with 17 additions and 11 deletions
|
@ -5,7 +5,8 @@
|
|||
#include <QSocketNotifier>
|
||||
|
||||
class CSigDaemon : public QObject {
|
||||
Q_OBJECT;
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
CSigDaemon(QObject* parent = nullptr);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue