@@ -177,7 +177,7 @@ class TestQgsLayoutItem: public QObject
177
177
178
178
bool renderCheck ( QString testName, QImage &image, int mismatchCount );
179
179
180
- QgsLayoutItem * createCopyViaXml ( QgsLayout *layout, QgsLayoutItem *original );
180
+ std::unique_ptr< QgsLayoutItem > createCopyViaXml ( QgsLayout *layout, QgsLayoutItem *original );
181
181
182
182
};
183
183
@@ -248,7 +248,7 @@ void TestQgsLayoutItem::registry()
248
248
QVERIFY ( registry.itemTypes ().isEmpty () );
249
249
QVERIFY ( !registry.createItem ( 1 , nullptr ) );
250
250
251
- auto create = []( QgsLayout * layout )->QgsLayoutItem *
251
+ auto create = []( QgsLayout * layout )->QgsLayoutItem *
252
252
{
253
253
return new TestItem ( layout );
254
254
};
@@ -1647,7 +1647,7 @@ void TestQgsLayoutItem::writeReadXmlProperties()
1647
1647
1648
1648
original->dataDefinedProperties ().setProperty ( QgsLayoutObject::TestProperty, QgsProperty::fromExpression ( QStringLiteral ( " 10 + 40" ) ) );
1649
1649
1650
- original->setReferencePoint ( QgsLayoutItem::Middle );
1650
+ original->setReferencePoint ( QgsLayoutItem::MiddleRight );
1651
1651
original->attemptResize ( QgsLayoutSize ( 6 , 8 , QgsUnitTypes::LayoutCentimeters ) );
1652
1652
original->attemptMove ( QgsLayoutPoint ( 0.05 , 0.09 , QgsUnitTypes::LayoutMeters ) );
1653
1653
original->setItemRotation ( 45.0 );
@@ -1665,7 +1665,7 @@ void TestQgsLayoutItem::writeReadXmlProperties()
1665
1665
original->setExcludeFromExports ( true );
1666
1666
original->setItemOpacity ( 0.75 );
1667
1667
1668
- QgsLayoutItem * copy = createCopyViaXml ( &l, original );
1668
+ std::unique_ptr< QgsLayoutItem > copy = createCopyViaXml ( &l, original );
1669
1669
1670
1670
QCOMPARE ( copy->uuid (), original->uuid () );
1671
1671
QCOMPARE ( copy->id (), original->id () );
@@ -1675,8 +1675,12 @@ void TestQgsLayoutItem::writeReadXmlProperties()
1675
1675
QCOMPARE ( dd.propertyType (), QgsProperty::ExpressionBasedProperty );
1676
1676
QCOMPARE ( copy->referencePoint (), original->referencePoint () );
1677
1677
QCOMPARE ( copy->sizeWithUnits (), original->sizeWithUnits () );
1678
- QCOMPARE ( copy->positionWithUnits (), original->positionWithUnits () );
1678
+ QGSCOMPARENEAR ( copy->positionWithUnits ().x (), original->positionWithUnits ().x (), 0.001 );
1679
+ QGSCOMPARENEAR ( copy->positionWithUnits ().y (), original->positionWithUnits ().y (), 0.001 );
1680
+ QCOMPARE ( copy->positionWithUnits ().units (), original->positionWithUnits ().units () );
1679
1681
QCOMPARE ( copy->itemRotation (), original->itemRotation () );
1682
+ QGSCOMPARENEAR ( copy->pos ().x (), original->pos ().x (), 0.001 );
1683
+ QGSCOMPARENEAR ( copy->pos ().y (), original->pos ().y (), 0.001 );
1680
1684
QVERIFY ( copy->isLocked () );
1681
1685
QCOMPARE ( copy->zValue (), 55.0 );
1682
1686
QVERIFY ( !copy->isVisible () );
@@ -1689,8 +1693,6 @@ void TestQgsLayoutItem::writeReadXmlProperties()
1689
1693
QCOMPARE ( copy->blendMode (), QPainter::CompositionMode_Darken );
1690
1694
QVERIFY ( copy->excludeFromExports ( ) );
1691
1695
QCOMPARE ( copy->itemOpacity (), 0.75 );
1692
-
1693
- delete copy;
1694
1696
delete original;
1695
1697
}
1696
1698
@@ -1985,7 +1987,7 @@ void TestQgsLayoutItem::excludeFromExports()
1985
1987
QVERIFY ( checker.testLayout ( mReport ) );
1986
1988
}
1987
1989
1988
- QgsLayoutItem * TestQgsLayoutItem::createCopyViaXml ( QgsLayout *layout, QgsLayoutItem *original )
1990
+ std::unique_ptr< QgsLayoutItem> TestQgsLayoutItem::createCopyViaXml ( QgsLayout *layout, QgsLayoutItem *original )
1989
1991
{
1990
1992
// save original item to xml
1991
1993
QDomImplementation DomImplementation;
@@ -1998,10 +2000,10 @@ QgsLayoutItem *TestQgsLayoutItem::createCopyViaXml( QgsLayout *layout, QgsLayout
1998
2000
original->writeXml ( rootNode, doc, QgsReadWriteContext () );
1999
2001
2000
2002
// create new item and restore settings from xml
2001
- TestItem * copy = new TestItem ( layout );
2003
+ std::unique_ptr< TestItem > copy = qgis::make_unique< TestItem > ( layout );
2002
2004
copy->readXml ( rootNode.firstChildElement (), doc, QgsReadWriteContext () );
2003
2005
2004
- return copy;
2006
+ return std::move ( copy ) ;
2005
2007
}
2006
2008
2007
2009
QGSTEST_MAIN ( TestQgsLayoutItem )
0 commit comments