aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/widgets/VariableSizedImageObject.cpp
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-10-11 14:19:29 -0300
committerflow <flowlnlnln@gmail.com>2022-10-11 15:51:54 -0300
commitd194b02e28132df3ea3da961299e969614b8a185 (patch)
treed4c8afbd6d595fc30972b72e223abd2544c7ac55 /launcher/ui/widgets/VariableSizedImageObject.cpp
parentd7992ab29d07c6d26377f6db1cfca6059aace471 (diff)
downloadPrismLauncher-d194b02e28132df3ea3da961299e969614b8a185.tar.gz
PrismLauncher-d194b02e28132df3ea3da961299e969614b8a185.tar.bz2
PrismLauncher-d194b02e28132df3ea3da961299e969614b8a185.zip
fix: prevent images overriding content when changing pages
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui/widgets/VariableSizedImageObject.cpp')
-rw-r--r--launcher/ui/widgets/VariableSizedImageObject.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/launcher/ui/widgets/VariableSizedImageObject.cpp b/launcher/ui/widgets/VariableSizedImageObject.cpp
index 0efdecab..e57f7e95 100644
--- a/launcher/ui/widgets/VariableSizedImageObject.cpp
+++ b/launcher/ui/widgets/VariableSizedImageObject.cpp
@@ -66,6 +66,11 @@ void VariableSizedImageObject::drawObject(QPainter* painter,
painter->drawImage(rect, image);
}
+void VariableSizedImageObject::flush()
+{
+ m_fetching_images.clear();
+}
+
void VariableSizedImageObject::parseImage(QTextDocument* doc, QImage image, int posInDocument)
{
QTextCursor cursor(doc);
@@ -85,7 +90,7 @@ void VariableSizedImageObject::parseImage(QTextDocument* doc, QImage image, int
void VariableSizedImageObject::loadImage(QTextDocument* doc, const QUrl& source, int posInDocument)
{
- m_fetching_images.append(source);
+ m_fetching_images.insert(source);
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry(
m_meta_entry,
@@ -99,6 +104,10 @@ void VariableSizedImageObject::loadImage(QTextDocument* doc, const QUrl& source,
connect(job, &NetJob::succeeded, [this, doc, full_entry_path, source_url, posInDocument] {
qDebug() << "Loaded resource at" << full_entry_path;
+ // If we flushed, don't proceed.
+ if (!m_fetching_images.contains(source_url))
+ return;
+
QImage image(full_entry_path);
doc->addResource(QTextDocument::ImageResource, source_url, image);
@@ -110,7 +119,7 @@ void VariableSizedImageObject::loadImage(QTextDocument* doc, const QUrl& source,
doc->adjustSize();
doc->setPageSize(size);
- m_fetching_images.removeOne(source_url);
+ m_fetching_images.remove(source_url);
});
connect(job, &NetJob::finished, job, &NetJob::deleteLater);