Going back to lookAndFeel_V2

I recently updated to JUCE v 4.0.2 and the default look and feel of my plugin changed to the new LookAndFeel_V3. I'm trying to go back to LookAndFeel_V2, but it is more difficult than I thought. 

The JUCE demo uses a OwnedArray of dynamically instantiated LookAndFeels. I only need one, so I used a scoped pointer instead, but otherwise I basically copied the code from the demo.  

This is in my editor header: 

ScopedPointer<LookAndFeel> mLookAndFeel;     // using ScopedPointer<LookAndFeel_V2> gives the same results

and this is in my editor constructor: 

mLookAndFeel = new LookAndFeel_V2();
for (int i = 0; i < getNumChildComponents(); ++i){
    if (Component* c = getChildComponent(i)){
        c->setLookAndFeel (mLookAndFeel);

The plugin opens fine (with LookAndFeel_V2), but on exiting the DAW, I'm getting a crash at the last line of this snippet from juce_TabbedButtonBar.cpp: 

void TabbedButtonBar::updateTabPositions (bool animate)
    LookAndFeel& lf = getLookAndFeel();
    int depth = getWidth();
    int length = getHeight();
    if (! isVertical())
        std::swap (depth, length);
    const int overlap = lf.getTabButtonOverlap (depth) + lf.getTabButtonSpaceAroundImage() * 2;

The error is: 

libc++abi.dylib: Pure virtual function called!

Any ideas?



Huh? There's no reason to do all that messing about. The demo is a bad example because it needs to be able to swap multiple L+Fs.

Just create a LookAndFeel_V2 (just as a member or static somewhere, don't faff about with ScopedPointers or heap allocation), and then call LookAndFeel::setDefaultLookAndFeel() with it. No need to assign it to components.

excellent, worked like a charm, thank you!