Skip to content

Conversation

@nilsding
Copy link
Member

@nilsding nilsding commented Oct 8, 2025

With this change some warnings from QObject like these are gone now:

QObject: Cannot create children for a parent that is in a different thread.

I suspect this might have been causing some "random" crashes during normal usage as well. QNAMs are supposed to be used from the same thread they were created in, which (as far as I could tell anyway) isn't the case within async image providers...

This change is similar to how the ImageResponse class inside src/gui/tray/usermodel.cpp fetches a remote resource:

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();
});

… Account

With this change some warnings from QObject like these are gone now:

    QObject: Cannot create children for a parent that is in a different thread.

I suspect this might have been causing some "random" crashes during
normal usage as well.  QNAMs are supposed to be used from the same
thread they were created in, which (as far as I could tell anyway) isn't
the case within async image providers...

This change is similar to how the `ImageResponse` class inside
`src/gui/tray/usermodel.cpp` fetches a remote resource.

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
@nilsding nilsding added this to the 4.0.0 milestone Oct 8, 2025
@nilsding nilsding self-assigned this Oct 8, 2025
@github-actions
Copy link

github-actions bot commented Oct 8, 2025

Artifact containing the AppImage: nextcloud-appimage-pr-8848.zip

Digest: sha256:03f92c1cdd01cb9c201dca26a80967593eeef859e17c06534311bbb08b942d0b

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@nilsding
Copy link
Member Author

nilsding commented Oct 8, 2025

/backport to stable-4.0

Copy link
Collaborator

@Aiiaiiio Aiiaiiio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mgallien mgallien merged commit 80d79e4 into master Oct 8, 2025
19 of 20 checks passed
@mgallien mgallien deleted the bugfix/noid/asyncimageresponse-use-qnam-thread branch October 8, 2025 15:43
@mgallien mgallien modified the milestones: 4.0.0, 4.1.0 Oct 8, 2025
@nilsding
Copy link
Member Author

nilsding commented Oct 9, 2025

/backport to stable-3.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants