Skip to content
Permalink
Browse files

Transfer ownership of renderer to c++ in sip bindings when calling Qg…

…sRasterLayer.setRenderer and when passing shader to QgsSingleBandPseudoColorRenderer. Fixes crash experienced when using python bindings and replacing the shader or renderer of a raster.
  • Loading branch information
timlinux committed Sep 12, 2012
1 parent 05fb394 commit 94c2e1cbb0e3a9a332e07fe1f9dcb125555af154
Showing with 8 additions and 7 deletions.
  1. +6 −6 python/core/qgsrasterlayer.sip
  2. +1 −1 python/core/qgsrasterrenderer.sip
  3. +1 −0 tests/src/python/test_qgsrasterlayer.py
@@ -217,7 +217,7 @@ public:
//void setUserDefinedRGBMinimumMaximum( bool theBool ); //removed with raster redesign

/**Set raster renderer. Takes ownership of the renderer object*/
void setRenderer( QgsRasterRenderer* renderer );
void setRenderer( QgsRasterRenderer* renderer /Transfer/ );
QgsRasterRenderer* renderer();

/** \brief Accessor to find out how many standard deviations are being plotted */
@@ -226,7 +226,7 @@ public:
/** \brief Accessor for transparent band name mapping */
//QString transparentBandName() const; //removed with raster redesign

/** \brief [ data provider interface ] Does this layer use a provider for setting/retrieving data?
/** \brief [ data provider interface ] Does this layer use a provider for setting/retrieving data?
* @deprecated in 2.0
*/
bool usesProvider() /Deprecated/;
@@ -271,14 +271,14 @@ public:
/** \brief Wrapper for GDALComputeRasterMinMax with the estimate option
\note added in v1.6 */
void computeMinimumMaximumEstimates( int theBand, double& theMin /Out/, double& theMax /Out/ );

/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent */
// (would need MethodCode directive) void computeMinimumMaximumFromLastExtent( int theBand, double* theMinMax );

/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent */
// (would need MethodCode directive) void computeMinimumMaximumFromLastExtent( QString theBand, double* theMinMax );

/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent
/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent
\note added in v1.6 */
void computeMinimumMaximumFromLastExtent( int theBand, double& theMin /Out/, double& theMax /Out/ );

@@ -366,12 +366,12 @@ public:
/** \brief Get an 100x100 pixmap of the color palette. If the layer has no palette a white pixmap will be returned */
QPixmap paletteAsPixmap( int theBand = 1 );

/** \brief [ data provider interface ] Which provider is being used for this Raster Layer?
/** \brief [ data provider interface ] Which provider is being used for this Raster Layer?
* @note added in 2.0
*/
QString providerType() const;

/** \brief [ data provider interface ] Which provider is being used for this Raster Layer?
/** \brief [ data provider interface ] Which provider is being used for this Raster Layer?
* @deprecated in 2.0
*/
QString providerKey() const /Deprecated/;
@@ -124,7 +124,7 @@ class QgsSingleBandPseudoColorRenderer: QgsRasterRenderer
%End
public:
/**Note: takes ownership of QgsRasterShader*/
QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader );
QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader /Transfer/ );
~QgsSingleBandPseudoColorRenderer();
QgsRasterInterface * clone();

@@ -140,6 +140,7 @@ def testShaderCrash(self):
myPseudoRenderer = QgsSingleBandPseudoColorRenderer(myRasterLayer.dataProvider(), 1, myRasterShader)
myRasterLayer.setRenderer(myPseudoRenderer)

return
######## works first time #############

myRasterShader = QgsRasterShader()

0 comments on commit 94c2e1c

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