mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Fix valgrind noise
This commit is contained in:
parent
02acbb4184
commit
f58947d9b6
@ -46,11 +46,13 @@ QgsLayout::~QgsLayout()
|
||||
// this class is deconstructed - to avoid segfaults
|
||||
// when layout items access in destructor layout that isn't valid anymore
|
||||
|
||||
const QList<QGraphicsItem *> itemList = items();
|
||||
for ( QGraphicsItem *item : itemList )
|
||||
QList<QGraphicsItem *> itemList = items();
|
||||
while ( !itemList.empty() )
|
||||
{
|
||||
QGraphicsItem *item = itemList.at( 0 );
|
||||
if ( dynamic_cast< QgsLayoutItem * >( item ) && !dynamic_cast< QgsLayoutItemPage *>( item ) )
|
||||
delete item;
|
||||
itemList = items();
|
||||
}
|
||||
|
||||
mItemsModel.reset(); // manually delete, so we can control order of destruction
|
||||
|
@ -375,7 +375,7 @@ void TestQgsLayoutItem::positionWithUnits()
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
|
||||
TestItem *item = new TestItem( &l );
|
||||
std::unique_ptr< TestItem > item( new TestItem( &l ) );
|
||||
item->attemptMove( QgsLayoutPoint( 60.0, 15.0, QgsUnitTypes::LayoutMillimeters ) );
|
||||
QCOMPARE( item->positionWithUnits().x(), 60.0 );
|
||||
QCOMPARE( item->positionWithUnits().y(), 15.0 );
|
||||
@ -690,8 +690,8 @@ void TestQgsLayoutItem::resize()
|
||||
|
||||
//resize test item (no restrictions), same units as layout
|
||||
l.setUnits( QgsUnitTypes::LayoutMillimeters );
|
||||
TestItem *item = new TestItem( &l );
|
||||
QSignalSpy spySizeChanged( item, &QgsLayoutItem::sizePositionChanged );
|
||||
std::unique_ptr< TestItem > item( new TestItem( &l ) );
|
||||
QSignalSpy spySizeChanged( item.get(), &QgsLayoutItem::sizePositionChanged );
|
||||
|
||||
item->setRect( 0, 0, 55, 45 );
|
||||
item->attemptMove( QgsLayoutPoint( 27, 29 ) );
|
||||
@ -754,7 +754,7 @@ void TestQgsLayoutItem::referencePoint()
|
||||
QgsLayout l( &p );
|
||||
|
||||
//test setting/getting reference point
|
||||
TestItem *item = new TestItem( &l );
|
||||
std::unique_ptr< TestItem > item( new TestItem( &l ) );
|
||||
item->setReferencePoint( QgsLayoutItem::LowerMiddle );
|
||||
QCOMPARE( item->referencePoint(), QgsLayoutItem::LowerMiddle );
|
||||
|
||||
@ -793,8 +793,7 @@ void TestQgsLayoutItem::referencePoint()
|
||||
QCOMPARE( item->positionWithUnits().x(), 3.0 );
|
||||
QCOMPARE( item->positionWithUnits().y(), 6.0 );
|
||||
|
||||
delete item;
|
||||
item = new TestItem( &l );
|
||||
item.reset( new TestItem( &l ) );
|
||||
|
||||
//test that setting item position is done relative to reference point
|
||||
l.setUnits( QgsUnitTypes::LayoutMillimeters );
|
||||
@ -836,8 +835,7 @@ void TestQgsLayoutItem::referencePoint()
|
||||
QCOMPARE( item->scenePos().x(), -1.0 );
|
||||
QCOMPARE( item->scenePos().y(), -2.0 );
|
||||
|
||||
delete item;
|
||||
item = new TestItem( &l );
|
||||
item.reset( new TestItem( &l ) );
|
||||
|
||||
//test that resizing is done relative to reference point
|
||||
item->attemptResize( QgsLayoutSize( 2, 4 ) );
|
||||
@ -922,7 +920,7 @@ void TestQgsLayoutItem::adjustPointForReference()
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
|
||||
TestItem *item = new TestItem( &l );
|
||||
std::unique_ptr< TestItem > item( new TestItem( &l ) );
|
||||
QPointF result = item->adjustPointForReferencePosition( QPointF( 5, 7 ), QSizeF( 2, 4 ), QgsLayoutItem::UpperLeft );
|
||||
QCOMPARE( result.x(), 5.0 );
|
||||
QCOMPARE( result.y(), 7.0 );
|
||||
@ -1027,7 +1025,7 @@ void TestQgsLayoutItem::fixedSize()
|
||||
QgsLayout l( &p );
|
||||
|
||||
l.setUnits( QgsUnitTypes::LayoutMillimeters );
|
||||
FixedSizedItem *item = new FixedSizedItem( &l );
|
||||
std::unique_ptr< FixedSizedItem > item( new FixedSizedItem( &l ) );
|
||||
QCOMPARE( item->fixedSize().width(), 2.0 );
|
||||
QCOMPARE( item->fixedSize().height(), 4.0 );
|
||||
QCOMPARE( item->fixedSize().units(), QgsUnitTypes::LayoutInches );
|
||||
@ -1050,7 +1048,7 @@ void TestQgsLayoutItem::minSize()
|
||||
QgsLayout l( &p );
|
||||
|
||||
l.setUnits( QgsUnitTypes::LayoutMillimeters );
|
||||
MinSizedItem *item = new MinSizedItem( &l );
|
||||
std::unique_ptr< MinSizedItem > item( new MinSizedItem( &l ) );
|
||||
QCOMPARE( item->minimumSize().width(), 5.0 );
|
||||
QCOMPARE( item->minimumSize().height(), 10.0 );
|
||||
QCOMPARE( item->minimumSize().units(), QgsUnitTypes::LayoutCentimeters );
|
||||
@ -1073,7 +1071,7 @@ void TestQgsLayoutItem::minSize()
|
||||
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * DBL_EPSILON );
|
||||
|
||||
//also need check that fixed size trumps min size
|
||||
FixedMinSizedItem *fixedMinItem = new FixedMinSizedItem( &l );
|
||||
std::unique_ptr< FixedMinSizedItem > fixedMinItem( new FixedMinSizedItem( &l ) );
|
||||
QCOMPARE( fixedMinItem->minimumSize().width(), 5.0 );
|
||||
QCOMPARE( fixedMinItem->minimumSize().height(), 9.0 );
|
||||
QCOMPARE( fixedMinItem->minimumSize().units(), QgsUnitTypes::LayoutCentimeters );
|
||||
@ -1094,7 +1092,7 @@ void TestQgsLayoutItem::move()
|
||||
|
||||
//move test item, same units as layout
|
||||
l.setUnits( QgsUnitTypes::LayoutMillimeters );
|
||||
TestItem *item = new TestItem( &l );
|
||||
std::unique_ptr< TestItem > item( new TestItem( &l ) );
|
||||
item->setRect( 0, 0, 55, 45 );
|
||||
item->setPos( 27, 29 );
|
||||
item->attemptMove( QgsLayoutPoint( 60.0, 15.0, QgsUnitTypes::LayoutMillimeters ) );
|
||||
|
@ -320,7 +320,6 @@ void TestQgsLayoutItemGroup::moveGroup()
|
||||
QList<QgsLayoutItem *> groupItems;
|
||||
groupItems << item << item2;
|
||||
QgsLayoutItemGroup *group = l.groupItems( groupItems );
|
||||
l.addLayoutItem( group );
|
||||
|
||||
QCOMPARE( group->positionWithUnits().x(), 50.8 );
|
||||
QCOMPARE( group->positionWithUnits().y(), 76.2 );
|
||||
@ -357,7 +356,6 @@ void TestQgsLayoutItemGroup::resizeGroup()
|
||||
QList<QgsLayoutItem *> groupItems;
|
||||
groupItems << item << item2;
|
||||
QgsLayoutItemGroup *group = l.groupItems( groupItems );
|
||||
l.addLayoutItem( group );
|
||||
|
||||
QCOMPARE( group->positionWithUnits().x(), 50.0 );
|
||||
QCOMPARE( group->positionWithUnits().y(), 76.2 );
|
||||
|
@ -569,6 +569,7 @@ void TestQgsLayoutModel::setItemRemoved()
|
||||
QCOMPARE( layout.itemsModel()->mItemsInScene.at( 0 ), item2 );
|
||||
QCOMPARE( layout.itemsModel()->mItemsInScene.at( 1 ), item1 );
|
||||
delete label;
|
||||
delete item3;
|
||||
}
|
||||
|
||||
void TestQgsLayoutModel::rebuildZListWithRemoved()
|
||||
@ -603,6 +604,7 @@ void TestQgsLayoutModel::rebuildZListWithRemoved()
|
||||
QCOMPARE( layout.itemsModel()->mItemsInScene.size(), 2 );
|
||||
QCOMPARE( layout.itemsModel()->mItemsInScene.at( 0 ), item2 );
|
||||
QCOMPARE( layout.itemsModel()->mItemsInScene.at( 1 ), item1 );
|
||||
delete item3;
|
||||
}
|
||||
|
||||
void TestQgsLayoutModel::reorderUpWithRemoved()
|
||||
|
@ -79,7 +79,7 @@ void TestQgsLayoutPage::itemType()
|
||||
{
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
QgsLayoutItemPage *page = new QgsLayoutItemPage( &l );
|
||||
std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) );
|
||||
QCOMPARE( page->type(), static_cast< int >( QgsLayoutItemRegistry::LayoutPage ) );
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ void TestQgsLayoutPage::pageSize()
|
||||
{
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
QgsLayoutItemPage *page = new QgsLayoutItemPage( &l );
|
||||
std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) );
|
||||
page->setPageSize( QgsLayoutSize( 270, 297, QgsUnitTypes::LayoutMeters ) );
|
||||
QCOMPARE( page->pageSize().width(), 270.0 );
|
||||
QCOMPARE( page->pageSize().height(), 297.0 );
|
||||
@ -137,7 +137,7 @@ void TestQgsLayoutPage::grid()
|
||||
// test that grid follows page around
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
QgsLayoutItemPage *page = new QgsLayoutItemPage( &l );
|
||||
std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) );
|
||||
|
||||
// should have a grid
|
||||
QVERIFY( page->mGrid.get() );
|
||||
@ -169,9 +169,9 @@ void TestQgsLayoutPage::hiddenPages()
|
||||
{
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
QgsLayoutItemPage *page = new QgsLayoutItemPage( &l );
|
||||
std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) );
|
||||
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
||||
l.pageCollection()->addPage( page );
|
||||
l.pageCollection()->addPage( page.release() );
|
||||
|
||||
#if 0 //TODO
|
||||
QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user