Skip to content

Commit f3649d1

Browse files
committed
minor fixes
1 parent e54f3de commit f3649d1

File tree

8 files changed

+17801
-16664
lines changed

8 files changed

+17801
-16664
lines changed

README.rst

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,27 @@ don't need to be garbage collected, but will be cleaned up from the C++ side.
9898
SL.setLayout(ohl)
9999
100100
When you overwrite a python variable pointing to a C++ object (and it is the only
101-
python variable pointing to that object), the C++ will usually be immediately deleted.
102-
This might be a problem if another C++ objects depends ob that old object, e.g.
101+
python variable pointing to that object), the C++ object will usually be immediately deleted.
102+
This might be a problem if another C++ objects depends on that old object, e.g.
103103
a ``GraphAttributes`` instance depending on a ``Graph`` instance.
104-
Now the other C++ object has a pointer to a delted and now invalid location,
104+
Now the other C++ object has a pointer to a deleted and now invalid location,
105105
which will usually cause issues down the road (e.g. when the dependant object is
106106
deleted and wants to deregister from its no longer alive parent).
107-
This overwriting might easily happen if you run a Jupyter cell multiple times.
108-
Please ensure that you always overwrite or delete C++ dependent variables in
107+
This overwriting might easily happen if you run a Jupyter cell multiple times or some code in a ``for``-loop.
108+
Please ensure that you always overwrite or delete dependent C++ variables in
109109
the reverse order of their initialization.
110110

111111
.. code-block:: python
112112
113-
CGA = CG = G = None
114-
G = ogdf.Graph()
115-
CG = ogdf.ClusterGraph(G)
116-
CGA = ogdf.ClusterGraphAttributes(CG, ogdf.ClusterGraphAttributes.all)
117-
113+
for i in range(5):
114+
# clean-up all variables
115+
CGA = CG = G = None # note that order is different from C++, CGA will be deleted first, G last
116+
# now we can re-use them
117+
G = ogdf.Graph()
118+
CG = ogdf.ClusterGraph(G)
119+
CGA = ogdf.ClusterGraphAttributes(CG, ogdf.ClusterGraphAttributes.all)
120+
121+
# alternatively manually clean up in the right order
122+
del CGA
123+
del CG
124+
del G

0 commit comments

Comments
 (0)