AU Plugin Editor window inheriting from ReferencecountedObject problems on closing window


#1

I have an AU AudioProcessorEditor  window that inherits from ReferenceCountedObject. 

 

Several ReferenceCountedObjectPtr  instances  point to this.  But when the window gets closed ( by AU Lab ) there are problems. 

 

It seems if the window is assigned to a global referenceountedpointer ( or a static member of my window ) on creation then there is a reference coint of 1 left over.  now i got over this by just claring the reference count as the last thing in the destructor of my window.

But then when a new editor window is opened i have issues - the referenceountedpointer gets reassigned to the new window but generates an exceptionn. 

 

If - on the other hand I DONT assign the new window instance to any global/static referencecountedpointer - but simply to a naked pointer and return this to createPluginEditor() then the referenceountedobject code will attept to delete my window - generating an assertion - since

my window was deleted by the AU plugin code itself ( in the JUCE AU wrapper ) . 

 

So what to do ? 

 

I really need the editor window to use referencecounting ! 

 

heres code: 

 

//-----------------------------------------  WEditPlugin::  ~WEditPlugin  ------------------------------------------

WEditPlugin::~WEditPlugin() {

    VUtimer->stop();

    VUtimer = nullptr;

     masterReference.clear() ;

    resetReferenceCount();

}

//-------------------------------------  WEditPlugin::  getNewInstance  --------------------------------------

AudioProcessorEditor* WEditPlugin::getNewInstance(AudioProcessor* proc) {

  //  return new WEditPlugin(proc);

 if (  mInstance )   //  mInstance is a static referencecountedptr

     mInstance  = nullptr;          mInstance =  new WEditPlugin(proc);

          return  mInstance;

}

//================================

 

class WEditPlugin : public PluginEditor , IMPLEMENTS ITimerCallBack

{

........

}

 

class PluginEditor  : public Windowbase, public AudioProcessorEditor, IMPLEMENTS MessageListener {

}

 

class Windowbase :  public RB_Object , public ApplicationCommandTarget, public IWindow

class RB_Object : public virtual ReferenceCountedObject

 {

 private:

 protected:

     int OBID__;

 public:

     RB_Object();

 };


#2
I have an AU AudioProcessorEditor  window that inherits from ReferenceCountedObject. 

I stopped reading your post at the first sentence - that ain't going to work! The editor is owned and deleted by the internal wrapper code, which will ignore your reference counting.

If there's some kind of state or data that needs to be shared, put it inside a different reference counted object and have pointers to it from the editor and whatever else needs it.


#3

aha !

 

thanks..   had a feeling that might be the issue  :(