Skip to content

Commit d72587f

Browse files
committed
Fix Coverity issues:
- uninitialized members - memory leaks
1 parent 9f67f4c commit d72587f

10 files changed

Lines changed: 32 additions & 8 deletions

File tree

‎python/core/qgis.sip‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class QGis
6666
static bool isMultiType( WkbType type );
6767
static int wkbDimensions( WkbType type );
6868

69+
//! Converts from old (pre 2.10) WKB type to new WKB type
70+
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type);
71+
72+
//! Converts from new (post 2.10) WKB type to old WKB type
73+
static QGis::WkbType fromNewWkbType( QgsWKBTypes::Type type );
74+
6975
enum GeometryType
7076
{
7177
Point,

‎src/core/qgis.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const char* QGis::qgisUnitTypes[] =
100100
QT_TRANSLATE_NOOP( "QGis::UnitType", "nautical miles" )
101101
};
102102

103-
static QgsWKBTypes::Type fromOldWkbType( QGis::WkbType type )
103+
QgsWKBTypes::Type QGis::fromOldWkbType( QGis::WkbType type )
104104
{
105105
switch ( type )
106106
{
@@ -125,7 +125,7 @@ static QgsWKBTypes::Type fromOldWkbType( QGis::WkbType type )
125125
return ( QgsWKBTypes::Type ) type;
126126
}
127127

128-
static QGis::WkbType fromNewWkbType( QgsWKBTypes::Type type )
128+
QGis::WkbType QGis::fromNewWkbType( QgsWKBTypes::Type type )
129129
{
130130
switch ( type )
131131
{

‎src/core/qgis.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <cfloat>
2828
#include <cmath>
2929
#include <qnumeric.h>
30+
#include "geometry/qgswkbtypes.h"
3031

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

97+
//! Converts from old (pre 2.10) WKB type to new WKB type
98+
static QgsWKBTypes::Type fromOldWkbType( QGis::WkbType type );
99+
100+
//! Converts from new (post 2.10) WKB type to old WKB type
101+
static QGis::WkbType fromNewWkbType( QgsWKBTypes::Type type );
102+
96103
enum GeometryType
97104
{
98105
Point,

‎src/core/qgsdatasourceuri.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
139139
}
140140
else if ( pname == "type" )
141141
{
142-
mWkbType = ( QGis::WkbType )QgsWKBTypes::parseType( pval );
142+
mWkbType = QGis::fromNewWkbType( QgsWKBTypes::parseType( pval ) );
143143
}
144144
else if ( pname == "selectatid" )
145145
{

‎src/core/qgsvectorfilewriter.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
17371737
// we must force the use of 25D.
17381738
if ( mWkbType >= QGis::WKBPoint25D && mWkbType <= QGis::WKBMultiPolygon25D )
17391739
{
1740-
QgsWKBTypes::Type wkbType = ( QgsWKBTypes::Type )geom->wkbType();
1740+
QgsWKBTypes::Type wkbType = QGis::fromOldWkbType( geom->wkbType() );
17411741
if ( wkbType >= QgsWKBTypes::PointZ && wkbType <= QgsWKBTypes::MultiPolygonZ )
17421742
{
17431743
QGis::WkbType wkbType25d = ( QGis::WkbType )( geom->wkbType() - QgsWKBTypes::PointZ + QgsWKBTypes::Point25D );

‎src/gui/auth/qgsauthcertificateinfo.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ QgsAuthCertInfo::QgsAuthCertInfo( const QSslCertificate& cert,
5757
, mDefaultItemForeground( QBrush() )
5858
, mManageTrust( manageCertTrust )
5959
, mTrustCacheRebuilt( false )
60+
, mDefaultTrustPolicy( QgsAuthCertUtils::DefaultTrust )
61+
, mCurrentTrustPolicy( QgsAuthCertUtils::DefaultTrust )
6062
, mSecGeneral( 0 )
6163
, mSecDetails( 0 )
64+
, mSecPemText( 0 )
6265
, mGrpSubj( 0 )
6366
, mGrpIssu( 0 )
6467
, mGrpCert( 0 )

‎src/gui/auth/qgsautheditorwidgets.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ void QgsAuthMethodPlugins::populateTable()
104104

105105
QgsAuthEditorWidgets::QgsAuthEditorWidgets( QWidget *parent )
106106
: QWidget( parent )
107+
, mAuthUtilitiesMenu( 0 )
108+
, mActionSetMasterPassword( 0 )
109+
, mActionClearCachedMasterPassword( 0 )
110+
, mActionResetMasterPassword( 0 )
111+
, mActionClearCachedAuthConfigs( 0 )
112+
, mActionRemoveAuthConfigs( 0 )
113+
, mActionEraseAuthDatabase( 0 )
107114
{
108115
setupUi( this );
109116
if ( !QgsAuthManager::instance()->isDisabled() )

‎src/gui/auth/qgsauthimportidentitydialog.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static QByteArray fileData_( const QString& path, bool astext = false )
5252
QgsAuthImportIdentityDialog::QgsAuthImportIdentityDialog( QgsAuthImportIdentityDialog::IdentityType identitytype,
5353
QWidget *parent )
5454
: QDialog( parent )
55+
, mIdentityType( CertIdentity )
5556
, mPkiBundle( QgsPkiBundle() )
5657
, mDisabled( false )
5758
, mAuthNotifyLayout( 0 )

‎src/plugins/topology/topolError.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ bool TopolError::fixUnion( FeatureLayer fl1, FeatureLayer fl2 )
6565
if ( !ok )
6666
return false;
6767

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

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

7575
return false;
7676
}

‎src/plugins/topology/topolTest.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ ErrorList topolTest::checkGaps( double tolerance, QgsVectorLayer *layer1, QgsVec
695695
//qDebug() << "difference gometry - " << diffGeoms->exportToWkt();
696696

697697
QList<QgsGeometry*> geomColl = diffGeoms->asGeometryCollection();
698+
delete diffGeoms;
698699

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

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

0 commit comments

Comments
 (0)