I am going to be using the JUCE ReferenceCounting classes extensively in my project, and early testing has shown that i could do with making myself some utility functions on top of ReferenceCountedObjectPtr in order to help with memory leaks, dangling and circular references etc.
To this end I am experimenting with a modified version of file “juceReferenceCountedObject.h” in order to add some simple
facility for tracking down undeleted ReferenceCountedObjects, circular references etc. The eventual idea is that with a MACRO flag set true, each time a ReferenceCountedObject gets referenced by
a ReferenceCountedObjectPtr, a unique integer ID gets added to an array inside the ReferenceCountedObject to maintain a list of reference “IDs”. Each time a reference is removed to this object the ID of the reference also gets removed. This then allows me to track any problematic references after JUCE has detected “hanging” references on closing the app.
I have a simple MACRO ENABLELEAKDEBUG throughout the modded file to switch in/out the debug feature.
As part of this I added a simple private integer member called refCountObjectPtrId to the template class ReferenceCountedObjectPtr.
But whenever I do a build with this i get lots of “non-virtual thunk” errors. Simply commenting out the member ( or making ENABLELEAKDEBUG = FALSE ) makes things build ok.
I am perplexed. How can adding a single integer member to this template cause red armaggedon in my Xcode ? ( Xcode 4.2 )
I have tried doing a “clean" on the build but to no avail.
( NOTE: there is a separate new juceReferenceCountedObject.cpp file which was just created to create the static “ReferenceCountedObject::objectIDcounter” but i haven’t bothered including its code here. It works fine and has no bearing on the thunks. )
/** The class being referenced by this pointer. */
typedef ReferenceCountedObjectClass ReferencedType;
I’ve enclosed the entire modded file.