This patch needs the following added to the appropriate place to not
break memory management.
+ %pythonprepend Particle::Particle %{
+ if len(args) >0: self.thisown=False
+ %}
Probably got lost somewhere in the patch process.
On Jan 5, 2009, at 11:43 AM, Notification of IMP commits wrote:
Patch from Daniel, with minor cleanup by me: add a constructor to
Particle to
take a Model, and change a few tests to use this constructor.
Modified: trunk/kernel/include/Particle.h
===================================================================
--- trunk/kernel/include/Particle.h 2008-12-31 00:40:19 UTC (rev 1101)
+++ trunk/kernel/include/Particle.h 2009-01-05 19:43:25 UTC (rev 1102)
@@ -96,8 +96,9 @@
public:
+ //! Construct a particle and add it to the Model
+ Particle(Model *m);
-
Particle();
~Particle();
Modified: trunk/kernel/pyext/IMP/test.py
===================================================================
--- trunk/kernel/pyext/IMP/test.py 2008-12-31 00:40:19 UTC (rev 1101)
+++ trunk/kernel/pyext/IMP/test.py 2009-01-05 19:43:25 UTC (rev 1102)
@@ -34,8 +34,7 @@
def create_point_particle(self, model, x, y, z):
"""Make a particle with optimizable x, y and z attributes, and
add it to the model."""
- p = IMP.Particle()
- model.add_particle(p)
+ p = IMP.Particle(model)
p.add_attribute(IMP.FloatKey("x"), x, True)
p.add_attribute(IMP.FloatKey("y"), y, True)
p.add_attribute(IMP.FloatKey("z"), z, True)
Modified: trunk/kernel/src/Particle.cpp
===================================================================
--- trunk/kernel/src/Particle.cpp 2008-12-31 00:40:19 UTC (rev 1101)
+++ trunk/kernel/src/Particle.cpp 2009-01-05 19:43:25 UTC (rev 1102)
@@ -11,6 +11,13 @@
IMP_BEGIN_NAMESPACE
+Particle::Particle(Model *m)
+{
+ is_active_ = true;
+ m->add_particle(this);
+}
+
+
Particle::Particle()
{
is_active_ = true;
Modified: trunk/kernel/test/particles/test_refcount.py
===================================================================
--- trunk/kernel/test/particles/test_refcount.py 2008-12-31 00:40:19
UTC (rev 1101)
+++ trunk/kernel/test/particles/test_refcount.py 2009-01-05 19:43:25
UTC (rev 1102)