Skip to content

Commit

Permalink
More Coverity memory leak fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 27, 2015
1 parent 481b164 commit ec01d76
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions python/core/qgsexpression.sip
Expand Up @@ -195,6 +195,9 @@ class QgsExpression
{
public:
Function( const QString& fnname, int params, const QString& group, const QString& helpText = QString(), bool usesGeometry = false, QStringList referencedColumns = QStringList(), bool lazyEval = false );

virtual ~Function();

/** The name of the function. */
QString name();
/** The number of parameters this function takes. */
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -446,7 +446,7 @@ QgsPoint QgsGeometry::vertexAt( int atVertex ) const
}

QgsVertexId vId;
vertexIdFromVertexNr( atVertex, vId );
( void )vertexIdFromVertexNr( atVertex, vId );
if ( vId.vertex < 0 )
{
return QgsPoint( 0, 0 );
Expand Down Expand Up @@ -982,7 +982,7 @@ QgsMultiPoint QgsGeometry::asMultiPoint() const
QgsMultiPoint multiPoint( nPoints );
for ( int i = 0; i < nPoints; ++i )
{
const QgsPointV2* pt = dynamic_cast<const QgsPointV2*>( mp->geometryN( i ) );
const QgsPointV2* pt = static_cast<const QgsPointV2*>( mp->geometryN( i ) );
multiPoint[i].setX( pt->x() );
multiPoint[i].setY( pt->y() );
}
Expand Down
11 changes: 8 additions & 3 deletions src/core/qgsexpression.h
Expand Up @@ -288,6 +288,9 @@ class CORE_EXPORT QgsExpression
public:
Function( const QString& fnname, int params, QString group, QString helpText = QString(), bool usesGeometry = false, QStringList referencedColumns = QStringList(), bool lazyEval = false )
: mName( fnname ), mParams( params ), mUsesGeometry( usesGeometry ), mGroup( group ), mHelpText( helpText ), mReferencedColumns( referencedColumns ), mLazyEval( lazyEval ) {}

virtual ~Function() {}

/** The name of the function. */
QString name() { return mName; }
/** The number of parameters this function takes. */
Expand Down Expand Up @@ -340,6 +343,8 @@ class CORE_EXPORT QgsExpression
StaticFunction( QString fnname, int params, FcnEval fcn, QString group, QString helpText = QString(), bool usesGeometry = false, QStringList referencedColumns = QStringList(), bool lazyEval = false, const QStringList& aliases = QStringList() )
: Function( fnname, params, group, helpText, usesGeometry, referencedColumns, lazyEval ), mFnc( fcn ), mAliases( aliases ) {}

virtual ~StaticFunction() {}

virtual QVariant func( const QVariantList& values, const QgsFeature* f, QgsExpression* parent ) override
{
return mFnc( values, f, parent );
Expand Down Expand Up @@ -537,10 +542,10 @@ class CORE_EXPORT QgsExpression

virtual QStringList referencedColumns() const override { QStringList lst( mNode->referencedColumns() ); foreach ( Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual bool needsGeometry() const override { bool needs = false; foreach ( Node* n, mList->list() ) needs |= n->needsGeometry(); return needs; }
virtual void accept( Visitor& v ) const override { v.visit( *this ); }
virtual void accept( Visitor& v ) const override { v.visit( *this ); }

protected:
Node* mNode;
protected:
Node* mNode;
NodeList* mList;
bool mNotIn;
};
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsgraduatedhistogramwidget.cpp
Expand Up @@ -171,7 +171,7 @@ bool QgsGraduatedHistogramEventFilter::eventFilter( QObject *object, QEvent *eve
{
case QEvent::MouseButtonPress:
{
const QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent* >( event );
const QMouseEvent* mouseEvent = static_cast<QMouseEvent* >( event );
if ( mouseEvent->button() == Qt::LeftButton )
{
emit mousePress( posToValue( mouseEvent->pos() ) );
Expand All @@ -180,7 +180,7 @@ bool QgsGraduatedHistogramEventFilter::eventFilter( QObject *object, QEvent *eve
}
case QEvent::MouseButtonRelease:
{
const QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent* >( event );
const QMouseEvent* mouseEvent = static_cast<QMouseEvent* >( event );
if ( mouseEvent->button() == Qt::LeftButton )
{
emit mouseRelease( posToValue( mouseEvent->pos() ) );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgssizescalewidget.cpp
Expand Up @@ -40,7 +40,7 @@ class ItemDelegate : public QItemDelegate
QSize sizeHint( const QStyleOptionViewItem& /*option*/, const QModelIndex & index ) const override
{
return mModel->item( index.row() )->icon().actualSize( QSize( 512, 512 ) );
}
}

private:
QStandardItemModel* mModel;
Expand Down Expand Up @@ -162,7 +162,7 @@ void QgsSizeScaleWidget::updatePreview()
{
QScopedPointer< QgsMarkerSymbolV2 > symbol( dynamic_cast<QgsMarkerSymbolV2*>( mSymbol->clone() ) );
symbol->setDataDefinedSize( QgsDataDefined() );
symbol->setDataDefinedAngle( "" ); // to avoid symbol not beeing drawn
symbol->setDataDefinedAngle( QgsDataDefined() ); // to avoid symbol not beeing drawn
symbol->setSize( expr->size( breaks[i] ) );
QgsSymbolV2LegendNode node( mLayerTreeLayer, QgsLegendSymbolItemV2( symbol.data(), QString::number( i ), 0 ) );
const QSize sz( node.minimumIconSize() );
Expand Down

0 comments on commit ec01d76

Please sign in to comment.