Skip to content
Permalink
Browse files

qgsgml & WFS provider: fix Coverity warnings introduced in recent WFS…

… works
  • Loading branch information
rouault committed May 14, 2016
1 parent abd182c commit 349a618a9ee9a5c93e5218fa3207b400cfe31b1b
@@ -473,7 +473,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
}
}

const bool isGMLNS = ( nsLen == mGMLNameSpaceURI.size() && memcmp( el, mGMLNameSpaceURIPtr, nsLen ) == 0 );
const bool isGMLNS = ( nsLen == mGMLNameSpaceURI.size() && mGMLNameSpaceURIPtr && memcmp( el, mGMLNameSpaceURIPtr, nsLen ) == 0 );
bool isGeom = false;
if ( isGMLNS && LOCALNAME_EQUALS( "coordinates" ) )
{
@@ -776,7 +776,7 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
const int localNameLen = ( pszSep ) ? ( int )( elLen - nsLen ) - 1 : elLen;
ParseMode theParseMode( mParseModeStack.isEmpty() ? none : mParseModeStack.top() );

const bool isGMLNS = ( nsLen == mGMLNameSpaceURI.size() && memcmp( el, mGMLNameSpaceURIPtr, nsLen ) == 0 );
const bool isGMLNS = ( nsLen == mGMLNameSpaceURI.size() && mGMLNameSpaceURIPtr && memcmp( el, mGMLNameSpaceURIPtr, nsLen ) == 0 );

if ( theParseMode == coordinate && isGMLNS && LOCALNAME_EQUALS( "coordinates" ) )
{
@@ -856,7 +856,13 @@ void QgsWFSFeatureIterator::featureReceivedSynchronous( QVector<QgsWFSFeatureGml
mWriterFilename = QDir( QgsWFSUtils::acquireCacheDirectory() ).filePath( QString( "iterator_%1_%2.bin" ).arg( thisStr ).arg( mCounter ) );
QgsDebugMsg( QString( "Transfering feature iterator cache to %1" ).arg( mWriterFilename ) );
mWriterFile = new QFile( mWriterFilename );
mWriterFile->open( QIODevice::WriteOnly );
if ( !mWriterFile->open( QIODevice::WriteOnly ) )
{
QgsDebugMsg( QString( "Cannot open %1 for writing" ).arg( mWriterFilename ) );
delete mWriterFile;
mWriterFile = nullptr;
return;
}
mWriterFile->write( mWriterByteArray );
mWriterByteArray.clear();
mWriterStream->setDevice( mWriterFile );
@@ -975,7 +981,13 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )
else if ( !mReaderFilename.isEmpty() )
{
mReaderFile = new QFile( mReaderFilename );
mReaderFile->open( QIODevice::ReadOnly );
if ( !mReaderFile->open( QIODevice::ReadOnly ) )
{
QgsDebugMsg( QString( "Cannot open %1" ).arg( mReaderFilename ) );
delete mReaderFile;
mReaderFile = nullptr;
return false;
}
mReaderStream = new QDataStream( mReaderFile );
}
}
@@ -290,7 +290,12 @@ bool QgsWFSProvider::processSQL( const QString& sqlString, QString& errorMsg )
return false;
}
const QgsSQLStatement::NodeSelect* select = dynamic_cast<const QgsSQLStatement::NodeSelect*>( sql.rootNode() );
Q_ASSERT( select );
if ( !select )
{
// Makes Coverity happy, but cannot happen in practice
QgsDebugMsg( "should not happen" );
return false;
}
mShared->mDistinctSelect = select->distinct();

QMap< QString, QString > mapTypenameAliasToTypename;
@@ -111,7 +111,12 @@ bool QgsWFSSharedData::computeFilter( QString& errorMsg )
QgsSQLStatement sql( mURI.sql() );

const QgsSQLStatement::NodeSelect* select = dynamic_cast<const QgsSQLStatement::NodeSelect*>( sql.rootNode() );
Q_ASSERT( select );
if ( !select )
{
// Makes Coverity happy, but cannot happen in practice
QgsDebugMsg( "should not happen" );
return false;
}
QList<QgsSQLStatement::NodeColumnSorted*> orderBy = select->orderBy();
Q_FOREACH ( QgsSQLStatement::NodeColumnSorted* columnSorted, orderBy )
{
@@ -407,7 +407,7 @@ class QgsWFSValidatorCallback: public QObject, public QgsSQLComposerDialog::SQLV
{
public:
QgsWFSValidatorCallback( QObject* parent,
QgsWFSDataSourceURI uri, const QString& allSql,
const QgsWFSDataSourceURI& uri, const QString& allSql,
const QgsWFSCapabilities::Capabilities& caps );
bool isValid( const QString& sql, QString& errorReason ) override;
private:
@@ -417,7 +417,7 @@ class QgsWFSValidatorCallback: public QObject, public QgsSQLComposerDialog::SQLV
};

QgsWFSValidatorCallback::QgsWFSValidatorCallback( QObject* parent,
QgsWFSDataSourceURI uri,
const QgsWFSDataSourceURI& uri,
const QString& allSql,
const QgsWFSCapabilities::Capabilities& caps )
: QObject( parent )
@@ -449,7 +449,7 @@ class QgsWFSTableSelectedCallback: public QObject, public QgsSQLComposerDialog::
{
public:
QgsWFSTableSelectedCallback( QgsSQLComposerDialog* dialog,
QgsWFSDataSourceURI uri,
const QgsWFSDataSourceURI& uri,
const QgsWFSCapabilities::Capabilities& caps );
void tableSelected( const QString& name ) override;

@@ -460,7 +460,7 @@ class QgsWFSTableSelectedCallback: public QObject, public QgsSQLComposerDialog::
};

QgsWFSTableSelectedCallback::QgsWFSTableSelectedCallback( QgsSQLComposerDialog* dialog,
QgsWFSDataSourceURI uri,
const QgsWFSDataSourceURI& uri,
const QgsWFSCapabilities::Capabilities& caps )
: QObject( dialog )
, mDialog( dialog )
@@ -29,7 +29,13 @@ bool QgsWFSTransactionRequest::send( const QDomDocument& doc, QDomDocument& serv

if ( sendPOST( url, "text/xml", doc.toByteArray( -1 ) ) )
{
serverResponse.setContent( mResponse, true );
QString errorMsg;
if ( !serverResponse.setContent( mResponse, true, &errorMsg ) )
{
QgsDebugMsg( mResponse );
QgsDebugMsg( errorMsg );
return false;
}
return true;
}
return false;

0 comments on commit 349a618

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