[solved] Custom CallOutBox crashing on child component with BAD_ACCESS


#1

I've created a derived class of CallOutBox to enable removal of the arrow before its drawn. 

The files are here: https://gist.github.com/adamski/9fac24ed90de412396a1

Its crashing in the addAndMakeVisible of the child component, and it seems to be due to a String within a ReferenceCountedObject::Ptr which is stored in the contentComponent. Its crashing on line 1488 of juce_Component.cpp (latest tip from about a week ago):

void Component::addAndMakeVisible (Component& child, int zOrder)

{

    child.setVisible (true); // <-- BAD_ACCESS here

    addChildComponent (child, zOrder);

}

The same code (CallOutBox::launchAsynchronously) works fine with the standard CallOutBox. Wonder if its somehow to do with passing references to the base class? My C++ skills are still a little green ! I assume that something is not getting initialised properly, or a reference has been lost along the way. 


#2

I did this a few weeks back and didn't hit any problems. Sounds like you're just deleting something you're inherited calloutbox that needs to stay; I'd just start from scratch and experiment a bit removing lines of code you think relate to the drawing of the arrow and see what ends up working.

 


#3

Ok cheers will give it another bash this evening !


#4

No worries. If you just create your copy and pasted subclass so it functions exactly as a normal calloutbox, then try removing lines of code that relate to the arrow drawing one by one, you will see what breaks and what is working. You may also need to change some things in the LnF function for drawing the calloutbox border depending on what you need to do.


#5

Sorted - I didnt actually need to do anything to it to prevent the arrow being drawn - just initialise arrowSize to 0 ! 

I copied the contents of the juce_CallOutBox files, renamed the relevent bits and had it inherit from CallOutBox. Just needed to add the initialiser for the base class. Kept the LnF functions the same. 

Thanks