From 904745543a69b15a8aa06ce51ffc0bcd65bf2ba4 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 22 Jul 2022 11:46:22 +0200 Subject: Verifications sneakily accumulating in the background --- src/encryption/VerificationManager.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/encryption/VerificationManager.cpp') diff --git a/src/encryption/VerificationManager.cpp b/src/encryption/VerificationManager.cpp index 8c775948..ca712922 100644 --- a/src/encryption/VerificationManager.cpp +++ b/src/encryption/VerificationManager.cpp @@ -116,12 +116,18 @@ VerificationManager::verifyUser(QString userid) if (auto model = rooms_->getRoomById(QString::fromStdString(room_id))) { auto flow = DeviceVerificationFlow::InitiateUserVerification(this, model.data(), userid); - connect(model.data(), - &TimelineModel::updateFlowEventId, - this, - [this, flow](std::string eventId) { - dvList[QString::fromStdString(eventId)] = flow; - }); + std::unique_ptr context{new QObject(flow.get())}; + QObject *pcontext = context.get(); + connect( + model.data(), + &TimelineModel::updateFlowEventId, + pcontext, + [this, flow, context = std::move(context)](std::string eventId) mutable { + if (context->parent() == flow.get()) { + dvList[QString::fromStdString(eventId)] = flow; + context.reset(); + } + }); emit newDeviceVerificationRequest(flow.data()); return; } @@ -137,8 +143,9 @@ VerificationManager::verifyUser(QString userid) void VerificationManager::removeVerificationFlow(DeviceVerificationFlow *flow) { + nhlog::crypto()->debug("Removing verification flow {}", (void *)flow); for (auto it = dvList.keyValueBegin(); it != dvList.keyValueEnd(); ++it) { - if ((*it).second == flow) { + if (it->second == flow) { dvList.remove((*it).first); return; } -- cgit 1.5.1