@@ -187,16 +187,16 @@ QgsComposition::~QgsComposition()
187
187
removePaperItems ();
188
188
deleteAndRemoveMultiFrames ();
189
189
190
- // clear pointers to QgsDataDefined objects
191
- // TODO - should be qDeleteAll? Check original label code too for same leak.
192
- mDataDefinedProperties .clear ();
193
-
194
190
// make sure that all composer items are removed before
195
191
// this class is deconstructed - to avoid segfaults
196
192
// when composer items access in destructor composition that isn't valid anymore
197
193
QList<QGraphicsItem*> itemList = items ();
198
194
qDeleteAll ( itemList );
199
195
196
+ // clear pointers to QgsDataDefined objects
197
+ qDeleteAll ( mDataDefinedProperties );
198
+ mDataDefinedProperties .clear ();
199
+
200
200
// order is important here - we need to delete model last so that all items have already
201
201
// been deleted. Deleting the undo stack will also delete any items which have been
202
202
// removed from the scene, so this needs to be done before deleting the model
@@ -925,13 +925,14 @@ bool QgsComposition::loadFromTemplate( const QDomDocument& doc, QMap<QString, QS
925
925
{
926
926
deleteAndRemoveMultiFrames ();
927
927
928
- // delete all items and emit itemRemoved signal
928
+ // delete all non paper items and emit itemRemoved signal
929
929
QList<QGraphicsItem *> itemList = items ();
930
930
QList<QGraphicsItem *>::iterator itemIter = itemList.begin ();
931
931
for ( ; itemIter != itemList.end (); ++itemIter )
932
932
{
933
933
QgsComposerItem* cItem = dynamic_cast <QgsComposerItem*>( *itemIter );
934
- if ( cItem )
934
+ QgsPaperItem* pItem = dynamic_cast <QgsPaperItem*>( *itemIter );
935
+ if ( cItem && !pItem )
935
936
{
936
937
removeItem ( cItem );
937
938
emit itemRemoved ( cItem );
@@ -940,7 +941,7 @@ bool QgsComposition::loadFromTemplate( const QDomDocument& doc, QMap<QString, QS
940
941
}
941
942
mItemsModel ->clear ();
942
943
943
- mPages . clear ();
944
+ removePaperItems ();
944
945
mUndoStack ->clear ();
945
946
}
946
947
@@ -2550,10 +2551,7 @@ void QgsComposition::addPaperItem()
2550
2551
2551
2552
void QgsComposition::removePaperItems ()
2552
2553
{
2553
- for ( int i = 0 ; i < mPages .size (); ++i )
2554
- {
2555
- delete mPages .at ( i );
2556
- }
2554
+ qDeleteAll ( mPages );
2557
2555
mPages .clear ();
2558
2556
QgsExpression::setSpecialColumn ( " $numpages" , QVariant (( int )0 ) );
2559
2557
}
0 commit comments