Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 9, 2017
1 parent 46a0a48 commit b791da3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/core/layout/qgslayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,22 @@ QgsLayout::~QgsLayout()
// this class is deconstructed - to avoid segfaults
// when layout items access in destructor layout that isn't valid anymore

// since deletion of some item types (e.g. groups) trigger deletion
// of other items, we have to do this careful, one at a time...
QList<QGraphicsItem *> itemList = items();
while ( !itemList.empty() )
bool deleted = true;
while ( deleted )
{
QGraphicsItem *item = itemList.at( 0 );
if ( dynamic_cast< QgsLayoutItem * >( item ) && !dynamic_cast< QgsLayoutItemPage *>( item ) )
delete item;
deleted = false;
for ( QGraphicsItem *item : qgsAsConst( itemList ) )
{
if ( dynamic_cast< QgsLayoutItem * >( item ) && !dynamic_cast< QgsLayoutItemPage *>( item ) )
{
delete item;
deleted = true;
break;
}
}
itemList = items();
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/layout/qgslayoutitemgroupundocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "qgslayout.h"
#include "qgsproject.h"

///@cond PRIVATE
QgsLayoutItemGroupUndoCommand::QgsLayoutItemGroupUndoCommand( State s, QgsLayoutItemGroup *group, QgsLayout *layout, const QString &text, QUndoCommand *parent )
: QUndoCommand( text, parent )
, mGroupUuid( group->uuid() )
Expand Down Expand Up @@ -84,3 +85,4 @@ void QgsLayoutItemGroupUndoCommand::switchState()
}
mLayout->project()->setDirty( true );
}
///@endcond
2 changes: 2 additions & 0 deletions src/core/layout/qgslayoutitemgroupundocommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qgslayoutitem.h"

#define SIP_NO_FILE
///@cond PRIVATE

/**
* \ingroup core
Expand Down Expand Up @@ -67,5 +68,6 @@ class CORE_EXPORT QgsLayoutItemGroupUndoCommand: public QObject, public QUndoCom
//changes between added / removed state
void switchState();
};
///@endcond

#endif // QGSLAYOUTITEMGROUPUNDOCOMMAND_H

0 comments on commit b791da3

Please sign in to comment.