<table><tr><td style="">apol created this revision.<br />apol added reviewers: Kirigami, mart.<br />Herald added a project: Kirigami.<br />Herald added a subscriber: plasma-devel.<br />apol requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D25185">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>For starters, QQmlEngine::networkAccessManager is not reentrant and would give<br />
us a warning along the lines of:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">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)</pre></div>

<p>That happens because Icon::findIcon is called from Icon::updatePaintNode which<br />
is called from the render thread.</p>

<p>This patch changes it so the QNAM bits happen upon setSource, so downloading<br />
the image will be handled by the main thread and we will only be grabbing it<br />
from an already prepared QImage.<br />
This patch also includes a QMutex, to keep both threads split.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>I don't get the warning anymore and if I agressively scroll I don't<br />
get crashes. This will potentially fix a bunch of bugs in Discover since we use<br />
extensively Kirigami.Icon + http.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R169 Kirigami</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D25185">https://phabricator.kde.org/D25185</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/icon.cpp<br />
src/icon.h</div></div></div><br /><div><strong>To: </strong>apol, Kirigami, mart<br /><strong>Cc: </strong>plasma-devel, fbampaloukas, GB_2, domson, dkardarakos, ngraham, apol, ahiemstra, davidedmundson, mart, hein<br /></div>