Skip to content
Permalink
Browse files

More Coverity fixes

  • Loading branch information
nyalldawson committed Feb 11, 2015
1 parent 5397d6b commit 25652e4228d2a8d8205f5e0d1be7e40a7cdc7f13
@@ -3007,7 +3007,10 @@ bool QgisApp::askUserForZipItemLayers( QString path )
{
QgsDataItem *item = zipItem->children()[i];
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem *>( item );
QgsDebugMsgLevel( QString( "item path=%1 provider=%2" ).arg( item->path() ).arg( layerItem->providerKey() ), 2 );
if ( layerItem )
{
QgsDebugMsgLevel( QString( "item path=%1 provider=%2" ).arg( item->path() ).arg( layerItem->providerKey() ), 2 );
}
if ( layerItem && layerItem->providerKey() == "gdal" )
{
layers << QString( "%1|%2|%3" ).arg( i ).arg( item->name() ).arg( "Raster" );
@@ -777,7 +777,7 @@ static QVariant fcnRegexpSubstr( const QVariantList& values, const QgsFeature*,
}

// extract substring
re.indexIn( str );
( void )re.indexIn( str );
if ( re.captureCount() > 0 )
{
// return first capture
@@ -146,7 +146,8 @@ void QgsLogger::logMessageToFile( QString theMessage )

//Maybe more efficient to keep the file open for the life of qgis...
QFile file( sLogFile );
file.open( QIODevice::Append );
if ( !file.open( QIODevice::Append ) )
return;
file.write( theMessage.toLocal8Bit().constData() );
file.write( "\n" );
file.close();
@@ -3702,7 +3702,8 @@ QList<QgsAttributeEditorElement*> QgsAttributeEditorContainer::findElements( Qgs
if ( elem->type() == AeTypeContainer )
{
QgsAttributeEditorContainer* cont = dynamic_cast<QgsAttributeEditorContainer*>( elem );
results += cont->findElements( type );
if ( cont )
results += cont->findElements( type );
}
}

@@ -56,7 +56,7 @@ QgsRasterBlock::QgsRasterBlock( QGis::DataType theDataType, int theWidth, int th
, mNoDataBitmapWidth( 0 )
, mNoDataBitmapSize( 0 )
{
reset( mDataType, mWidth, mHeight );
( void )reset( mDataType, mWidth, mHeight );
}

QgsRasterBlock::QgsRasterBlock( QGis::DataType theDataType, int theWidth, int theHeight, double theNoDataValue )
@@ -73,7 +73,7 @@ QgsRasterBlock::QgsRasterBlock( QGis::DataType theDataType, int theWidth, int th
, mNoDataBitmapWidth( 0 )
, mNoDataBitmapSize( 0 )
{
reset( mDataType, mWidth, mHeight, mNoDataValue );
( void )reset( mDataType, mWidth, mHeight, mNoDataValue );
}

QgsRasterBlock::~QgsRasterBlock()
@@ -1092,6 +1092,9 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::convertFromRenderer( const QgsFe
if ( renderer->type() == "categorizedSymbol" )
{
const QgsCategorizedSymbolRendererV2* categorizedRenderer = dynamic_cast<const QgsCategorizedSymbolRendererV2*>( renderer );
if ( !categorizedRenderer )
return 0;

QgsRuleBasedRendererV2::Rule* rootrule = new QgsRuleBasedRendererV2::Rule( NULL );

QString expression;
@@ -169,8 +169,8 @@ QSqlQuery* eVisDatabaseConnection::query( QString sqlStatement )
//set forward only is required for OBDC on linux
mQuery = QSqlQuery( mDatabase );
mQuery.setForwardOnly( true );
mQuery.exec( sqlStatement );
if ( mQuery.isActive() )
bool execOk = mQuery.exec( sqlStatement );
if ( execOk && mQuery.isActive() )
{
return &mQuery;
}
@@ -294,7 +294,8 @@ bool QgsGeorefTransform::getLinearOriginScale( QgsPoint &origin, double &scaleX,
{
return false;
}
return dynamic_cast<QgsLinearGeorefTransform *>( mGeorefTransformImplementation )->getOriginScale( origin, scaleX, scaleY );
QgsLinearGeorefTransform* transform = dynamic_cast<QgsLinearGeorefTransform *>( mGeorefTransformImplementation );
return transform && transform->getOriginScale( origin, scaleX, scaleY );
}

bool QgsGeorefTransform::getOriginScaleRotation( QgsPoint &origin, double &scaleX, double &scaleY, double& rotation ) const
@@ -136,7 +136,7 @@ QVector<QgsDataItem*> QgsMssqlConnectionItem::createChildren()
// issue the sql query
QSqlQuery q = QSqlQuery( db );
q.setForwardOnly( true );
q.exec( query );
( void )q.exec( query );

if ( q.isActive() )
{
@@ -920,7 +920,16 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
}
}

query.next();
if ( !query.next() )
{
QString msg = query.lastError().text();
QgsDebugMsg( msg );
if ( !mSkipFailures )
{
pushError( msg );
return false;
}
}
it->setFeatureId( query.value( 0 ).toLongLong() );
}

@@ -1315,17 +1324,17 @@ QgsCoordinateReferenceSystem QgsMssqlProvider::crs()
// try to load crs
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
query.exec( QString( "select srtext from spatial_ref_sys where srid = %1" ).arg( QString::number( mSRId ) ) );
if ( query.isActive() )
bool execOk = query.exec( QString( "select srtext from spatial_ref_sys where srid = %1" ).arg( QString::number( mSRId ) ) );
if ( execOk && query.isActive() )
{
if ( query.next() && mCrs.createFromWkt( query.value( 0 ).toString() ) )
return mCrs;

query.finish();
}
query.clear();
query.exec( QString( "select well_known_text from sys.spatial_reference_systems where spatial_reference_id = %1" ).arg( QString::number( mSRId ) ) );
if ( query.isActive() && query.next() && mCrs.createFromWkt( query.value( 0 ).toString() ) )
execOk = query.exec( QString( "select well_known_text from sys.spatial_reference_systems where spatial_reference_id = %1" ).arg( QString::number( mSRId ) ) );
if ( execOk && query.isActive() && query.next() && mCrs.createFromWkt( query.value( 0 ).toString() ) )
return mCrs;
}
return mCrs;
@@ -541,7 +541,7 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()
// issue the sql query
QSqlQuery q = QSqlQuery( db );
q.setForwardOnly( true );
q.exec( query );
( void )q.exec( query );

if ( q.isActive() )
{
@@ -339,7 +339,9 @@ QString QgsBench::serialize( QMap<QString, QVariant> theMap, int level )
void QgsBench::saveLog( const QString & fileName )
{
QFile file( fileName );
file.open( QIODevice::WriteOnly | QIODevice::Text );
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
return;

QTextStream out( &file );
out << serialize( mLogMap ).toAscii().constData() << "\n";
file.close();
@@ -132,7 +132,7 @@ void ModelTest::nonDestructiveBasicTest()
fetchingMore = false;
Qt::ItemFlags flags = model->flags( QModelIndex() );
Q_ASSERT( flags == Qt::ItemIsDropEnabled || flags == 0 );
model->hasChildren( QModelIndex() );
( void )model->hasChildren( QModelIndex() );
model->hasIndex( 0, 0 );
model->headerData( 0, Qt::Horizontal );
model->index( 0, 0 );
@@ -114,6 +114,7 @@ void TestQgsMapLayerStyleManager::testReadWrite()
sm0.addStyleFromLayer( "blue" );
sm0.setCurrentStyle( "blue" );
QgsSingleSymbolRendererV2* r1 = dynamic_cast<QgsSingleSymbolRendererV2*>( mVL->rendererV2() );
QVERIFY( r1 );
r1->symbol()->setColor( Qt::blue );

// read and write
@@ -546,7 +546,7 @@ void TestQgsWcsPublicServers::test()
myVersionLogFile.close();
}
QFile myServerLogFile( myServerLogPath );
myServerLogFile.open( QIODevice::WriteOnly | QIODevice::Text );
Q_ASSERT( myServerLogFile.open( QIODevice::WriteOnly | QIODevice::Text ) );
QTextStream myServerStream( &myServerLogFile );
myServerStream << myServerLog.join( "\n" );
myServerLogFile.close();

0 comments on commit 25652e4

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