Skip to content

Commit

Permalink
Fix Coverity issues:
Browse files Browse the repository at this point in the history
- uninitialized members
- memory leaks
  • Loading branch information
nyalldawson committed Oct 10, 2015
1 parent 9f67f4c commit d72587f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 8 deletions.
6 changes: 6 additions & 0 deletions python/core/qgis.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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 )
{
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdatasourceuri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/gui/auth/qgsauthcertificateinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
7 changes: 7 additions & 0 deletions src/gui/auth/qgsautheditorwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
1 change: 1 addition & 0 deletions src/gui/auth/qgsauthimportidentitydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/topology/topolError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/topology/topolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );

Expand All @@ -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;
Expand Down

0 comments on commit d72587f

Please sign in to comment.