summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.h
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-05-28 20:19:17 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-07-22 18:04:16 (GMT)
commit1373081ce19698e50fdde95ab18012950f729d62 (patch)
treef48c93716115f812b95c5e8c8dcab432c55e1f0d /src/gui/graphicsview/qgraphicsanchorlayout_p.h
parenta5e99a6812e8a721dac29554ebcaa92c6d3fdd3a (diff)
downloadQt-1373081ce19698e50fdde95ab18012950f729d62.zip
Qt-1373081ce19698e50fdde95ab18012950f729d62.tar.gz
Qt-1373081ce19698e50fdde95ab18012950f729d62.tar.bz2
QGraphicsAnchorLayout: Update m_vertexList reference count system
The reference count system used to delete AnchorVertex objects stored in m_vertexList had an issue that prevented the count values from being stored properly. This is a tentative fix for the memory leaks in the layout, changes were made to the m_vertexList access methods as well as those that use them. 1) addInternalVertex() After incrementing the ref count, store it in m_vertexList. 2) removeInternalVertex() To make it symmetrical to addInternalVertex() we delete the anchor vertex if its reach count reaches zero. From now on, the only methods that create or delete vertices are these two. All other methods should rely on add/removeInternalVertex. Also made the method 'void'. This method is called to release the associated object and may trigger a deletion of it, thus any use of the object reference after that is unsafe. Other methods can get a reference with internalVertex(). 3) removeAnchor() Follow above instructions. No longer relies on the reference returned by removeInternalVertex(), instead, use the reference first then release. Note: In this particular case, we know that "removeEdge(v1, v2)" will only access the contents of the pointers, not the referenced object. Yet, the change probably pays itself for the sake of clarity and safety. 4) removeAnchors() Each tiime an anchor is created, the reference count of its both vertices is incremented, thus we should decrement that count every time we remove an anchor. (Instead of removing v1 only once). Also, leave the task of deleting v1 to removeInternalVertex() as explained above. Removing the constraints handling code. I understand that we cannot leave constraints with dangling pointers inside of them, however that raises an even worse problem. Every time an item is added, we create an item center constraint, thus we must be sure to delete those when the item is removed. Once we do that, we won't have bad constraints laying around. This issue remains open in this commit but will be solved soon. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.h')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index ee1a181..27855e6 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -276,7 +276,7 @@ public:
}
AnchorVertex *addInternalVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge);
- AnchorVertex *removeInternalVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge);
+ void removeInternalVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge);
// Geometry interpolation methods
void setItemsGeometries();