Ensure avatarJob is run on the respective account's QNAM thread

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-11-20 14:09:40 +08:00
parent 5b5c5e3ac7
commit 13141db2ed
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -1650,12 +1650,20 @@ public:
qCWarning(lcActivity) << "Invalid account:" << accountString;
return;
}
const auto avatarSize = requestedSize.width() > 0 ? requestedSize.width() : 64;
const auto avatarJob = new AvatarJob(accountState->account(), avatarUserId, avatarSize);
connect(avatarJob, &AvatarJob::avatarPixmap, this, [&](const QImage &avatarImg) {
handleDone(AvatarJob::makeCircularAvatar(avatarImg));
const auto account = accountState->account();
const auto qnam = account->networkAccessManager();
QMetaObject::invokeMethod(qnam, [this, requestedSize, avatarUserId, account]() {
const auto avatarSize = requestedSize.width() > 0 ? requestedSize.width() : 64;
const auto avatarJob = new AvatarJob(account, avatarUserId, avatarSize);
connect(avatarJob, &AvatarJob::avatarPixmap, this, [&](const QImage &avatarImg) {
QMetaObject::invokeMethod(this, [this, avatarImg] {
handleDone(AvatarJob::makeCircularAvatar(avatarImg));
});
});
avatarJob->start();
});
avatarJob->start();
return;
}