Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Modernise code
  • Loading branch information
nyalldawson committed Nov 19, 2017
1 parent 7cd8e38 commit 6508a5d
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 83 deletions.
5 changes: 1 addition & 4 deletions src/core/providers/memory/qgsmemoryfeatureiterator.cpp
Expand Up @@ -45,7 +45,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour

if ( !mSource->mSubsetString.isEmpty() )
{
mSubsetExpression = new QgsExpression( mSource->mSubsetString );
mSubsetExpression = qgis::make_unique< QgsExpression >( mSource->mSubsetString );
mSubsetExpression->prepare( &mSource->mExpressionContext );
}

Expand Down Expand Up @@ -82,11 +82,8 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour
QgsMemoryFeatureIterator::~QgsMemoryFeatureIterator()
{
close();

delete mSubsetExpression;
}


bool QgsMemoryFeatureIterator::fetchFeature( QgsFeature &feature )
{
feature.setValid( false );
Expand Down
2 changes: 1 addition & 1 deletion src/core/providers/memory/qgsmemoryfeatureiterator.h
Expand Up @@ -75,7 +75,7 @@ class QgsMemoryFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs
bool mUsingFeatureIdList = false;
QList<QgsFeatureId> mFeatureIdList;
QList<QgsFeatureId>::const_iterator mFeatureIdListIterator;
QgsExpression *mSubsetExpression = nullptr;
std::unique_ptr< QgsExpression > mSubsetExpression;
QgsCoordinateTransform mTransform;

};
Expand Down
6 changes: 0 additions & 6 deletions src/core/qgsfeatureiterator.cpp
Expand Up @@ -21,12 +21,6 @@

QgsAbstractFeatureIterator::QgsAbstractFeatureIterator( const QgsFeatureRequest &request )
: mRequest( request )
, mClosed( false )
, mZombie( false )
, refs( 0 )
, mFetchedCount( 0 )
, mCompileStatus( NoCompilation )
, mUseCachedFeatures( false )
{
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsfeatureiterator.h
Expand Up @@ -159,7 +159,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator
QgsFeatureRequest mRequest;

//! Set to true, as soon as the iterator is closed.
bool mClosed;
bool mClosed = false;

/**
* A feature iterator may be closed already but still be serving features from the cache.
Expand All @@ -168,24 +168,24 @@ class CORE_EXPORT QgsAbstractFeatureIterator
* In such a scenario, all resources have been released (mClosed is true) but the deads
* are still alive.
*/
bool mZombie;
bool mZombie = false;

/**
* reference counting (to allow seamless copying of QgsFeatureIterator instances)
* TODO QGIS3: make this private
*/
int refs;
int refs = 0;
//! Add reference
void ref();
//! Remove reference, delete if refs == 0
void deref();
friend class QgsFeatureIterator;

//! Number of features already fetched by iterator
long mFetchedCount;
long mFetchedCount = 0;

//! Status of compilation of filter expression
CompileStatus mCompileStatus;
CompileStatus mCompileStatus = NoCompilation;

//! Setup the simplification of geometries to fetch using the specified simplify method
virtual bool prepareSimplification( const QgsSimplifyMethod &simplifyMethod );
Expand All @@ -201,7 +201,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator
bool mValid = true;

private:
bool mUseCachedFeatures;
bool mUseCachedFeatures = false;
QList<QgsIndexedFeature> mCachedFeatures;
QList<QgsIndexedFeature>::ConstIterator mFeatureIterator;

Expand Down
Expand Up @@ -536,7 +536,6 @@ QgsDelimitedTextFeatureSource::QgsDelimitedTextFeatureSource( const QgsDelimited

QgsDelimitedTextFeatureSource::~QgsDelimitedTextFeatureSource()
{
delete mSubsetExpression;
}

QgsFeatureIterator QgsDelimitedTextFeatureSource::getFeatures( const QgsFeatureRequest &request )
Expand Down
Expand Up @@ -32,7 +32,7 @@ class QgsDelimitedTextFeatureSource : public QgsAbstractFeatureSource

private:
QgsDelimitedTextProvider::GeomRepresentationType mGeomRep;
QgsExpression *mSubsetExpression = nullptr;
std::unique_ptr< QgsExpression > mSubsetExpression;
QgsExpressionContext mExpressionContext;
QgsRectangle mExtent;
bool mUseSpatialIndex;
Expand Down

0 comments on commit 6508a5d

Please sign in to comment.