T , 2011-10-12 17:17 -0400, David Lonie rakstīja:
> On Wed, Oct 12, 2011 at 4:53 PM, My Th <rei4...@gmail.com> wrote:
> > 
> > The reason it breaks on making second instance is that you invalidate
> > plugin map pointers by deleting the instance. Those pointers are set by
> > the constructor to point to the new instance, but the destructor doesn't
> > set them back to the default global instance for the plugin.
> >
> > Forcfield destructor should do this:
> >
> > OBForceFieldUFF::~OBForceFieldUFF() {
> >  if (this != Default()) {
> >    Map()[_id] = Default();
> >    PluginMap()[TypeID()] = Default();
> >  }
> > }
> >
> > With this for me your test program runs without crashing.
> 
> Thanks! I can confirm that this fixes the problem.
> 
> Can someone add this to the sources? I would, but I'm a bit too
> unfamiliar with this part of OB to know if this should go in
> ForceFieldUFF, ForceField, Plugin, ... or if there are any side
> effects from this fix.

There shouldn't be any side effects, AFAIK.

In my opinion this should be applied to destructors of all plugin
sub-types (ForceFieldUFF, etc.).

Then there are other issues..

It has to be decided if deleting the default instance is allowed and
what would it mean:
- OB forgets that plugin sub-type completely or
+ new default instance is created automatically or
- keep track of all instances and make next default (finally 1 or 2).

Also, what to do when the default instance is switched (or new instance
with an existing ID is created):
- Do nothing (as currently) or
- keep track of all instances so we can later fall back to it or
- delete the old one or
+ require the one who switches the default to clean up (document it!).

I would prefer the options marked with "+", but developers should decide
what is needed. I'm just interested in getting my plugin loading patch
in, so that it is not required to call OBConversion constructor to get
plugins loaded :)


Reinis


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to