Skip to content

Commit 9c0ac68

Browse files
committed
service/polkit: use property update groups and keep supplementary message on session restart
1 parent 38759b4 commit 9c0ac68

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/services/polkit/flow.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ void AuthFlow::cancelFromAgent() {
5252

5353
qCDebug(logPolkitState) << "cancelling authentication request from agent";
5454

55+
// Session cancel can immediately call the cancel handler, which also
56+
// performs property updates.
57+
Qt::beginPropertyUpdateGroup();
5558
this->bIsCancelled = true;
5659
this->currentSession->cancel();
60+
Qt::endPropertyUpdateGroup();
5761

5862
emit this->authenticationRequestCancelled();
5963

@@ -67,18 +71,24 @@ void AuthFlow::submit(const QString& value) {
6771

6872
this->currentSession->respond(value);
6973

74+
Qt::beginPropertyUpdateGroup();
7075
this->bIsResponseRequired = false;
7176
this->bInputPrompt = QString();
7277
this->bResponseVisible = false;
78+
Qt::endPropertyUpdateGroup();
7379
}
7480

7581
void AuthFlow::cancelAuthenticationRequest() {
7682
if (!this->currentSession) return;
7783

7884
qCDebug(logPolkitState) << "cancelling authentication request by user request";
7985

86+
// Session cancel can immediately call the cancel handler, which also
87+
// performs property updates.
88+
Qt::beginPropertyUpdateGroup();
8089
this->bIsCancelled = true;
8190
this->currentSession->cancel();
91+
Qt::endPropertyUpdateGroup();
8292

8393
this->mRequest->cancel("Authentication request cancelled by user.");
8494
}
@@ -101,48 +111,50 @@ void AuthFlow::setupSession() {
101111
this->currentSession->initiate();
102112
}
103113

104-
void AuthFlow::clearState() {
105-
this->bIsResponseRequired = false;
106-
this->bInputPrompt = QString {};
107-
this->bResponseVisible = false;
108-
this->bSupplementaryMessage = QString {};
109-
this->bSupplementaryIsError = false;
110-
}
111-
112114
void AuthFlow::request(const QString& message, bool echo) {
115+
Qt::beginPropertyUpdateGroup();
113116
this->bIsResponseRequired = true;
114117
this->bInputPrompt = message;
115118
this->bResponseVisible = echo;
119+
Qt::endPropertyUpdateGroup();
116120
}
117121

118122
void AuthFlow::completed(bool gainedAuthorization) {
119123
qCDebug(logPolkitState) << "authentication session completed, gainedAuthorization ="
120124
<< gainedAuthorization << ", isCancelled =" << this->bIsCancelled.value();
121125

122126
if (gainedAuthorization) {
127+
Qt::beginPropertyUpdateGroup();
123128
this->bIsCompleted = true;
124129
this->bIsSuccessful = true;
130+
Qt::endPropertyUpdateGroup();
131+
125132
this->mRequest->complete();
126133

127134
emit this->authenticationSucceeded();
128135
} else if (this->bIsCancelled.value()) {
136+
Qt::beginPropertyUpdateGroup();
129137
this->bIsCompleted = true;
130138
this->bIsSuccessful = false;
139+
Qt::endPropertyUpdateGroup();
131140
} else {
132141
emit this->authenticationFailed();
133142

134-
this->clearState();
135143
this->setupSession();
136144
}
137145
}
138146

139147
void AuthFlow::showError(const QString& message) {
148+
Qt::beginPropertyUpdateGroup();
140149
this->bSupplementaryMessage = message;
141150
this->bSupplementaryIsError = true;
151+
Qt::endPropertyUpdateGroup();
142152
}
143153

144154
void AuthFlow::showInfo(const QString& message) {
155+
Qt::beginPropertyUpdateGroup();
145156
this->bSupplementaryMessage = message;
146157
this->bSupplementaryIsError = false;
158+
Qt::endPropertyUpdateGroup();
147159
}
148160
} // namespace qs::service::polkit

src/services/polkit/flow.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ private slots:
153153
private:
154154
/// Start a session for the currently selected identity and the current request.
155155
void setupSession();
156-
/// Clear all state variables.
157-
void clearState();
158156

159157
Session* currentSession = nullptr;
160158
AuthRequest* mRequest = nullptr;

0 commit comments

Comments
 (0)