Skip to content

Commit 7773d4e

Browse files
committed
[composer] Ensure that composers are deleted before compositions
Fixes some rare crashes when loading projects.
1 parent 64f0fdf commit 7773d4e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/app/qgisapp.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5465,8 +5465,19 @@ void QgisApp::deletePrintComposers()
54655465
for ( ; it != mPrintComposers.end(); ++it )
54665466
{
54675467
emit composerWillBeRemoved(( *it )->view() );
5468-
delete(( *it )->composition() );
5468+
5469+
//save a reference to the composition
5470+
QgsComposition* composition = ( *it )->composition();
5471+
5472+
//first, delete the composer. This must occur before deleting the composition as some of the cleanup code in
5473+
//composer or in composer item widgets may require the composition to still be around
54695474
delete( *it );
5475+
5476+
//next, delete the composition
5477+
if ( composition )
5478+
{
5479+
delete composition;
5480+
}
54705481
}
54715482
mPrintComposers.clear();
54725483
mLastComposerId = 0;

0 commit comments

Comments
 (0)