Skip to content
Permalink
Browse files

Fix some leaks in symbology widgets

  • Loading branch information
nyalldawson committed Sep 1, 2015
1 parent e602a58 commit d7ab102dafbbdffcbad0a1e423ebef3dcce5d429
@@ -113,15 +113,22 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2
void setSourceSymbol( QgsSymbolV2* sym /Transfer/ );

QgsVectorColorRampV2* sourceColorRamp();

/** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer
*/
void setSourceColorRamp( QgsVectorColorRampV2* ramp /Transfer/ );

//! @note added in 2.1
bool invertedColorRamp();
void setInvertedColorRamp( bool inverted );

// Update the color ramp used and all symbols colors.
//! @note added in 2.5
void updateColorRamp( QgsVectorColorRampV2* ramp, bool inverted = false );
/** Update the color ramp used and all symbols colors.
* @param ramp color ramp. Ownership is transferred to the renderer
* @param inverted set to true to invert ramp colors
* @note added in 2.5
*/
void updateColorRamp( QgsVectorColorRampV2* ramp /Transfer/, bool inverted = false );

void setRotationField( QString fieldOrExpression ) /Deprecated/;
QString rotationField() const /Deprecated/;
@@ -213,13 +213,20 @@ class QgsGraduatedSymbolRendererV2 : QgsFeatureRendererV2
void setSourceSymbol( QgsSymbolV2* sym /Transfer/ );

QgsVectorColorRampV2* sourceColorRamp();

/** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer
*/
void setSourceColorRamp( QgsVectorColorRampV2* ramp /Transfer/ );

//! @note added in 2.1
bool invertedColorRamp();
void setInvertedColorRamp( bool inverted );

/** Update the color ramp used. Also updates all symbols colors.
* Doesn't alter current breaks.
* @param ramp color ramp. Ownership is transferred to the renderer
* @param inverted set to true to invert ramp colors
*/
void updateColorRamp( QgsVectorColorRampV2* ramp /Transfer/ = 0, bool inverted = false );

@@ -146,14 +146,21 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2
void setSourceSymbol( QgsSymbolV2* sym );

QgsVectorColorRampV2* sourceColorRamp();

/** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer
*/
void setSourceColorRamp( QgsVectorColorRampV2* ramp );

//! @note added in 2.1
bool invertedColorRamp() { return mInvertedColorRamp; }
void setInvertedColorRamp( bool inverted ) { mInvertedColorRamp = inverted; }

// Update the color ramp used and all symbols colors.
//! @note added in 2.5
/** Update the color ramp used and all symbols colors.
* @param ramp color ramp. Ownership is transferred to the renderer
* @param inverted set to true to invert ramp colors
* @note added in 2.5
*/
void updateColorRamp( QgsVectorColorRampV2* ramp, bool inverted = false );

Q_DECL_DEPRECATED void setRotationField( QString fieldOrExpression ) override;
@@ -259,13 +259,20 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2
void setSourceSymbol( QgsSymbolV2* sym );

QgsVectorColorRampV2* sourceColorRamp();

/** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer
*/
void setSourceColorRamp( QgsVectorColorRampV2* ramp );

//! @note added in 2.1
bool invertedColorRamp() { return mInvertedColorRamp; }
void setInvertedColorRamp( bool inverted ) { mInvertedColorRamp = inverted; }

/** Update the color ramp used. Also updates all symbols colors.
* Doesn't alter current breaks.
* @param ramp color ramp. Ownership is transferred to the renderer
* @param inverted set to true to invert ramp colors
*/
void updateColorRamp( QgsVectorColorRampV2* ramp = 0, bool inverted = false );

@@ -472,6 +472,7 @@ QgsCategorizedSymbolRendererV2Widget::~QgsCategorizedSymbolRendererV2Widget()
{
if ( mRenderer ) delete mRenderer;
if ( mModel ) delete mModel;
delete mCategorizedSymbol;
}

void QgsCategorizedSymbolRendererV2Widget::updateUiFromRenderer()
@@ -557,6 +558,7 @@ void QgsCategorizedSymbolRendererV2Widget::changeCategorizedSymbol()
return;
}

delete mCategorizedSymbol;
mCategorizedSymbol = newSymbol;
updateCategorizedSymbolIcon();

@@ -781,14 +783,15 @@ void QgsCategorizedSymbolRendererV2Widget::addCategories()
delete mRenderer;
mRenderer = r;
if ( ! keepExistingColors && ramp ) applyColorRamp();
delete ramp;
}

void QgsCategorizedSymbolRendererV2Widget::applyColorRamp()
{
QgsVectorColorRampV2* ramp = getColorRamp();
if ( ramp )
{
mRenderer->updateColorRamp( ramp->clone(), cbxInvertedColorRamp->isChecked() );
mRenderer->updateColorRamp( ramp, cbxInvertedColorRamp->isChecked() );
}
mModel->updateSymbology();
}
@@ -87,6 +87,7 @@ bool QgsColorRampComboBox::createNewColorRampSelected() const

void QgsColorRampComboBox::setSourceColorRamp( QgsVectorColorRampV2* sourceRamp )
{
delete mSourceColorRamp;
mSourceColorRamp = sourceRamp->clone();

QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon( mSourceColorRamp, rampIconSize );
@@ -503,6 +503,7 @@ QgsGraduatedSymbolRendererV2Widget::~QgsGraduatedSymbolRendererV2Widget()
{
delete mRenderer;
delete mModel;
delete mGraduatedSymbol;
}

QgsFeatureRendererV2* QgsGraduatedSymbolRendererV2Widget::renderer()
@@ -645,7 +646,7 @@ void QgsGraduatedSymbolRendererV2Widget::on_methodComboBox_currentIndexChanged(
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
return;
}
mRenderer->setSourceColorRamp( ramp->clone() );
mRenderer->setSourceColorRamp( ramp );
reapplyColorRamp();
}
else
@@ -716,7 +717,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
return;
}
mRenderer->setSourceColorRamp( ramp->clone() );
mRenderer->setSourceColorRamp( ramp );
}
else
{
@@ -775,6 +776,7 @@ void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
return;
}

delete mGraduatedSymbol;
mGraduatedSymbol = newSymbol;

mSizeUnitWidget->blockSignals( true );
@@ -231,7 +231,7 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
btnUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) );
btnDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) );

model = new QStandardItemModel();
model = new QStandardItemModel( layersTree );
// Set the symbol
layersTree->setModel( model );
layersTree->setHeaderHidden( true );
@@ -273,7 +273,7 @@ QMenu* QgsSymbolV2SelectorDialog::advancedMenu()
{
if ( mAdvancedMenu == NULL )
{
mAdvancedMenu = new QMenu;
mAdvancedMenu = new QMenu( this );
// Brute force method to activate the Advanced menu
layerChanged();
}

0 comments on commit d7ab102

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