While doing some conversions to the new SCF, I realized a potential issue with the handling of the iEventHandler interface. I may have been inadvertently been adding memory leaks when converting classes to the new SCF. I'm not very familiar with the new event system so I'm not sure if this is a problem or not.
Here is the setup: * The class "csFoo" implements needs to register as an event listener. * The "csFoo::Initialize" method registers the event listener. * The "~csFoo::csFoo" destructor unregisters the event listener. * The "~csFoo::csFoo" destructor will only get called when the reference count goes to zero. Does registering the event listener cause a (non-weak) reference to the event handler to be held by the event queue? If so, then the natural way of writing the above with the new SCF (i.e. "class csFoo : scfImplementation1<csFoo, iEventHandler>") will make any object written in this fashion live at least as long as the event queue (since it never gets unregistered unless it is destroyed which never happens unless it is unregistered). Is this a problem? If it is a problem, is embedding the event handler inside the outer class the best solution? (Part of the point of the new SCF is to get rid of those.) Would it be better to have an option during subscription that allowed a choice between using a hard ref (for "fire and forget" event listeners) and a weak ref for cases where the object should just go away and unregister itself if nothing else refers to it? (Is the latter case needed?) Michael D. Adams [EMAIL PROTECTED] ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Crystal-main mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crystal-main Unsubscribe: mailto:[EMAIL PROTECTED]
