Skip to content

Commit

Permalink
cache geometries only if layer is editable
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5327 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 21, 2006
1 parent 2efa86e commit 046f901
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/gui/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,14 +797,17 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th
QgsDebugMsg("QgsVectorLayer::draw: Destroying all cached geometries.");

// TODO: This area has suspect memory management
for (std::map<int, QgsGeometry*>::iterator it = mCachedGeometries.begin();
it != mCachedGeometries.end();
++it )
{
delete (*it).second;
}
QgsDebugMsg("QgsVectorLayer::draw: Clearing all cached geometries.");
mCachedGeometries.clear();
if(mEditable)
{
for (std::map<int, QgsGeometry*>::iterator it = mCachedGeometries.begin();
it != mCachedGeometries.end();
++it )
{
delete (*it).second;
}
QgsDebugMsg("QgsVectorLayer::draw: Clearing all cached geometries.");
mCachedGeometries.clear();
}

dataProvider->select(viewExtent);
dataProvider->updateFeatureCount();
Expand Down Expand Up @@ -871,8 +874,10 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th
}

// Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
mCachedGeometries[fet->featureId()] = fet->geometryAndOwnership();

if(mEditable)
{
mCachedGeometries[fet->featureId()] = fet->geometryAndOwnership();
}
bool sel=mSelected.find(fet->featureId()) != mSelected.end();
m_renderer->renderFeature(p, fet, &marker, &markerScaleFactor,
sel, widthScale );
Expand Down

0 comments on commit 046f901

Please sign in to comment.