Skip to content

Commit

Permalink
Transfer ownership of renderer to c++ in sip bindings when calling Qg…
Browse files Browse the repository at this point in the history
…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 94c2e1c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions python/core/qgsrasterlayer.sip
Expand Up @@ -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 */
Expand All @@ -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/;
Expand Down Expand Up @@ -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/ );

Expand Down Expand Up @@ -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/;
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsrasterrenderer.sip
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgsrasterlayer.py
Expand Up @@ -140,6 +140,7 @@ def testShaderCrash(self):
myPseudoRenderer = QgsSingleBandPseudoColorRenderer(myRasterLayer.dataProvider(), 1, myRasterShader)
myRasterLayer.setRenderer(myPseudoRenderer)

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

myRasterShader = QgsRasterShader()
Expand Down

0 comments on commit 94c2e1c

Please sign in to comment.