Skip to content

Commit

Permalink
Ensure avatarJob is run on the respective account's QNAM thread
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Nov 20, 2024
1 parent 5b5c5e3 commit 13141db
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,12 +1650,20 @@ class ImageResponse : public QQuickImageResponse
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;
}

Expand Down

0 comments on commit 13141db

Please sign in to comment.