Skip to content
Snippets Groups Projects
Commit 928f2e9e authored by Prince Gupta's avatar Prince Gupta :speech_balloon: Committed by Steve Lhomme
Browse files

qt: optimize status handling in RoundImage

this omits texture clearing incase the image is available in cache
parent 6ca4e0cf
No related branches found
No related tags found
1 merge request!5758qt: optimize status handling in RoundImage
Pipeline #496815 passed with stage
in 16 minutes and 20 seconds
......@@ -490,11 +490,25 @@ void RoundImage::setDPR(const qreal value)
void RoundImage::load()
{
// NOTE: at this point we still have old content displayed
m_enqueuedGeneration = false;
if (m_source.isEmpty())
{
// nothing to load, clear old content
setStatus(Status::Null);
setRoundImage({});
return;
}
auto engine = qmlEngine(this);
if (!engine || m_source.isEmpty() || !m_sourceSize.isValid() || m_sourceSize.isEmpty())
if (!engine || !m_sourceSize.isValid() || m_sourceSize.isEmpty())
{
onRequestCompleted(Status::Error, {});
return;
}
const qreal scaledWidth = m_sourceSize.width() * m_dpr;
const qreal scaledHeight = m_sourceSize.height() * m_dpr;
......@@ -519,6 +533,7 @@ void RoundImage::load()
m_activeImageResponse->saveInCache();
connect(m_activeImageResponse.get(), &RoundImageRequest::requestCompleted, this, &RoundImage::onRequestCompleted);
//at this point m_activeImageResponse is either in Loading or Error status
onRequestCompleted(RoundImage::Loading, {});
}
......@@ -581,11 +596,6 @@ void RoundImage::regenerateRoundImage()
if (!isComponentComplete() || m_enqueuedGeneration)
return;
setStatus(source().isEmpty() ? Status::Null : Status::Loading);
// remove old contents
setRoundImage({});
m_activeImageResponse.reset();
// use Qt::QueuedConnection to delay generation, so that dependent properties
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment