Skip to content
Permalink
Browse files

Fix some memory leaks exposed by Coverity

  • Loading branch information
nyalldawson committed Feb 3, 2015
1 parent 5cacf59 commit 005e158ca4a498bc9eb4b0c5bed9598758eebb14
@@ -49,7 +49,7 @@ inline Node::Node() : mPoint( 0 ), mNext( 0 )

inline Node::~Node()
{

delete mPoint;
}

inline Node* Node::getNext() const
@@ -4957,13 +4957,13 @@ void QgisApp::saveAsRasterFile()
// TODO: show error dialogs
// TODO: this code should go somewhere else, but probably not into QgsRasterFileWriter
// clone pipe/provider is not really necessary, ready for threads
QgsRasterPipe* pipe = 0;
QScopedPointer<QgsRasterPipe> pipe( 0 );

if ( d.mode() == QgsRasterLayerSaveAsDialog::RawDataMode )
{
QgsDebugMsg( "Writing raw data" );
//QgsDebugMsg( QString( "Writing raw data" ).arg( pos ) );
pipe = new QgsRasterPipe();
pipe.reset( new QgsRasterPipe() );
if ( !pipe->set( rasterLayer->dataProvider()->clone() ) )
{
QgsDebugMsg( "Cannot set pipe provider" );
@@ -4997,20 +4997,18 @@ void QgisApp::saveAsRasterFile()
{
// clone the whole pipe
QgsDebugMsg( "Writing rendered image" );
pipe = new QgsRasterPipe( *rasterLayer->pipe() );
pipe.reset( new QgsRasterPipe( *rasterLayer->pipe() ) );
QgsRasterProjector *projector = pipe->projector();
if ( !projector )
{
QgsDebugMsg( "Cannot get pipe projector" );
delete pipe;
return;
}
projector->setCRS( rasterLayer->crs(), d.outputCrs() );
}

if ( !pipe->last() )
{
delete pipe;
return;
}
fileWriter.setCreateOptions( d.createOptions() );
@@ -5021,7 +5019,7 @@ void QgisApp::saveAsRasterFile()
fileWriter.setPyramidsFormat( d.pyramidsFormat() );
fileWriter.setPyramidsConfigOptions( d.pyramidsConfigOptions() );

QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe, d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe.data(), d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
if ( err != QgsRasterFileWriter::NoError )
{
QMessageBox::warning( this, tr( "Error" ),
@@ -5033,7 +5031,6 @@ void QgisApp::saveAsRasterFile()
{
emit layerSavedAs( rasterLayer, d.outputFileName() );
}
delete pipe;
}
}

@@ -169,12 +169,12 @@ QgsFeatureList QgsClipboard::copyOf( const QgsFields &fields )
if ( !geometry )
continue;

QgsFeature* feature = new QgsFeature();
QgsFeature feature;
if ( !fields.isEmpty() )
feature->setFields( &fields, true );
feature.setFields( &fields, true );

feature->setGeometry( geometry );
features.append( QgsFeature( *feature ) );
feature.setGeometry( geometry );
features.append( feature );
}

if ( features.isEmpty() )
@@ -477,7 +477,9 @@ void QgsRelationReferenceWidget::highlightFeature( QgsFeature f, CanvasExtent ca
}
else if ( canvasExtent == Pan )
{
QgsPoint center = geom->centroid()->asPoint();
QgsGeometry* centroid = geom->centroid();
QgsPoint center = centroid->asPoint();
delete centroid;
center = mCanvas->mapSettings().layerToMapCoordinates( mReferencedLayer, center );
mCanvas->zoomByFactor( 1.0, &center ); // refresh is done in this method
}
@@ -216,6 +216,7 @@ QgsValueRelationWidgetWrapper::ValueRelationCache QgsValueRelationWidgetWrapper:
cache.append( ValueRelationItem( f.attribute( ki ), f.attribute( vi ).toString() ) );
}
}
delete e;
}

if ( config.value( "OrderByValue" ).toBool() )
@@ -23,6 +23,10 @@ QgsAttributeFormInterface::QgsAttributeFormInterface( QgsAttributeForm* form )
{
}

QgsAttributeFormInterface::~QgsAttributeFormInterface()
{
}

bool QgsAttributeFormInterface::acceptChanges( const QgsFeature& feature )
{
Q_UNUSED( feature )
@@ -24,6 +24,8 @@ class GUI_EXPORT QgsAttributeFormInterface
public:
explicit QgsAttributeFormInterface( QgsAttributeForm* form );

virtual ~QgsAttributeFormInterface();

virtual bool acceptChanges( const QgsFeature& feature );

virtual void initForm();

0 comments on commit 005e158

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