diff --git a/python/core/composer/qgscomposershape.sip b/python/core/composer/qgscomposershape.sip index ae37c2225f5..7833dabed5c 100644 --- a/python/core/composer/qgscomposershape.sip +++ b/python/core/composer/qgscomposershape.sip @@ -47,7 +47,7 @@ class QgsComposerShape: QgsComposerItem /** Sets the QgsFillSymbolV2 used to draw the shape. Must also call setUseSymbolV2( true ) to * enable drawing with a symbol. * Note: added in version 2.1*/ - void setShapeStyleSymbol( QgsFillSymbolV2* symbol /Transfer/ ); + void setShapeStyleSymbol( QgsFillSymbolV2* symbol ); /** Returns the QgsFillSymbolV2 used to draw the shape. * Note: added in version 2.1*/ QgsFillSymbolV2* shapeStyleSymbol(); diff --git a/python/core/composer/qgscomposition.sip b/python/core/composer/qgscomposition.sip index 51e2cc7b8e0..94948d588f4 100644 --- a/python/core/composer/qgscomposition.sip +++ b/python/core/composer/qgscomposition.sip @@ -115,7 +115,7 @@ class QgsComposition : QGraphicsScene bool shouldExportPage( const int page ) const; /** Note: added in version 2.1*/ - void setPageStyleSymbol( QgsFillSymbolV2* symbol /Transfer/ ); + void setPageStyleSymbol( QgsFillSymbolV2* symbol ); /** Note: added in version 2.1*/ QgsFillSymbolV2* pageStyleSymbol(); diff --git a/src/app/composer/qgscomposershapewidget.cpp b/src/app/composer/qgscomposershapewidget.cpp index c4b353275c9..b1ec8db43c1 100644 --- a/src/app/composer/qgscomposershapewidget.cpp +++ b/src/app/composer/qgscomposershapewidget.cpp @@ -117,10 +117,7 @@ void QgsComposerShapeWidget::on_mShapeStyleButton_clicked() updateShapeStyle(); mComposerShape->endCommand(); } - else - { - delete newSymbol; - } + delete newSymbol; } void QgsComposerShapeWidget::updateShapeStyle() diff --git a/src/app/composer/qgscompositionwidget.cpp b/src/app/composer/qgscompositionwidget.cpp index 1a17494dff7..08a67a42288 100644 --- a/src/app/composer/qgscompositionwidget.cpp +++ b/src/app/composer/qgscompositionwidget.cpp @@ -563,10 +563,7 @@ void QgsCompositionWidget::on_mPageStyleButton_clicked() mComposition->setPageStyleSymbol( newSymbol ); updatePageStyle(); } - else - { - delete newSymbol; - } + delete newSymbol; } void QgsCompositionWidget::updatePageStyle() diff --git a/src/core/composer/qgscomposershape.cpp b/src/core/composer/qgscomposershape.cpp index af16d5c3840..406de171634 100644 --- a/src/core/composer/qgscomposershape.cpp +++ b/src/core/composer/qgscomposershape.cpp @@ -74,7 +74,7 @@ void QgsComposerShape::setUseSymbolV2( bool useSymbolV2 ) void QgsComposerShape::setShapeStyleSymbol( QgsFillSymbolV2* symbol ) { delete mShapeStyleSymbol; - mShapeStyleSymbol = symbol; + mShapeStyleSymbol = static_cast( symbol->clone() ); refreshSymbol(); } diff --git a/src/core/composer/qgscomposition.cpp b/src/core/composer/qgscomposition.cpp index 784019486d9..3b11fe0ed90 100644 --- a/src/core/composer/qgscomposition.cpp +++ b/src/core/composer/qgscomposition.cpp @@ -492,7 +492,7 @@ bool QgsComposition::shouldExportPage( const int page ) const void QgsComposition::setPageStyleSymbol( QgsFillSymbolV2* symbol ) { delete mPageStyleSymbol; - mPageStyleSymbol = symbol; + mPageStyleSymbol = static_cast( symbol->clone() ); QgsProject::instance()->dirty( true ); } diff --git a/tests/src/core/testqgscomposerpaper.cpp b/tests/src/core/testqgscomposerpaper.cpp index 98f0d69ca7d..864a121fecf 100644 --- a/tests/src/core/testqgscomposerpaper.cpp +++ b/tests/src/core/testqgscomposerpaper.cpp @@ -36,10 +36,6 @@ class TestQgsComposerPaper : public QObject public: TestQgsComposerPaper() : mComposition( 0 ) - , mSimpleFill( 0 ) - , mMarkerLine( 0 ) - , mFillSymbol( 0 ) - , mMarkerLineSymbol( 0 ) , mMapSettings( 0 ) {} @@ -56,10 +52,6 @@ class TestQgsComposerPaper : public QObject private: QgsComposition* mComposition; QString mReport; - QgsSimpleFillSymbolLayerV2* mSimpleFill; - QgsMarkerLineSymbolLayerV2* mMarkerLine; - QgsFillSymbolV2* mFillSymbol; - QgsFillSymbolV2* mMarkerLineSymbol; QgsMapSettings *mMapSettings; // QgsSingleSymbolRendererV2* mSymbolRenderer; @@ -75,16 +67,6 @@ void TestQgsComposerPaper::initTestCase() mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape - //setup simple fill - mSimpleFill = new QgsSimpleFillSymbolLayerV2(); - mFillSymbol = new QgsFillSymbolV2(); - mFillSymbol->changeSymbolLayer( 0, mSimpleFill ); - - //setup marker line fill - mMarkerLine = new QgsMarkerLineSymbolLayerV2(); - mMarkerLineSymbol = new QgsFillSymbolV2(); - mMarkerLineSymbol->changeSymbolLayer( 0, mMarkerLine ); - mReport = "

