Skip to content

Commit

Permalink
Fix #11455 (Crash when setting transparency for WMS layer)
Browse files Browse the repository at this point in the history
Layer transparency instance was not copied when renderers were cloned.
  • Loading branch information
wonder-sk committed Oct 22, 2014
1 parent 6db04b4 commit c9e05f9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/raster/qgsmultibandcolorrenderer.cpp
Expand Up @@ -57,7 +57,7 @@ QgsRasterInterface * QgsMultiBandColorRenderer::clone() const
}
renderer->setOpacity( mOpacity );
renderer->setAlphaBand( mAlphaBand );
renderer->setRasterTransparency( mRasterTransparency );
renderer->setRasterTransparency( new QgsRasterTransparency( *mRasterTransparency ) );

return renderer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgspalettedrasterrenderer.cpp
Expand Up @@ -51,7 +51,7 @@ QgsRasterInterface * QgsPalettedRasterRenderer::clone() const
QgsPalettedRasterRenderer * renderer = new QgsPalettedRasterRenderer( 0, mBand, rgbArray(), mNColors );
renderer->setOpacity( mOpacity );
renderer->setAlphaBand( mAlphaBand );
renderer->setRasterTransparency( mRasterTransparency );
renderer->setRasterTransparency( new QgsRasterTransparency( *mRasterTransparency ) );
renderer->mLabels = mLabels;
return renderer;
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgssinglebandcolordatarenderer.cpp
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgssinglebandcolordatarenderer.h"
#include "qgsrastertransparency.h"
#include "qgsrasterviewport.h"
#include <QDomDocument>
#include <QDomElement>
Expand All @@ -36,7 +37,7 @@ QgsRasterInterface * QgsSingleBandColorDataRenderer::clone() const
QgsSingleBandColorDataRenderer * renderer = new QgsSingleBandColorDataRenderer( 0, mBand );
renderer->setOpacity( mOpacity );
renderer->setAlphaBand( mAlphaBand );
renderer->setRasterTransparency( mRasterTransparency );
renderer->setRasterTransparency( new QgsRasterTransparency( *mRasterTransparency ) );
return renderer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandgrayrenderer.cpp
Expand Up @@ -37,7 +37,7 @@ QgsRasterInterface * QgsSingleBandGrayRenderer::clone() const
QgsSingleBandGrayRenderer * renderer = new QgsSingleBandGrayRenderer( 0, mGrayBand );
renderer->setOpacity( mOpacity );
renderer->setAlphaBand( mAlphaBand );
renderer->setRasterTransparency( mRasterTransparency );
renderer->setRasterTransparency( new QgsRasterTransparency( *mRasterTransparency ) );
renderer->setGradient( mGradient );
if ( mContrastEnhancement )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Expand Up @@ -63,7 +63,7 @@ QgsRasterInterface * QgsSingleBandPseudoColorRenderer::clone() const

renderer->setOpacity( mOpacity );
renderer->setAlphaBand( mAlphaBand );
renderer->setRasterTransparency( mRasterTransparency );
renderer->setRasterTransparency( new QgsRasterTransparency( *mRasterTransparency ) );

return renderer;
}
Expand Down

3 comments on commit c9e05f9

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wonder-sk This change has introduced a ton of crashes - you can see them if you try and run the test suite, or at http://dash.orfeo-toolbox.org/viewTest.php?onlyfailed&buildid=161197 . I think in some cases mRasterTransparency is not set, so the copy constructor causes a segfault.

@wonder-sk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh what a shameful "fix" - going to fix it... thanks for pointing it out

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wonder-sk don't worry, you're excused... 2600CHF to go and we won't have to check this anymore! ;)

Please sign in to comment.