D25185: Icon: solve threading issue on when the source is http
Aleix Pol Gonzalez
noreply at phabricator.kde.org
Thu Nov 7 02:26:11 GMT 2019
apol created this revision.
apol added reviewers: Kirigami, mart.
Herald added a project: Kirigami.
Herald added a subscriber: plasma-devel.
apol requested review of this revision.
REVISION SUMMARY
For starters, QQmlEngine::networkAccessManager is not reentrant and would give
us a warning along the lines of:
discover(68504)/ QObject::QObject|QNetworkAccessManager::QNetworkAccessManager QObject: Cannot create children for a parent that is in a different thread.
(Parent is QQmlApplicationEngine(0x5563bf8dcad0), parent's thread is QThread(0x5563bf825f70), current thread is QSGRenderThread(0x5563bfef7830)
That happens because Icon::findIcon is called from Icon::updatePaintNode which
is called from the render thread.
This patch changes it so the QNAM bits happen upon setSource, so downloading
the image will be handled by the main thread and we will only be grabbing it
from an already prepared QImage.
This patch also includes a QMutex, to keep both threads split.
TEST PLAN
I don't get the warning anymore and if I agressively scroll I don't
get crashes. This will potentially fix a bunch of bugs in Discover since we use
extensively Kirigami.Icon + http.
REPOSITORY
R169 Kirigami
BRANCH
master
REVISION DETAIL
https://phabricator.kde.org/D25185
AFFECTED FILES
src/icon.cpp
src/icon.h
To: apol, #kirigami, mart
Cc: plasma-devel, fbampaloukas, GB_2, domson, dkardarakos, ngraham, apol, ahiemstra, davidedmundson, mart, hein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20191107/7a053c09/attachment.html>
More information about the Plasma-devel
mailing list