Composer Paper Tests

\n"; } @@ -123,9 +105,14 @@ void TestQgsComposerPaper::defaultPaper() void TestQgsComposerPaper::transparentPaper() { - mSimpleFill->setColor( Qt::transparent ); - mSimpleFill->setBorderColor( Qt::transparent ); - mComposition->setPageStyleSymbol( mFillSymbol ); + QgsSimpleFillSymbolLayerV2* simpleFill = new QgsSimpleFillSymbolLayerV2(); + QgsFillSymbolV2* fillSymbol = new QgsFillSymbolV2(); + fillSymbol->changeSymbolLayer( 0, simpleFill ); + simpleFill->setColor( Qt::transparent ); + simpleFill->setBorderColor( Qt::transparent ); + mComposition->setPageStyleSymbol( fillSymbol ); + delete fillSymbol; + QgsCompositionChecker checker( "composerpaper_transparent", mComposition ); checker.setControlPathPrefix( "composer_paper" ); QVERIFY( checker.testComposition( mReport ) ); @@ -133,9 +120,15 @@ void TestQgsComposerPaper::transparentPaper() void TestQgsComposerPaper::borderedPaper() { - mSimpleFill->setColor( Qt::white ); - mSimpleFill->setBorderColor( Qt::black ); - mSimpleFill->setBorderWidth( 6 ); + QgsSimpleFillSymbolLayerV2* simpleFill = new QgsSimpleFillSymbolLayerV2(); + QgsFillSymbolV2* fillSymbol = new QgsFillSymbolV2(); + fillSymbol->changeSymbolLayer( 0, simpleFill ); + simpleFill->setColor( Qt::white ); + simpleFill->setBorderColor( Qt::black ); + simpleFill->setBorderWidth( 6 ); + mComposition->setPageStyleSymbol( fillSymbol ); + delete fillSymbol; + QgsCompositionChecker checker( "composerpaper_bordered", mComposition ); checker.setControlPathPrefix( "composer_paper" ); QVERIFY( checker.testComposition( mReport ) ); @@ -143,7 +136,12 @@ void TestQgsComposerPaper::borderedPaper() void TestQgsComposerPaper::markerLinePaper() { - mComposition->setPageStyleSymbol( mMarkerLineSymbol ); + QgsMarkerLineSymbolLayerV2* markerLine = new QgsMarkerLineSymbolLayerV2(); + QgsFillSymbolV2* markerLineSymbol = new QgsFillSymbolV2(); + markerLineSymbol->changeSymbolLayer( 0, markerLine ); + mComposition->setPageStyleSymbol( markerLineSymbol ); + delete markerLineSymbol; + QgsCompositionChecker checker( "composerpaper_markerborder", mComposition ); checker.setControlPathPrefix( "composer_paper" ); QVERIFY( checker.testComposition( mReport, 0, 0 ) ); diff --git a/tests/src/core/testqgscomposershapes.cpp b/tests/src/core/testqgscomposershapes.cpp index c4ccc66778e..5c6052b73bc 100644 --- a/tests/src/core/testqgscomposershapes.cpp +++ b/tests/src/core/testqgscomposershapes.cpp @@ -37,8 +37,6 @@ class TestQgsComposerShapes : public QObject : mComposition( 0 ) , mComposerShape( 0 ) , mMapSettings( 0 ) - , mSimpleFill( 0 ) - , mFillSymbol( 0 ) {} private slots: @@ -56,8 +54,6 @@ class TestQgsComposerShapes : public QObject QgsComposition* mComposition; QgsComposerShape* mComposerShape; QgsMapSettings *mMapSettings; - QgsSimpleFillSymbolLayerV2* mSimpleFill; - QgsFillSymbolV2* mFillSymbol; QString mReport; }; @@ -75,11 +71,6 @@ void TestQgsComposerShapes::initTestCase() mComposerShape->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) ); mComposition->addComposerShape( mComposerShape ); - //setup simple fill - mSimpleFill = new QgsSimpleFillSymbolLayerV2(); - mFillSymbol = new QgsFillSymbolV2(); - mFillSymbol->changeSymbolLayer( 0, mSimpleFill ); - mReport = "

Composer Shape Tests

\n"; } @@ -151,12 +142,17 @@ void TestQgsComposerShapes::symbolV2() { mComposerShape->setShapeType( QgsComposerShape::Rectangle ); - mSimpleFill->setColor( Qt::green ); - mSimpleFill->setBorderColor( Qt::yellow ); - mSimpleFill->setBorderWidth( 6 ); + //setup simple fill + QgsSimpleFillSymbolLayerV2* simpleFill = new QgsSimpleFillSymbolLayerV2(); + QgsFillSymbolV2* fillSymbol = new QgsFillSymbolV2(); + fillSymbol->changeSymbolLayer( 0, simpleFill ); + simpleFill->setColor( Qt::green ); + simpleFill->setBorderColor( Qt::yellow ); + simpleFill->setBorderWidth( 6 ); - mComposerShape->setShapeStyleSymbol( mFillSymbol ); + mComposerShape->setShapeStyleSymbol( fillSymbol ); mComposerShape->setUseSymbolV2( true ); + delete fillSymbol; QgsCompositionChecker checker( "composershapes_symbolv2", mComposition ); checker.setControlPathPrefix( "composer_shapes" );