Skip to content

Commit

Permalink
[composer] Fix crash on extend mode for multiframes (Sponsored by
Browse files Browse the repository at this point in the history
City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Sep 17, 2014
1 parent 3ca416a commit a0db663
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 0 additions & 1 deletion src/app/composer/qgscomposerattributetablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void QgsComposerMultiFrame::handleFrameRemoval( QgsComposerItem* item )
{
return;
}

mFrameItems.removeAt( index );
if ( mFrameItems.size() > 0 )
{
Expand Down
6 changes: 6 additions & 0 deletions src/core/composer/qgscomposertablev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions tests/src/core/testqgscomposertablev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.