@@ -106,7 +106,7 @@ void PolkitAgentImpl::initiateAuthentication(AuthRequest* request) {
106106
107107 this ->queuedRequests .emplace_back (request);
108108
109- if (this ->queuedRequests . size () == 1 ) {
109+ if (! this ->bActiveFlow . value () ) {
110110 this ->activateAuthenticationRequest ();
111111 }
112112}
@@ -130,37 +130,39 @@ void PolkitAgentImpl::cancelAuthentication(AuthRequest* request) {
130130}
131131
132132void PolkitAgentImpl::activateAuthenticationRequest () {
133- if (this ->queuedRequests .empty ()) return ;
133+ while (!this ->queuedRequests .empty ()) {
134+ AuthRequest* req = this ->queuedRequests .front ();
135+ this ->queuedRequests .pop_front ();
136+ qCDebug (logPolkit) << " activating authentication request for action" << req->actionId
137+ << " , cookie: " << req->cookie ;
138+
139+ QList<Identity*> identities;
140+ for (auto & identity: req->identities ) {
141+ auto * obj = Identity::fromPolkitIdentity (identity);
142+ if (obj) identities.append (obj);
143+ }
144+ if (identities.isEmpty ()) {
145+ qCWarning (
146+ logPolkit
147+ ) << " no supported identities available for authentication request, cancelling." ;
148+ req->cancel (" Error requesting authentication: no supported identities available." );
149+ delete req;
150+ continue ;
151+ }
152+
153+ this ->bActiveFlow = new AuthFlow (req, std::move (identities));
154+
155+ QObject::connect (
156+ this ->bActiveFlow .value (),
157+ &AuthFlow::isCompletedChanged,
158+ this ,
159+ &PolkitAgentImpl::finishAuthenticationRequest
160+ );
161+
162+ emit this ->qmlAgent ->authenticationRequestStarted ();
134163
135- AuthRequest* req = this ->queuedRequests .front ();
136- this ->queuedRequests .pop_front ();
137- qCDebug (logPolkit) << " activating authentication request for action" << req->actionId
138- << " , cookie: " << req->cookie ;
139-
140- QList<Identity*> identities;
141- for (auto & identity: req->identities ) {
142- auto * obj = Identity::fromPolkitIdentity (identity);
143- if (obj) identities.append (obj);
144- }
145- if (identities.isEmpty ()) {
146- qCWarning (
147- logPolkit
148- ) << " no supported identities available for authentication request, cancelling." ;
149- req->cancel (" Error requesting authentication: no supported identities available." );
150- delete req;
151164 return ;
152165 }
153-
154- this ->bActiveFlow = new AuthFlow (req, std::move (identities));
155-
156- QObject::connect (
157- this ->bActiveFlow .value (),
158- &AuthFlow::isCompletedChanged,
159- this ,
160- &PolkitAgentImpl::finishAuthenticationRequest
161- );
162-
163- emit this ->qmlAgent ->authenticationRequestStarted ();
164166}
165167
166168void PolkitAgentImpl::finishAuthenticationRequest () {
@@ -170,11 +172,8 @@ void PolkitAgentImpl::finishAuthenticationRequest() {
170172 << this ->bActiveFlow .value ()->actionId ();
171173
172174 this ->bActiveFlow .value ()->deleteLater ();
175+ this ->bActiveFlow = nullptr ;
173176
174- if (!this ->queuedRequests .empty ()) {
175- this ->activateAuthenticationRequest ();
176- } else {
177- this ->bActiveFlow = nullptr ;
178- }
177+ this ->activateAuthenticationRequest ();
179178}
180179} // namespace qs::service::polkit
0 commit comments