Bug in juce_DrawableButton.cpp

In juce_DrawableButton.cpp, setImages() calls copyDrawableIfNotNull for each Drawable pointer.

However the size of the Drawable component is not copied to the Drawable member pointer.

This leads to Drawable components with a zero size. As the result the button can disappear when turned on...

 

I modified copyDrawableIfNotNull  to copy the size of the drawable component into the new one and it fixes the problem :

static Drawable* copyDrawableIfNotNull (const Drawable* const d)
{

    // old code
    //return d != nullptr ? d->createCopy() : nullptr;

 

   // new code

    Drawable* pDrawable = nullptr;
    
    if(d != nullptr)
    {
        pDrawable = d->createCopy();
        pDrawable->setBounds(d->getBounds());
    }

    return pDrawable;

}

Ok, but I think you're fixing the wrong thing there. If a createCopy method is returning a new Drawable which isn't correct, then that would need to be fixed, it's not the responsibility of copyDrawableIfNotNull to fix it. If you let me know which Drawable subclass is the problem, I'll take a look..

Yes you're right.

It's the DrawableImage subclass.

Ok, try it now.

Ok. It works