Skip to content
Permalink
Browse files

Fix style of nullptr comparisons

  • Loading branch information
rouault committed Apr 26, 2016
1 parent 8259b3f commit 65a37dbe07c5de2d3fb763cff677bfa05714cdee
@@ -459,7 +459,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
ParseMode theParseMode( mParseModeStack.isEmpty() ? none : mParseModeStack.top() );

// Figure out if the GML namespace is GML_NAMESPACE or GML32_NAMESPACE
if ( mGMLNameSpaceURIPtr == nullptr && pszSep != nullptr )
if ( !mGMLNameSpaceURIPtr && pszSep )
{
if ( nsLen == ( int )strlen( GML_NAMESPACE ) && memcmp( el, GML_NAMESPACE, nsLen ) == 0 )
{
@@ -544,7 +544,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
mParseModeStack.push( QgsGmlStreamingParser::upperCorner );
mStringCash.clear();
}
else if ( theParseMode == none && mTypeNamePtr == nullptr &&
else if ( theParseMode == none && !mTypeNamePtr &&
LOCALNAME_EQUALS( "Tuple" ) )
{
Q_ASSERT( !mCurrentFeature );
@@ -852,7 +852,7 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
mParseModeStack.pop();
mFeatureTupleDepth = 0;
}
else if (( theParseMode == tuple && mTypeNamePtr == nullptr &&
else if (( theParseMode == tuple && !mTypeNamePtr &&
LOCALNAME_EQUALS( "Tuple" ) ) ||
( theParseMode == feature && localNameLen == mTypeName.size() &&
memcmp( pszLocalName, mTypeNamePtr, mTypeName.size() ) == 0 ) )
@@ -3181,7 +3181,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
const QString& leftTable )
{
QgsSQLStatement::Node* onExpr = node->onExpr();
if ( onExpr != nullptr )
if ( onExpr )
{
return toOgcFilter( onExpr );
}
@@ -3261,7 +3261,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
}

// Process WHERE conditions
if ( node->where() != nullptr )
if ( node->where() )
{
QDomElement whereElem = toOgcFilter( node->where() );
if ( !mErrorMessage.isEmpty() )
@@ -99,9 +99,9 @@ QgsWFSFeatureDownloader::~QgsWFSFeatureDownloader()
{
stop();

if ( mProgressDialog != nullptr )
if ( mProgressDialog )
mProgressDialog->deleteLater();
if ( mTimer != nullptr )
if ( mTimer )
mTimer->deleteLater();
}

@@ -161,7 +161,7 @@ void QgsWFSFeatureDownloader::createProgressDialog()
{
if ( mStop )
return;
Q_ASSERT( mProgressDialog == nullptr );
Q_ASSERT( !mProgressDialog );
mProgressDialog = new QgsWFSProgressDialog( tr( "Loading features for layer %1" ).arg( mShared->mURI.typeName() ),
tr( "Abort" ), 0, mNumberMatched, mMainWindow );
mProgressDialog->setWindowTitle( tr( "QGIS" ) );
@@ -377,7 +377,7 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
}
}

if ( mMainWindow != nullptr )
if ( mMainWindow )
{
// In case the header of the GetFeature response doesn't contain the total
// number of features, or we don't get it within 4 seconds, we will issue
@@ -511,7 +511,7 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )

// Consider if we should display a progress dialog
// We can only do that if we know how many features will be downloaded
if ( mTimer == nullptr && maxFeatures != 1 && mMainWindow != nullptr )
if ( !mTimer && maxFeatures != 1 && mMainWindow )
{
if ( mNumberMatched < 0 )
{
@@ -644,12 +644,12 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
// test suite.
emit endOfDownload( success );

if ( mProgressDialog != nullptr )
if ( mProgressDialog )
{
mProgressDialog->deleteLater();
mProgressDialog = nullptr;
}
if ( mTimer != nullptr )
if ( mTimer )
{
mTimer->deleteLater();
mTimer = nullptr;
@@ -678,7 +678,7 @@ QgsWFSThreadedFeatureDownloader::~QgsWFSThreadedFeatureDownloader()

void QgsWFSThreadedFeatureDownloader::stop()
{
if ( mDownloader != nullptr )
if ( mDownloader )
{
mDownloader->stop();
wait();
@@ -721,7 +721,7 @@ QgsWFSFeatureIterator::QgsWFSFeatureIterator( QgsWFSFeatureSource* source,
int genCounter = ( mShared->mURI.isRestrictedToRequestBBOX() && !request.filterRect().isNull() ) ?
mShared->registerToCache( this, request.filterRect() ) : mShared->registerToCache( this );
mDownloadFinished = genCounter < 0;
if ( mShared->mCacheDataProvider == nullptr )
if ( !mShared->mCacheDataProvider )
return;

QgsDebugMsg( QString( "QgsWFSFeatureIterator::constructor(): genCounter=%1 " ).arg( genCounter ) );
@@ -825,7 +825,7 @@ void QgsWFSFeatureIterator::connectSignals( QObject* downloader )
void QgsWFSFeatureIterator::endOfDownload( bool )
{
mDownloadFinished = true;
if ( mLoop != nullptr )
if ( mLoop )
mLoop->quit();
}

@@ -840,15 +840,15 @@ void QgsWFSFeatureIterator::featureReceivedSynchronous( QVector<QgsWFSFeatureGml
{
QgsDebugMsg( QString( "QgsWFSFeatureIterator::featureReceivedSynchronous %1 features" ).arg( list.size() ) );
QMutexLocker locker( &mMutex );
if ( mWriterStream == nullptr )
if ( !mWriterStream )
{
mWriterStream = new QDataStream( &mWriterByteArray, QIODevice::WriteOnly );
}
Q_FOREACH ( const QgsWFSFeatureGmlIdPair& pair, list )
{
*mWriterStream << pair.first;
}
if ( mWriterFile == nullptr && mWriterByteArray.size() > mWriteTransferThreshold )
if ( !mWriterFile && mWriterByteArray.size() > mWriteTransferThreshold )
{
QString thisStr;
thisStr.sprintf( "%p", this );
@@ -868,7 +868,7 @@ void QgsWFSFeatureIterator::featureReceivedSynchronous( QVector<QgsWFSFeatureGml
void QgsWFSFeatureIterator::featureReceived( int /*featureCount*/ )
{
//QgsDebugMsg( QString("QgsWFSFeatureIterator::featureReceived %1 features").arg(featureCount) );
if ( mLoop != nullptr )
if ( mLoop )
mLoop->quit();
}

@@ -879,7 +879,7 @@ void QgsWFSFeatureIterator::checkInterruption()
if ( mInterruptionChecker && mInterruptionChecker->mustStop() )
{
mDownloadFinished = true;
if ( mLoop != nullptr )
if ( mLoop )
mLoop->quit();
}
}
@@ -936,7 +936,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )

const QgsGeometry* constGeom = cachedFeature.constGeometry();
if ( !mRequest.filterRect().isNull() &&
( constGeom == nullptr || !constGeom->intersects( mRequest.filterRect() ) ) )
( !constGeom || !constGeom->intersects( mRequest.filterRect() ) ) )
{
continue;
}
@@ -949,7 +949,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )
while ( true )
{
// Initialize a reader stream if there's a writer stream available
if ( mReaderStream == nullptr )
if ( !mReaderStream )
{
{
QMutexLocker locker( &mMutex );
@@ -981,7 +981,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )
}

// Read from the stream
if ( mReaderStream != nullptr )
if ( mReaderStream )
{
while ( !mReaderStream->atEnd() )
{
@@ -1010,7 +1010,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )

const QgsGeometry* constGeom = feat.constGeometry();
if ( !mRequest.filterRect().isNull() &&
( constGeom == nullptr || !constGeom->intersects( mRequest.filterRect() ) ) )
( !constGeom || !constGeom->intersects( mRequest.filterRect() ) ) )
{
continue;
}
@@ -1045,7 +1045,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )
mLoop = &loop;
QTimer timer( this );
timer.start( 50 );
if ( mInterruptionChecker != nullptr )
if ( mInterruptionChecker )
connect( &timer, SIGNAL( timeout() ), this, SLOT( checkInterruption() ) );
loop.exec( QEventLoop::ExcludeUserInputEvents );
mLoop = nullptr;
@@ -1078,7 +1078,7 @@ bool QgsWFSFeatureIterator::rewind()
requestCache.setFilterExpression( QString( QgsWFSConstants::FIELD_GEN_COUNTER + " <= %1" ).arg( genCounter ) );
else
mDownloadFinished = true;
if ( mShared->mCacheDataProvider != nullptr )
if ( mShared->mCacheDataProvider )
mCacheIterator = mShared->mCacheDataProvider->getFeatures( requestCache );
return true;
}
@@ -264,7 +264,7 @@ bool QgsWFSSharedData::createCache()
vsi_l_offset nLength = 0;
GByte* pabyData = VSIGetMemFileBuffer( vsimemFilename.toStdString().c_str(), &nLength, TRUE );
VSILFILE* fp = VSIFOpenL( mCacheDbname.toStdString().c_str(), "wb " );
if ( fp != nullptr )
if ( fp )
{
VSIFWriteL( pabyData, 1, nLength, fp );
VSIFCloseL( fp );
@@ -431,12 +431,12 @@ bool QgsWFSSharedData::createCache()
dsURI.setParam( "pragma", pragmas );
mCacheDataProvider = ( QgsVectorDataProvider* )( QgsProviderRegistry::instance()->provider(
"spatialite", dsURI.uri() ) );
if ( mCacheDataProvider != nullptr && !mCacheDataProvider->isValid() )
if ( mCacheDataProvider && !mCacheDataProvider->isValid() )
{
delete mCacheDataProvider;
mCacheDataProvider = nullptr;
}
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
{
QgsMessageLog::logMessage( tr( "Cannot connect to temporary SpatiaLite cache" ), tr( "WFS" ) );
return false;
@@ -501,7 +501,7 @@ int QgsWFSSharedData::registerToCache( QgsWFSFeatureIterator* iterator, QgsRecta
}
}

if ( newDownloadNeeded || mDownloader == nullptr )
if ( newDownloadNeeded || !mDownloader )
{
mRect = rect;
// to prevent deadlock when waiting the end of the downloader thread that will try to take the mutex in serializeFeatures()
@@ -672,7 +672,7 @@ QSet<QString> QgsWFSSharedData::getExistingCachedMD5( const QVector<QgsWFSFeatur
// Used by WFS-T
QString QgsWFSSharedData::findGmlId( QgsFeatureId fid )
{
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
return QString();
QgsFeatureRequest request;
request.setFilterFid( fid );
@@ -698,7 +698,7 @@ QString QgsWFSSharedData::findGmlId( QgsFeatureId fid )
// Used by WFS-T
bool QgsWFSSharedData::deleteFeatures( const QgsFeatureIds& fidlist )
{
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
return false;

{
@@ -712,7 +712,7 @@ bool QgsWFSSharedData::deleteFeatures( const QgsFeatureIds& fidlist )
// Used by WFS-T
bool QgsWFSSharedData::changeGeometryValues( const QgsGeometryMap &geometry_map )
{
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
return false;

// We need to replace the geometry by its bounding box and issue a attribute
@@ -754,7 +754,7 @@ bool QgsWFSSharedData::changeGeometryValues( const QgsGeometryMap &geometry_map
// Used by WFS-T
bool QgsWFSSharedData::changeAttributeValues( const QgsChangedAttributesMap &attr_map )
{
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
return false;

const QgsFields & dataProviderFields = mCacheDataProvider->fields();
@@ -795,7 +795,7 @@ void QgsWFSSharedData::serializeFeatures( QVector<QgsWFSFeatureGmlIdPair>& featu
return;
}
}
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
{
return;
}
@@ -1034,7 +1034,7 @@ void QgsWFSSharedData::invalidateCache()
mFeatureCount = 0;
mFeatureCountExact = false;
mTotalFeaturesAttemptedToBeCached = 0;
if ( !mCacheDbname.isEmpty() && mCacheDataProvider != nullptr )
if ( !mCacheDbname.isEmpty() && mCacheDataProvider )
{
// We need to invalidate connections pointing to the cache, so as to
// be able to delete the file.
@@ -81,7 +81,7 @@ void QgsWFSUtils::releaseCacheDirectory()
gmCounter --;
if ( gmCounter == 0 )
{
if ( gmThread != nullptr )
if ( gmThread )
{
gmThread->exit();
gmThread->wait();
@@ -174,7 +174,7 @@ QSharedMemory* QgsWFSUtils::createAndAttachSHM()
{
QSharedMemory* sharedMemory = nullptr;
// For debug purpose. To test in the case where shared memory mechanism doesn't work
if ( getenv( "QGIS_USE_SHARED_MEMORY_KEEP_ALIVE" ) == nullptr )
if ( !getenv( "QGIS_USE_SHARED_MEMORY_KEEP_ALIVE" ) )
{
sharedMemory = new QSharedMemory( QString( "qgis_wfs_pid_%1" ).arg( QCoreApplication::applicationPid() ) );
if ( sharedMemory->create( sizeof( qint64 ) ) && sharedMemory->lock() && sharedMemory->unlock() )

0 comments on commit 65a37db

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