Look and Feel crash when unload and reload

Hello.

I'm having a problem with my plugin crashing. I can create and unload as many instances as I want, however, when I remove the last instance and then create another one, it crashes the host.

I believe the look and feel is causing the problem. It happens in both AU and VST versions. I'm on OSX Yosemite.

I'm inheriting deletedAtShutdown, and using a singleton http://www.juce.com/forum/topic/setdefaultlookandfeel

I've tried decalring singleton false for doNotRecreateAfterDeletion, but that will not reload the L&F if I reload the plugin after unloading it, and defaults to the stock V3 Look and feel.

 

Have I missed something silly? Should I be checking if the singleton exists before calling getInstance()?

EDIT: Oh, and I'm pretty sure this didn't happen until I updated the modules to the latest version. I was only a couple of points behind until the update.

Cheers..

Here's my crash log and implementation....

 

eg. .h

class MyLookAndFeel    : public LookAndFeel_V3,
                            public DeletedAtShutdown

{

public:
    MyLookAndFeel();
    ~MyLookAndFeel();
    juce_DeclareSingleton (MyLookAndFeel, true);

    void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
                               bool isMouseOverButton, bool isButtonDown) override;

 

eg.cpp

MyLookAndFeel::MyLookAndFeel()
{
}

MyLookAndFeel::~MyLookAndFeel()
{
}

juce_ImplementSingleton (MyLookAndFeel)

 

and in the editor...

LookAndFeel::setDefaultLookAndFeel(MyLookAndFeel::getInstance());

Here's the crash report from Apple.....

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.MyPluginID.MyPlugin    0x0000000128357d38 juce::ComboBox::lookAndFeelChanged() + 68
1   com.MyPluginID.MyPlugin    0x000000012832193d juce::Component::internalHierarchyChanged() + 71
2   com.MyPluginID.MyPlugin    0x0000000128321999 juce::Component::internalHierarchyChanged() + 163
3   com.MyPluginID.MyPlugin    0x00000001283231fd juce::Component::addChildComponent(juce::Component&, int) + 211
4   com.MyPluginID.MyPlugin    0x0000000128292fb4 MyPluginAudioProcessorEditor::MyPluginAudioProcessorEditor(MyPluginAudioProcessor*) + 1330
5   com.MyPluginID.MyPlugin    0x0000000128292332 MyPluginAudioProcessor::createEditor() + 34
6   com.MyPluginID.MyPlugin    0x00000001282a8ecd juce::AudioProcessor::createEditorIfNeeded() + 63
7   com.MyPluginID.MyPlugin    0x00000001282a3ff3 JuceAU::JuceUICreationClass::uiViewForAudioUnit(objc_object*, 

**Added to original post**

It’s good practice to call setDefaultLookAndFeel in your processor. This way it is already set before your editor is constructed. 1

I once had issues even when it was called first in the editors constructor. Some parts where just not taken from my own LookAndFeel.

Hard to tell from the stack trace, but probably some sort of callback happening during a constructor that's causing a pure virtual call?

Cheers guys. Done a bit more debugging, and it's inheriting from DeletedAtShutdown that's causing the problem. If I remove this and call LookAndFeel::setDefaultLookAndFeel(MyLookAndFeel::getInstance()); , will the L&F class still deal with any clearing up that's needed?