Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/next.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Bug Fixes

- Fixed newer polkit requests overtaking currently active one.
- Fixed ScreencopyView not displaying when only lock surfaces are shown.
- Fixed WlSessionLockSurface.visible crashing if accessed before backing surface creation.
67 changes: 33 additions & 34 deletions src/services/polkit/agentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void PolkitAgentImpl::initiateAuthentication(AuthRequest* request) {

this->queuedRequests.emplace_back(request);

if (this->queuedRequests.size() == 1) {
if (!this->bActiveFlow.value()) {
this->activateAuthenticationRequest();
}
}
Expand All @@ -130,37 +130,39 @@ void PolkitAgentImpl::cancelAuthentication(AuthRequest* request) {
}

void PolkitAgentImpl::activateAuthenticationRequest() {
if (this->queuedRequests.empty()) return;
while (!this->queuedRequests.empty()) {
AuthRequest* req = this->queuedRequests.front();
this->queuedRequests.pop_front();
qCDebug(logPolkit) << "activating authentication request for action" << req->actionId
<< ", cookie: " << req->cookie;

QList<Identity*> identities;
for (auto& identity: req->identities) {
auto* obj = Identity::fromPolkitIdentity(identity);
if (obj) identities.append(obj);
}
if (identities.isEmpty()) {
qCWarning(
logPolkit
) << "no supported identities available for authentication request, cancelling.";
req->cancel("Error requesting authentication: no supported identities available.");
delete req;
continue;
}

this->bActiveFlow = new AuthFlow(req, std::move(identities));

QObject::connect(
this->bActiveFlow.value(),
&AuthFlow::isCompletedChanged,
this,
&PolkitAgentImpl::finishAuthenticationRequest
);

emit this->qmlAgent->authenticationRequestStarted();

AuthRequest* req = this->queuedRequests.front();
this->queuedRequests.pop_front();
qCDebug(logPolkit) << "activating authentication request for action" << req->actionId
<< ", cookie: " << req->cookie;

QList<Identity*> identities;
for (auto& identity: req->identities) {
auto* obj = Identity::fromPolkitIdentity(identity);
if (obj) identities.append(obj);
}
if (identities.isEmpty()) {
qCWarning(
logPolkit
) << "no supported identities available for authentication request, cancelling.";
req->cancel("Error requesting authentication: no supported identities available.");
delete req;
return;
}

this->bActiveFlow = new AuthFlow(req, std::move(identities));

QObject::connect(
this->bActiveFlow.value(),
&AuthFlow::isCompletedChanged,
this,
&PolkitAgentImpl::finishAuthenticationRequest
);

emit this->qmlAgent->authenticationRequestStarted();
}

void PolkitAgentImpl::finishAuthenticationRequest() {
Expand All @@ -170,11 +172,8 @@ void PolkitAgentImpl::finishAuthenticationRequest() {
<< this->bActiveFlow.value()->actionId();

this->bActiveFlow.value()->deleteLater();
this->bActiveFlow = nullptr;

if (!this->queuedRequests.empty()) {
this->activateAuthenticationRequest();
} else {
this->bActiveFlow = nullptr;
}
this->activateAuthenticationRequest();
}
} // namespace qs::service::polkit
Loading