mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -05:00
[layouts] Fix a crash when using multiframe items when no pages exist
This commit is contained in:
parent
afde31b94f
commit
fb3ff6d226
@ -148,7 +148,7 @@ void QgsLayoutMultiFrame::recalculateFrameSizes()
|
||||
}
|
||||
|
||||
//at end of frames but there is still content left. Add other pages if ResizeMode ==
|
||||
if ( currentItem && mResizeMode != UseExistingFrames )
|
||||
if ( mLayout->pageCollection()->pageCount() > 0 && currentItem && mResizeMode != UseExistingFrames )
|
||||
{
|
||||
while ( ( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight )
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ class TestQgsLayoutMultiFrame : public QObject
|
||||
void registry();
|
||||
void deleteFrame();
|
||||
void writeReadXml();
|
||||
void noPageNoCrash();
|
||||
|
||||
private:
|
||||
QgsLayout *mLayout = nullptr;
|
||||
@ -620,5 +621,35 @@ void TestQgsLayoutMultiFrame::writeReadXml()
|
||||
QCOMPARE( html2->frames(), QList< QgsLayoutFrame * >() << frame2 );
|
||||
}
|
||||
|
||||
void TestQgsLayoutMultiFrame::noPageNoCrash()
|
||||
{
|
||||
QgsProject p;
|
||||
|
||||
// create layout, no pages
|
||||
QgsLayout c( &p );
|
||||
// add an multiframe
|
||||
QgsLayoutItemHtml *html = new QgsLayoutItemHtml( &c );
|
||||
c.addMultiFrame( html );
|
||||
html->setContentMode( QgsLayoutItemHtml::ManualHtml );
|
||||
html->setHtml( QStringLiteral( "<div style=\"height: 2000px\">hi</div>" ) );
|
||||
QgsLayoutFrame *frame = new QgsLayoutFrame( &c, html );
|
||||
frame->attemptSetSceneRect( QRectF( 1, 1, 10, 1 ) );
|
||||
c.addLayoutItem( frame );
|
||||
html->addFrame( frame );
|
||||
|
||||
html->setResizeMode( QgsLayoutMultiFrame::UseExistingFrames );
|
||||
html->recalculateFrameSizes();
|
||||
QCOMPARE( html->frameCount(), 1 );
|
||||
html->setResizeMode( QgsLayoutMultiFrame::ExtendToNextPage );
|
||||
html->recalculateFrameSizes();
|
||||
QCOMPARE( html->frameCount(), 1 );
|
||||
html->setResizeMode( QgsLayoutMultiFrame::RepeatOnEveryPage );
|
||||
html->recalculateFrameSizes();
|
||||
QCOMPARE( html->frameCount(), 1 );
|
||||
html->setResizeMode( QgsLayoutMultiFrame::RepeatUntilFinished );
|
||||
html->recalculateFrameSizes();
|
||||
QCOMPARE( html->frameCount(), 1 );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsLayoutMultiFrame )
|
||||
#include "testqgslayoutmultiframe.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user