Skip to content
Permalink
Browse files

Fix Coverity issues:

- uninitialized members
- memory leaks
  • Loading branch information
nyalldawson committed Oct 10, 2015
1 parent 9f67f4c commit d72587f436151acffee26bd1d64969978532e0ff
@@ -66,6 +66,12 @@ class QGis
static bool isMultiType( WkbType type );
static int wkbDimensions( WkbType type );

//! Converts from old (pre 2.10) WKB type to new WKB type
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type);

//! Converts from new (post 2.10) WKB type to old WKB type
static QGis::WkbType fromNewWkbType( QgsWKBTypes::Type type );

enum GeometryType
{
Point,
@@ -100,7 +100,7 @@ const char* QGis::qgisUnitTypes[] =
QT_TRANSLATE_NOOP( "QGis::UnitType", "nautical miles" )
};

static QgsWKBTypes::Type fromOldWkbType( QGis::WkbType type )
QgsWKBTypes::Type QGis::fromOldWkbType( QGis::WkbType type )
{
switch ( type )
{
@@ -125,7 +125,7 @@ static QgsWKBTypes::Type fromOldWkbType( QGis::WkbType type )
return ( QgsWKBTypes::Type ) type;
}

static QGis::WkbType fromNewWkbType( QgsWKBTypes::Type type )
QGis::WkbType QGis::fromNewWkbType( QgsWKBTypes::Type type )
{
switch ( type )
{
@@ -27,6 +27,7 @@
#include <cfloat>
#include <cmath>
#include <qnumeric.h>
#include "geometry/qgswkbtypes.h"

/** \ingroup core
* The QGis class provides global constants for use throughout the application.
@@ -93,6 +94,12 @@ class CORE_EXPORT QGis
// @deprecated use QgsWKBTypes::hasZ() and QgsWKBTypes::hasM()
/* Q_DECL_DEPRECATED */ static int wkbDimensions( WkbType type );

//! Converts from old (pre 2.10) WKB type to new WKB type
static QgsWKBTypes::Type fromOldWkbType( QGis::WkbType type );

//! Converts from new (post 2.10) WKB type to old WKB type
static QGis::WkbType fromNewWkbType( QgsWKBTypes::Type type );

enum GeometryType
{
Point,
@@ -139,7 +139,7 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
}
else if ( pname == "type" )
{
mWkbType = ( QGis::WkbType )QgsWKBTypes::parseType( pval );
mWkbType = QGis::fromNewWkbType( QgsWKBTypes::parseType( pval ) );
}
else if ( pname == "selectatid" )
{
@@ -1737,7 +1737,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
// we must force the use of 25D.
if ( mWkbType >= QGis::WKBPoint25D && mWkbType <= QGis::WKBMultiPolygon25D )
{
QgsWKBTypes::Type wkbType = ( QgsWKBTypes::Type )geom->wkbType();
QgsWKBTypes::Type wkbType = QGis::fromOldWkbType( geom->wkbType() );
if ( wkbType >= QgsWKBTypes::PointZ && wkbType <= QgsWKBTypes::MultiPolygonZ )
{
QGis::WkbType wkbType25d = ( QGis::WkbType )( geom->wkbType() - QgsWKBTypes::PointZ + QgsWKBTypes::Point25D );
@@ -57,8 +57,11 @@ QgsAuthCertInfo::QgsAuthCertInfo( const QSslCertificate& cert,
, mDefaultItemForeground( QBrush() )
, mManageTrust( manageCertTrust )
, mTrustCacheRebuilt( false )
, mDefaultTrustPolicy( QgsAuthCertUtils::DefaultTrust )
, mCurrentTrustPolicy( QgsAuthCertUtils::DefaultTrust )
, mSecGeneral( 0 )
, mSecDetails( 0 )
, mSecPemText( 0 )
, mGrpSubj( 0 )
, mGrpIssu( 0 )
, mGrpCert( 0 )
@@ -104,6 +104,13 @@ void QgsAuthMethodPlugins::populateTable()

QgsAuthEditorWidgets::QgsAuthEditorWidgets( QWidget *parent )
: QWidget( parent )
, mAuthUtilitiesMenu( 0 )
, mActionSetMasterPassword( 0 )
, mActionClearCachedMasterPassword( 0 )
, mActionResetMasterPassword( 0 )
, mActionClearCachedAuthConfigs( 0 )
, mActionRemoveAuthConfigs( 0 )
, mActionEraseAuthDatabase( 0 )
{
setupUi( this );
if ( !QgsAuthManager::instance()->isDisabled() )
@@ -52,6 +52,7 @@ static QByteArray fileData_( const QString& path, bool astext = false )
QgsAuthImportIdentityDialog::QgsAuthImportIdentityDialog( QgsAuthImportIdentityDialog::IdentityType identitytype,
QWidget *parent )
: QDialog( parent )
, mIdentityType( CertIdentity )
, mPkiBundle( QgsPkiBundle() )
, mDisabled( false )
, mAuthNotifyLayout( 0 )
@@ -65,12 +65,12 @@ bool TopolError::fixUnion( FeatureLayer fl1, FeatureLayer fl2 )
if ( !ok )
return false;

QgsGeometry* g = f1.constGeometry()->combine( f2.constGeometry() );
if ( !g )
QScopedPointer< QgsGeometry > g( f1.constGeometry()->combine( f2.constGeometry() ) );
if ( !g.data() )
return false;

if ( fl2.layer->deleteFeature( f2.id() ) )
return fl1.layer->changeGeometry( f1.id(), g );
return fl1.layer->changeGeometry( f1.id(), g.data() );

return false;
}
@@ -695,6 +695,7 @@ ErrorList topolTest::checkGaps( double tolerance, QgsVectorLayer *layer1, QgsVec
//qDebug() << "difference gometry - " << diffGeoms->exportToWkt();

QList<QgsGeometry*> geomColl = diffGeoms->asGeometryCollection();
delete diffGeoms;

QgsGeometry* canvasExtentPoly = QgsGeometry::fromWkt( theQgsInterface->mapCanvas()->extent().asWktPolygon() );

@@ -713,7 +714,6 @@ ErrorList topolTest::checkGaps( double tolerance, QgsVectorLayer *layer1, QgsVec
}
}
QgsRectangle bBox = conflictGeom->boundingBox();
QgsFeature feat;
FeatureLayer ftrLayer1;
ftrLayer1.layer = layer1;
QList<FeatureLayer> errorFtrLayers;

0 comments on commit d72587f

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