Slider PopupDisplayComponent bug


#1

if a slider is destructed while its PopupDisplayComponent exists then we get a EXC_BAD_ACCESS in the PopupDisplayComponent destructor.

to reproduce :

  • open the demo runner -> widgetdemo -> sliders tab
  • hover the slider that is at the extreme right to see its PopupDisplayComponent
  • quit (cmd+q) the app while the PopupDisplayComponent is shown

#2

Thanks, I’ll sort this out.


#3

I have a derived Slider class with a L&F… and even though the LookAndFeel is declared as the first variable in the class and I have:

 setLookAndFeel (nullptr);

in the destructor… if I quit while the pimpl->popupDisplay is visible then I hit the ~LookAndFeel() assertion.

Rail


#4

Adding the following lines to the destructor of your derived Slider should fix the issue:

if (auto* popup = getCurrentPopupDisplay())
    popup->setLookAndFeel (nullptr);

#5

Thanks! Oddly enough it needs both…

MixerFader::~MixerFader()
{    
    if (auto* popup = getCurrentPopupDisplay())
        popup->setLookAndFeel (nullptr);
    
    setLookAndFeel (nullptr);
}

Even though the L&F is the first class variable defined.

Cheers,

Rail


#6

Yeah, it’s because the Slider and its PopupDisplayComponent hold a reference to the L&F and they are destroyed after your derived class which contains the L&F object.


#7

That explains the refCount value of 2 I was seeing.

Thanks!

Rail