Skip to content
Permalink
Browse files

Fix various Coverity errors (inc mem leaks)

  • Loading branch information
nyalldawson committed Oct 16, 2015
1 parent 772ab8e commit 725f97384045e40ff7a115f7006161dbeede12a9
@@ -88,15 +88,15 @@ void QgsDecorationGridDialog::updateGuiElements()
delete mLineSymbol;
if ( mDeco.lineSymbol() )
{
mLineSymbol = dynamic_cast<QgsLineSymbolV2*>( mDeco.lineSymbol()->clone() );
mLineSymbol = static_cast<QgsLineSymbolV2*>( mDeco.lineSymbol()->clone() );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mLineSymbol, mLineSymbolButton->iconSize() );
mLineSymbolButton->setIcon( icon );
}
if ( mMarkerSymbol )
delete mMarkerSymbol;
if ( mDeco.markerSymbol() )
{
mMarkerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mDeco.markerSymbol()->clone() );
mMarkerSymbol = static_cast<QgsMarkerSymbolV2*>( mDeco.markerSymbol()->clone() );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol, mMarkerSymbolButton->iconSize() );
mMarkerSymbolButton->setIcon( icon );
}
@@ -973,7 +973,7 @@ bool QgsGeometry::convertToSingleType()
}

QgsGeometryCollectionV2* multiGeom = dynamic_cast<QgsGeometryCollectionV2*>( d->geometry );
if ( multiGeom->partCount() < 1 )
if ( !multiGeom || multiGeom->partCount() < 1 )
return false;

QgsAbstractGeometryV2* firstPart = multiGeom->geometryN( 0 )->clone();
@@ -1664,8 +1664,7 @@ bool QgsPalLayerSettings::dataDefinedEvaluate( DataDefinedProperties p, QVariant
if ( !context )
{
scopedEc.reset( new QgsExpressionContext() );
if ( mCurFeat )
scopedEc->setFeature( *mCurFeat );
scopedEc->setFeature( *mCurFeat );
scopedEc->setFields( mCurFields );
}
QgsExpressionContext* ec = context ? context : scopedEc.data();
@@ -804,6 +804,9 @@ void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()

void QgsGraduatedSymbolRendererV2Widget::updateGraduatedSymbolIcon()
{
if ( !mGraduatedSymbol )
return;

QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mGraduatedSymbol, btnChangeGraduatedSymbol->iconSize() );
btnChangeGraduatedSymbol->setIcon( icon );
}
@@ -203,7 +203,7 @@ void QgsSizeScaleWidget::updatePreview()
int widthMax = 0;
for ( int i = 0; i < breaks.length(); i++ )
{
QScopedPointer< QgsMarkerSymbolV2 > symbol( dynamic_cast<QgsMarkerSymbolV2*>( mSymbol->clone() ) );
QScopedPointer< QgsMarkerSymbolV2 > symbol( static_cast<QgsMarkerSymbolV2*>( mSymbol->clone() ) );
symbol->setDataDefinedSize( QgsDataDefined() );
symbol->setDataDefinedAngle( QgsDataDefined() ); // to avoid symbol not beeing drawn
symbol->setSize( expr->size( breaks[i] ) );
@@ -60,7 +60,7 @@ QgsGrassEditRenderer::QgsGrassEditRenderer()
QgsMarkerSymbolV2 * markerSymbol = new QgsMarkerSymbolV2( markerLayers );
firstVertexMarkerLine->setSubSymbol( markerSymbol );
firstVertexMarkerLine->setPlacement( QgsMarkerLineSymbolLayerV2::FirstVertex );
QgsMarkerLineSymbolLayerV2 * lastVertexMarkerLine = dynamic_cast<QgsMarkerLineSymbolLayerV2 *>( firstVertexMarkerLine->clone() );
QgsMarkerLineSymbolLayerV2 * lastVertexMarkerLine = static_cast<QgsMarkerLineSymbolLayerV2 *>( firstVertexMarkerLine->clone() );
lastVertexMarkerLine->setPlacement( QgsMarkerLineSymbolLayerV2::LastVertex );
foreach ( int value, colors.keys() )
{
@@ -101,6 +101,8 @@ QgsGrassEditRenderer::QgsGrassEditRenderer()

QgsGrassEditRenderer::~QgsGrassEditRenderer()
{
delete mMarkerRenderer;
delete mLineRenderer;
}

void QgsGrassEditRenderer::setLineRenderer( QgsFeatureRendererV2 *renderer )
@@ -260,6 +262,8 @@ QgsRendererV2Widget* QgsGrassEditRendererWidget::create( QgsVectorLayer* layer,
QgsGrassEditRendererWidget::QgsGrassEditRendererWidget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
: QgsRendererV2Widget( layer, style )
, mRenderer( 0 )
, mLineRendererWidget( 0 )
, mPointRendererWidget( 0 )
{
QgsDebugMsg( "entered" );
mRenderer = dynamic_cast<QgsGrassEditRenderer*>( renderer->clone() );
@@ -408,6 +408,7 @@ void QgsGrassPlugin::onEditingStarted()
{
QgsDebugMsg( editStyleName + " style exists -> set as current" );
vectorLayer->styleManager()->setCurrentStyle( editStyleName );
delete renderer;
}
else
{
@@ -193,6 +193,8 @@ QgsGrassRegion::QgsGrassRegion( QgisInterface *iface,
QWidget * parent, Qt::WindowFlags f )
: QWidget( parent, f )
, QgsGrassRegionBase()
, mX( 0 )
, mY( 0 )
, mRegionEdit( 0 )
{
QgsDebugMsg( "QgsGrassRegion()" );
@@ -775,6 +775,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData * data, Qt::DropAction )
{
import = new QgsGrassExternal( rasterProvider->dataSourceUri(), rasterObject );
delete rasterProvider;
delete pipe;
}
else
{
@@ -193,12 +193,14 @@ QgsGrassVector::QgsGrassVector( const QString& gisdbase, const QString& location
const QString& name, QObject *parent )
: QObject( parent )
, mGrassObject( gisdbase, location, mapset, name )
, mNodeCount( 0 )
{
}

QgsGrassVector::QgsGrassVector( const QgsGrassObject& grassObject, QObject *parent )
: QObject( parent )
, mGrassObject( grassObject )
, mNodeCount( 0 )
{
}

@@ -267,6 +267,7 @@ void QgsGrassVectorMapLayer::load()
break;
case DB_C_TYPE_DATETIME:
variant = QVariant( QByteArray( db_get_string( &dbstr ) ) );
break;
default:
variant = QVariant( QByteArray( db_get_string( &dbstr ) ) );
}
@@ -52,7 +52,7 @@ extern "C"
class TestQgsGrassFeature : public QgsFeature
{
public:
TestQgsGrassFeature() {}
TestQgsGrassFeature() : grassType( 0 ) {}
TestQgsGrassFeature( int type ) : grassType( type ) {}

int grassType;
@@ -73,8 +73,8 @@ class TestQgsGrassCommand
ChangeAttributeValue
};

TestQgsGrassCommand() {}
TestQgsGrassCommand( Command c ) : command( c ), geometry( 0 ) {}
TestQgsGrassCommand() : command( AddFeature ), fid( 0 ), geometry( 0 ) {}
TestQgsGrassCommand( Command c ) : command( c ), fid( 0 ), geometry( 0 ) {}

QString toString() const;
Command command;

0 comments on commit 725f973

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