Skip to content

Commit

Permalink
Fix style of nullptr comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed May 12, 2016
1 parent 8259b3f commit 65a37db
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/core/qgsgml.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsogcutils.cpp
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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() )
Expand Down
40 changes: 20 additions & 20 deletions src/providers/wfs/qgswfsfeatureiterator.cpp
Expand Up @@ -99,9 +99,9 @@ QgsWFSFeatureDownloader::~QgsWFSFeatureDownloader()
{
stop();

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

Expand Down Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -678,7 +678,7 @@ QgsWFSThreadedFeatureDownloader::~QgsWFSThreadedFeatureDownloader()

void QgsWFSThreadedFeatureDownloader::stop()
{
if ( mDownloader != nullptr )
if ( mDownloader )
{
mDownloader->stop();
wait();
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -825,7 +825,7 @@ void QgsWFSFeatureIterator::connectSignals( QObject* downloader )
void QgsWFSFeatureIterator::endOfDownload( bool )
{
mDownloadFinished = true;
if ( mLoop != nullptr )
if ( mLoop )
mLoop->quit();
}

Expand All @@ -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 );
Expand All @@ -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();
}

Expand All @@ -879,7 +879,7 @@ void QgsWFSFeatureIterator::checkInterruption()
if ( mInterruptionChecker && mInterruptionChecker->mustStop() )
{
mDownloadFinished = true;
if ( mLoop != nullptr )
if ( mLoop )
mLoop->quit();
}
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 );
Expand Down Expand Up @@ -981,7 +981,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature& f )
}

// Read from the stream
if ( mReaderStream != nullptr )
if ( mReaderStream )
{
while ( !mReaderStream->atEnd() )
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 10 additions & 10 deletions src/providers/wfs/qgswfsshareddata.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
Expand All @@ -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;

{
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -795,7 +795,7 @@ void QgsWFSSharedData::serializeFeatures( QVector<QgsWFSFeatureGmlIdPair>& featu
return;
}
}
if ( mCacheDataProvider == nullptr )
if ( !mCacheDataProvider )
{
return;
}
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/providers/wfs/qgswfsutils.cpp
Expand Up @@ -81,7 +81,7 @@ void QgsWFSUtils::releaseCacheDirectory()
gmCounter --;
if ( gmCounter == 0 )
{
if ( gmThread != nullptr )
if ( gmThread )
{
gmThread->exit();
gmThread->wait();
Expand Down Expand Up @@ -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() )
Expand Down

0 comments on commit 65a37db

Please sign in to comment.