Help: Fix rendering images with litehtml

Creating the document parses it, which also populates the pixmap cache,
so we may not clear the pixmap cache afterwards.

Change-Id: I1e6d1669db898b1e50d59d135e52807afb307d09
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2019-09-02 13:40:51 +02:00
parent c7b84d821b
commit 4b8ec5ffb7
3 changed files with 5 additions and 8 deletions

View File

@@ -848,11 +848,11 @@ void DocumentContainer::setScrollPosition(const QPoint &pos)
m_scrollPosition = pos; m_scrollPosition = pos;
} }
void DocumentContainer::setDocument(litehtml::document::ptr document) void DocumentContainer::setDocument(const QByteArray &data, litehtml::context *context)
{ {
m_document = document;
m_pixmaps.clear(); m_pixmaps.clear();
m_selection = {}; m_selection = {};
m_document = litehtml::document::createFromUTF8(data.constData(), this, context);
} }
litehtml::document::ptr DocumentContainer::document() const litehtml::document::ptr DocumentContainer::document() const

View File

@@ -120,9 +120,9 @@ public:
void get_media_features(litehtml::media_features &media) const override; void get_media_features(litehtml::media_features &media) const override;
void get_language(litehtml::tstring &language, litehtml::tstring &culture) const override; void get_language(litehtml::tstring &language, litehtml::tstring &culture) const override;
void setScrollPosition(const QPoint &pos); void setDocument(const QByteArray &data, litehtml::context *context);
void setDocument(litehtml::document::ptr document);
litehtml::document::ptr document() const; litehtml::document::ptr document() const;
void setScrollPosition(const QPoint &pos);
void render(int width, int height); void render(int width, int height);
// these return areas to redraw in document space // these return areas to redraw in document space

View File

@@ -422,10 +422,7 @@ QUrl QLiteHtmlWidget::url() const
void QLiteHtmlWidget::setHtml(const QString &content) void QLiteHtmlWidget::setHtml(const QString &content)
{ {
litehtml::document::ptr doc = litehtml::document::createFromUTF8(content.toUtf8().constData(), d->documentContainer.setDocument(content.toUtf8(), &d->context);
&d->documentContainer,
&d->context);
d->documentContainer.setDocument(doc);
verticalScrollBar()->setValue(0); verticalScrollBar()->setValue(0);
horizontalScrollBar()->setValue(0); horizontalScrollBar()->setValue(0);
render(); render();