Slider assert jassert style != TwoValue

Hello,
I left Juce and plugins programming for more than one year , and I try to make working an old plugins I made with the latest Juce Version.
I use Reaper , the plugins works , it’s a guitar pedal simulation but with only with one of my amp sim plugins It crash when the GUI of the plugins is hidden and reopen . I tried tu debug it with Visual Studio and before it stop this is the assert :

jassert (style != TwoValueHorizontal && style != TwoValueVertical);

What I don’t understand is that there is no Two values Slider in this plug :

in editor.h

    MyLookAndFeel myLookAndFeel;
Slider gainPot;
Slider bassPot;
Slider midPot;
Slider hardClipThresholdPot;
Slider volumePot;
Slider bassClipPot;
Slider highClipPot;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> gainPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> bassPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> midPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> 
    volumePotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> 
   hardClipThresholdPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> 
    highclipPotAttachement;
ScopedPointer 
   <AudioProcessorValueTreeState::SliderAttachment>BassClipPotAttachement;

in editor.cpp all the sliders are created like this one :

   gainPot.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
gainPot.setRange(0.01f, 60.0f);
gainPot.setTextBoxStyle(Slider::NoTextBox, false, 80, 20);
gainPot.setBounds(20, 28, 80, 80); 
//gainPot.addListener(this);
    gainPot.setLookAndFeel(&myLookAndFeel);
addAndMakeVisible(gainPot);
gainPotAttachement = new 
   AudioProcessorValueTreeState::SliderAttachment(processor.tree, "gain", gainPot);

and in processor.cpp

  NormalisableRange<float> gainParam(0.0f, 80.0f);
NormalisableRange<float> bassParam(-16.0f, 16.0f);
NormalisableRange<float> midParam(-20.0f, 20.0f);
NormalisableRange<float> volumeParam(-48.0f, 0.0f);
NormalisableRange<float> bassClipParam(6000.0f, 15000.0f);
NormalisableRange<float> highClipParam(0.01f, 1000.0f);

NormalisableRange<float> thresholdParam(0.3f, 2.0f);
String paramID = "foo";
tree.createAndAddParameter("gain", "Gain", "Gain", gainParam, 0.0f, nullptr, nullptr);
tree.createAndAddParameter("bass", "Bass", "Attack OSC1", bassParam, 0.0f, nullptr, 
        nullptr);
tree.createAndAddParameter("mid", "Mids", "Mids", midParam, 0.0f, nullptr, nullptr);
tree.createAndAddParameter("volume", "volume", "volume", volumeParam, -20.0f, nullptr, 
       nullptr);
tree.state = ValueTree("Foo");

Thanks,

I finally succeed to make it work
It was the scoped pointer attachements

I changed :

   ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> gainPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> bassPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> midPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> 
        volumePotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> 
       hardClipThresholdPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> highclipPotAttachement;
ScopedPointer <AudioProcessorValueTreeState::SliderAttachment> 
   BassClipPotAttachement;

to :

OwnedArray <AudioProcessorValueTreeState::SliderAttachment> sliderAttachments;

and also the attachments like this :

/*midPotAttachement = new AudioProcessorValueTreeState::SliderAttachment(processor.tree, "mid", midPot);*/
sliderAttachments.add(new 
            AudioProcessorValueTreeState::SliderAttachment(processor.tree, "mid", midPot));

But I have to admit , I didn’t understand what I have done lol …Does someone can show me some examples of the best practices and some explanations about scoped pointers vs standard pointers in this case ?

Thanks

Changing the ScopedPointers to OwnedArray was a good step, since there is no need to keep a member for each attachment. Once set up, there is no need to have them except for keeping them alive.

You can save a lot of your setting up code by using default construction values:

Slider gainPot { Slider::RotaryHorizontalVerticalDrag, Slider::NoTextBox };

This sets the correct slider type.

Next, by connecting the SliderAttachment, the range is automatically set from the parameter.
And last but not least, put the setBounds in the resized() callback, so if the UI is resized (even if you have it fixed at the moment, you might change that in the future), the placement is recalculated.

Third: the lookAndFeel is inherited from the parent component, if it is not set. So if you set myLookAndFeel to the editor, all child components (and the parent of course) will use that one. If you have only one lookAndFeel, that saves some typing as well.
Only caveat: in your editor’s destructor you have to set the lookAndFeel to nullptr, otherwise the editor is still referencing it, while destroying the members, of which the myLookAndFeel is one.

// Constructor
setLookAndFeel (&myLookAndFeel);
sliderAttachments.add (new AudioProcessorValueTreeState::SliderAttachment(processor.tree, "gain", gainPot));

// Destructor:
setLookAndFeel (nullptr);

// resized()
gainPot.setBounds(20, 28, 80, 80);

That should be all you need as far as I can see.

But all that is most likely unrelated to your jassert.
When the code breaks in the debugger (getValue or setValue?) have a look at the variables, if they seem legit?
Sometimes the debugger points wrong, for instance when there is memory corruption, pointing to deleted objects, etc.
Or there was indeed a TwoValueSlider, which sneaked in…

Thanks a lot , I wil make the modifications to the code this evening .

I totally agree that this assert was not related to these modification, but It work lol
I perhaps made a mistake while running the debugger ( I am new to visual studio and C++).
The call stack was also strange and there was not a line of my code in the stack …