Skip to content
Permalink
Browse files

[composer] Fix crash on extend mode for multiframes (Sponsored by

City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Sep 15, 2014
1 parent 3ca416a commit a0db6634f505b196d313c298e08f25039676868e
@@ -3261,7 +3261,7 @@ void QgsComposer::deleteItem( QgsComposerItem* item )
}

//the item itself is not deleted here (usually, this is done in the destructor of QgsAddRemoveItemCommand)
delete( it.value() );
it.value()->deleteLater();
mItemWidgetMap.remove( it.key() );

QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item );
@@ -43,7 +43,6 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt

mResizeModeComboBox->addItem( tr( "Use existing frames" ), QgsComposerMultiFrame::UseExistingFrames );
mResizeModeComboBox->addItem( tr( "Extend to next page" ), QgsComposerMultiFrame::ExtendToNextPage );
mResizeModeComboBox->addItem( tr( "Repeat on every page" ), QgsComposerMultiFrame::RepeatOnEveryPage );
mResizeModeComboBox->addItem( tr( "Repeat until finished" ), QgsComposerMultiFrame::RepeatUntilFinished );

mLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );
@@ -233,6 +233,7 @@ void QgsComposerMultiFrame::handleFrameRemoval( QgsComposerItem* item )
{
return;
}

mFrameItems.removeAt( index );
if ( mFrameItems.size() > 0 )
{
@@ -32,6 +32,12 @@ QgsComposerTableV2::QgsComposerTableV2( QgsComposition *composition, bool create
, mGridStrokeWidth( 0.5 )
, mGridColor( Qt::black )
{

if ( mComposition )
{
QObject::connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( handleFrameRemoval( QgsComposerItem* ) ) );
}

//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
@@ -46,6 +46,8 @@ class TestQgsComposerTableV2: public QObject
void attributeTableVisibleOnly(); //test displaying only visible attributes
void attributeTableRender(); //test rendering attribute table

void attributeTableExtend();

private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
@@ -298,6 +300,23 @@ void TestQgsComposerTableV2::attributeTableRender()
QVERIFY( result );
}

void TestQgsComposerTableV2::attributeTableExtend()
{
mComposerAttributeTable->removeFrame( 1 );

//force auto creation of some new frames
mComposerAttributeTable->setResizeMode( QgsComposerMultiFrame::ExtendToNextPage );

mComposition->setSelectedItem( mComposerAttributeTable->frame( 1 ) );

QgsCompositionChecker checker( "composerattributetable_render", mComposition );

//now auto remove extra created frames
mComposerAttributeTable->setMaximumNumberOfFeatures( 1 );
bool result = checker.testComposition( mReport, 1 );

}

QTEST_MAIN( TestQgsComposerTableV2 )
#include "moc_testqgscomposertablev2.cxx"

0 comments on commit a0db663

Please sign in to comment.
You can’t perform that action at this time.