Strange thunk errors in modded ReferenceCountedObjectPtr


#1

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. )

[code]template
class ReferenceCountedObjectPtr
{
public:
/** The class being referenced by this pointer. */
typedef ReferenceCountedObjectClass ReferencedType;

SNIP

private:
//==============================================================================
ReferenceCountedObjectClass* referencedObject;

//#if ENABLELEAKDEBUG
int refCountObjectPtrId;
//#endif

};[/code]

I’ve enclosed the entire modded file.


#2

It sounds to me like your build has somehow got both the modded and unmodded classes in it. Probably a rogue file that’s including a header from an unexpected place. Try searching your machine for all instances of that file, and removing them.


#3

thanks. i’ll go check that out.


#4

tried all that. no change I’m afraid.

Heres a list of what came up on a “spotlight” search for ReferenceCountedObject on my hard disk:

juce_core_includes.h
juce_DynamicObject.h
juce_Expression.h
juce_Font.h
juce_Message.h
juce_MouseCursor.h
juce_ReferenceCountedObject.cpp.zip
juce_ReferenceCountedObject.h
juce_Synthesiser.h
juce_Typeface.h
juce_Value.h

and for ReferenceCountedObjectPtr:

compile_options.hpp
juce_amalgamated.cpp
juce_amalgamated.h
juce_AsyncUpdater.h
juce_AudioProcessorGraph.h
juce_Expression.cpp
juce_Expression.h
juce_Font.h
juce_Image.cpp
juce_Image.h
juce_LowLevelGraphicsSoftwareRenderer.cpp
juce_Message.h
juce_MessageManager.h
juce_PopupMenu.cpp
juce_ReferenceCountedArray.h
juce_ReferenceCountedObject.h
juce_Synthesiser.h
juce_Typeface.h
juce_Value.cpp
juce_Value.h
juce_ValueTree.h
juce_VSTPluginFormat.cpp
juce_WeakReference.h
JUCE: Class List.webarchive

I’ve enclosed my project code - which is very small - its just a test harness to try out my RBclasses.hpp and RBclasses.cpp files and the reference counting stuff until ready for my main project.

The project as zipped compiles and builds fine. Until i remove the comments at: // int refCountObjectPtrId;