Fix crashes in layout manager tests

This commit is contained in:
Nyall Dawson 2018-01-24 07:01:17 +10:00
parent b8880d46cd
commit be959628e5

View File

@ -37,7 +37,7 @@ QgsLayoutManager::~QgsLayoutManager()
bool QgsLayoutManager::addLayout( QgsMasterLayoutInterface *layout )
{
if ( !layout )
if ( !layout || mLayouts.contains( layout ) )
return false;
// check for duplicate name
@ -265,13 +265,12 @@ QgsMasterLayoutInterface *QgsLayoutManager::duplicateLayout( const QgsMasterLayo
newLayout->setName( newName );
QgsMasterLayoutInterface *l = newLayout.get();
if ( !addLayout( l ) )
if ( !addLayout( newLayout.release() ) )
{
return nullptr;
}
else
{
( void )newLayout.release(); //ownership was transferred successfully
return l;
}
}