Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[layouts] Fix crash when opening layout with dynamic image in html label #31880

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/core/layout/qgslayoutitemlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ void QgsLayoutItemLabel::contentChanged()
//For very basic html labels with no external assets, the html load will already be
//complete before we even get a chance to start the QEventLoop. Make sure we check
//this before starting the loop
if ( !mHtmlLoaded )

// important -- we CAN'T do this when it's a render inside the designer, otherwise the
// event loop will mess with the paint event and cause it to be deleted, and BOOM!
if ( !mHtmlLoaded && ( !mLayout || !mLayout->renderContext().isPreviewRender() ) )
{
//Setup event loop and timeout for rendering html
QEventLoop loop;
Expand Down Expand Up @@ -185,6 +188,8 @@ void QgsLayoutItemLabel::loadingHtmlFinished( bool result )
{
Q_UNUSED( result )
mHtmlLoaded = true;
invalidateCache();
update();
}

double QgsLayoutItemLabel::htmlUnitsToLayoutUnits()
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutrendercontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject
friend class TestQgsLayout;
friend class LayoutContextPreviewSettingRestorer;
friend class TestQgsLayoutMap;
friend class TestQgsLayoutLabel;

};

Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgslayoutlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ void TestQgsLayoutLabel::renderAsHtmlRelative()
{
QgsLayout l( QgsProject::instance() );
l.initializeDefaults();
l.renderContext().mIsPreviewRender = false;
QgsLayoutItemLabel *label = new QgsLayoutItemLabel( &l );
label->setMargin( 1 );
l.addLayoutItem( label );
Expand Down