Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[oracle] Fix minor Coverity issues
  • Loading branch information
nyalldawson committed Jul 10, 2016
1 parent 9a917c4 commit b94fbc0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/providers/oracle/qgsoracleconn.cpp
Expand Up @@ -31,7 +31,7 @@ QMap<QString, QgsOracleConn *> QgsOracleConn::sConnections;
int QgsOracleConn::snConnections = 0;
const int QgsOracleConn::sGeomTypeSelectLimit = 100;

QgsOracleConn *QgsOracleConn::connectDb( QgsDataSourceURI uri )
QgsOracleConn *QgsOracleConn::connectDb( const QgsDataSourceURI& uri )
{
QString conninfo = toPoolName( uri );
if ( sConnections.contains( conninfo ) )
Expand Down Expand Up @@ -140,7 +140,7 @@ QgsOracleConn::~QgsOracleConn()
mDatabase.close();
}

QString QgsOracleConn::toPoolName( QgsDataSourceURI uri )
QString QgsOracleConn::toPoolName( const QgsDataSourceURI &uri )
{
QString conninfo = uri.connectionInfo();
if ( uri.hasParam( "dbworkspace" ) )
Expand Down
8 changes: 6 additions & 2 deletions src/providers/oracle/qgsoracleconn.h
Expand Up @@ -45,6 +45,10 @@ struct QgsOracleLayerProperty
QStringList pkCols;
QString sql;

QgsOracleLayerProperty()
: isView( false )
{}

int size() const { Q_ASSERT( types.size() == srids.size() ); return types.size(); }

bool operator==( const QgsOracleLayerProperty& other )
Expand Down Expand Up @@ -107,7 +111,7 @@ class QgsOracleConn : public QObject
{
Q_OBJECT
public:
static QgsOracleConn *connectDb( QgsDataSourceURI uri );
static QgsOracleConn *connectDb( const QgsDataSourceURI &uri );
void disconnect();

/** Double quote a Oracle identifier for placement in a SQL string.
Expand Down Expand Up @@ -160,7 +164,7 @@ class QgsOracleConn : public QObject
static bool onlyExistingTypes( QString theConnName );
static void deleteConnection( QString theConnName );
static QString databaseName( QString database, QString host, QString port );
static QString toPoolName( QgsDataSourceURI uri );
static QString toPoolName( const QgsDataSourceURI& uri );

operator QSqlDatabase() { return mDatabase; }

Expand Down
2 changes: 1 addition & 1 deletion src/providers/oracle/qgsoracleconnpool.h
Expand Up @@ -25,7 +25,7 @@ inline QString qgsConnectionPool_ConnectionToName( QgsOracleConn* c )
return c->connInfo();
}

inline void qgsConnectionPool_ConnectionCreate( QgsDataSourceURI uri, QgsOracleConn*& c )
inline void qgsConnectionPool_ConnectionCreate( const QgsDataSourceURI& uri, QgsOracleConn*& c )
{
c = QgsOracleConn::connectDb( uri );
}
Expand Down
14 changes: 10 additions & 4 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1863,7 +1863,6 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
g.eleminfo.clear();
g.ordinates.clear();

QString expr;
int iOrdinate = 1;
QGis::WkbType type = ( QGis::WkbType ) * ptr.iPtr++;
int dim = 2;
Expand All @@ -1872,6 +1871,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
{
case QGis::WKBPoint25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBPoint:
g.srid = mSrid;
g.gtype = SDO_GTYPE( dim, gtPoint );
Expand All @@ -1883,6 +1884,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
case QGis::WKBLineString25D:
case QGis::WKBMultiLineString25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBLineString:
case QGis::WKBMultiLineString:
{
Expand Down Expand Up @@ -1918,6 +1921,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
case QGis::WKBPolygon25D:
case QGis::WKBMultiPolygon25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBPolygon:
case QGis::WKBMultiPolygon:
{
Expand Down Expand Up @@ -1957,6 +1962,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry

case QGis::WKBMultiPoint25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBMultiPoint:
{
g.gtype = SDO_GTYPE( dim, gtMultiPoint );
Expand Down Expand Up @@ -2830,7 +2837,7 @@ QgsVectorLayerImport::ImportError QgsOracleProvider::createEmptyLayer(

QgsDebugMsg( QString( "layer %1 created" ).arg( ownerTableName ) );

// use the provider to edit the table
// use the provider to edit the table1
dsUri.setDataSource( ownerName, tableName, geometryColumn, QString(), primaryKey );
QgsOracleProvider *provider = new QgsOracleProvider( dsUri.uri() );
if ( !provider->isValid() )
Expand All @@ -2845,8 +2852,7 @@ QgsVectorLayerImport::ImportError QgsOracleProvider::createEmptyLayer(
QgsDebugMsg( "layer loaded" );

// add fields to the layer
if ( oldToNewAttrIdxMap )
oldToNewAttrIdxMap->clear();
oldToNewAttrIdxMap->clear();

if ( fields.size() > 0 )
{
Expand Down
1 change: 0 additions & 1 deletion src/providers/oracle/qgsoracleprovider.h
Expand Up @@ -410,7 +410,6 @@ class QgsOracleProvider : public QgsVectorDataProvider
QgsFeatureId mFidCounter; //! next feature id if map is used
QgsOracleConn *mConnection;

bool mHasSpatial; //! Oracle Spatial is installed
bool mHasSpatialIndex; //! Geometry column is indexed
QString mSpatialIndexName; //! name of spatial index of geometry column

Expand Down

0 comments on commit b94fbc0

Please sign in to comment.