Why do i get an assertion here?


demoSong1InputStream  is a ScopedPointer<MemoryInputStream> , and already filled with a MemoryInputStream

when i use 

demoSong1InputStream = new MemoryInputStream(BinaryData::loop_ogg, BinaryData::loop_oggSize,false); 

a second time i get an assertion

   virtual ~ReferenceCountedObject()

        // it's dangerous to delete an object that's still referenced by something else!
        jassert (getReferenceCount() == 0);

but MemoryInputStream isn't ReferenceCountedObject, isn't it, how can that be?

     Droid.exe!juce::ReferenceCountedObject::~ReferenceCountedObject() Line 113    C++
     Droid.exe!juce::WeakReference<juce::Component,juce::ReferenceCountedObject>::SharedPointer::~SharedPointer()    C++
     Droid.exe!juce::WeakReference<juce::Component,juce::ReferenceCountedObject>::SharedPointer::`scalar deleting destructor'(unsigned int)    C++
     Droid.exe!juce::ContainerDeletePolicy<juce::MemoryInputStream>::destroy(juce::MemoryInputStream * object=0x050c71b8) Line 48    C++
     Droid.exe!juce::ScopedPointer<juce::MemoryInputStream>::operator=(juce::MemoryInputStream * const newObjectToTakePossessionOf=0x0233a830) Line 141    C++


Most likely that you've deleted the first object somewhere else, and the scopedpointer is left with a dangling pointer.


well yes, you are right. The WeakReference in the stacktrace irritated me. Thanks