Skip to content

Commit

Permalink
fix #3001
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14228 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 14, 2010
1 parent b420878 commit a2fd4ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/core/qgsvectordataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,7 @@ QVariant QgsVectorDataProvider::minimumValue( int index )
return QVariant();
}

if ( mCacheMinMaxDirty )
{
fillMinMaxCache();
}
fillMinMaxCache();

if ( !mCacheMinValues.contains( index ) )
return QVariant();
Expand All @@ -324,10 +321,7 @@ QVariant QgsVectorDataProvider::maximumValue( int index )
return QVariant();
}

if ( mCacheMinMaxDirty )
{
fillMinMaxCache();
}
fillMinMaxCache();

if ( !mCacheMaxValues.contains( index ) )
return QVariant();
Expand Down Expand Up @@ -358,8 +352,16 @@ void QgsVectorDataProvider::uniqueValues( int index, QList<QVariant> &values, in
}
}

void QgsVectorDataProvider::clearMinMaxCache()
{
mCacheMinMaxDirty = true;
}

void QgsVectorDataProvider::fillMinMaxCache()
{
if ( !mCacheMinMaxDirty )
return;

const QgsFieldMap& flds = fields();
for ( QgsFieldMap::const_iterator it = flds.begin(); it != flds.end(); ++it )
{
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsvectordataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
protected:
QVariant convertValue( QVariant::Type type, QString value );

void clearMinMaxCache();
void fillMinMaxCache();

bool mCacheMinMaxDirty;
Expand Down
10 changes: 10 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,9 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
}
recalculateFeatureCount();

if ( returnvalue )
clearMinMaxCache();

return returnvalue;
}

Expand Down Expand Up @@ -888,6 +891,11 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )

bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr_map )
{
if ( attr_map.isEmpty() )
return true;

clearMinMaxCache();

for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
long fid = ( long ) it.key();
Expand Down Expand Up @@ -1049,6 +1057,8 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )

recalculateFeatureCount();

clearMinMaxCache();

if ( extent_ )
{
free( extent_ );
Expand Down

0 comments on commit a2fd4ea

Please sign in to comment.