Skip to content
Permalink
Browse files
Cleanup items before reading from template. Fixes bug #2083
git-svn-id: http://svn.osgeo.org/qgis/trunk@12098 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Nov 13, 2009
1 parent 2e93a04 commit 1a90d512cedb63414c18fa49be363b46f92be6fa
Showing with 18 additions and 8 deletions.
  1. +15 −8 src/app/composer/qgscomposer.cpp
  2. +3 −0 src/app/composer/qgscomposer.h
@@ -184,7 +184,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ): QMainWindow(),
connectSlots();

mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
mComposition->setParent(mView);
mComposition->setParent( mView );
mView->setComposition( mComposition );

QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mCompositionOptionsFrame, mComposition );
@@ -220,13 +220,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ): QMainWindow(),

QgsComposer::~QgsComposer()
{
//delete all the items
QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.begin();
for ( ; it != mItemWidgetMap.end(); ++it )
{
delete it.key();
delete it.value();
}
deleteItems();
}

void QgsComposer::setupTheme()
@@ -842,6 +836,7 @@ void QgsComposer::on_mActionLoadFromTemplate_triggered()
return;
}

deleteItems();
readXML( templateDocument );

//clean up after template read (e.g. legend and map extent)
@@ -1176,6 +1171,18 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
setSelectionTool();
}

void QgsComposer::deleteItems()
{
//delete all the items
QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.begin();
for ( ; it != mItemWidgetMap.end(); ++it )
{
delete it.key();
delete it.value();
}
mItemWidgetMap.clear();
}

void QgsComposer::addComposerMap( QgsComposerMap* map )
{
if ( !map )
@@ -246,6 +246,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Writes state under DOM element
void writeXML( QDomNode& parentNode, QDomDocument& doc );

//! Removes all the item from the graphics scene and deletes them
void deleteItems();

/**Composer title*/
QString mTitle;

0 comments on commit 1a90d51

Please sign in to comment.