Strange crash with own slider class


#1

Okay, maybe it’s something completely obvious, but I’m really at a loss here… I’ve created a class MySlider which inherits from Slider. It has its own mouseDoubleClick and mouseDrag functions, that’s it (no class variables added). This MySlider is now serving as the base class for different slider types, each with their own getValueFromText and getTextFromValue routines. All of this works fine, except that in one plugin things go wrong for one of the subclasses. Here is some code:

#include "MySlider.h"

class FreqSlider : public MySlider
{
public:
	FreqSlider(const String &name);
	~FreqSlider();
	virtual double getValueFromText(const String& text);
	virtual const String getTextFromValue(double Value);
	void setFreqMin(double f);
	void setFreqMax(double f);
private:
	double freq_min, freq_max;
	
};

Apart from the mentioned routines, there are two variables, freq_min and freq_max, and routines to change them. Now in the constructor of the editor of the plugin, I create an instance of the slider, just like you would expect:

That’s where the crash is happening. Now the funny thing is: if we look at the constructor of freqSlider

FreqSlider::FreqSlider(const String& name) : MySlider(name)
{
	freq_min=20.;
	freq_max=21000.;
}

you see that freq_min and freq_max are initialized. If I comment out these two lines, everything’s fine. :shock: Does anybody have any idea what to do with this? I’m using VisualC++ 8.0; it fails both in debug and in release mode.


#2

Have to admit that sounds very odd… Have you stepped over those troublesome lines in the debugger to watch what happens?


#3

Try to rebuild. Sometimes VC++ does these kind of things and when you rebuild it’s ok.


#4

Or you might be using a pointer that is not valid at all. So when it tries to access the memory for the variables, you experience a crash?


#5

I’ve tried all the usual suspects (rebooting, debugging) for two days now, nothing suspicious. I’m starting to see ghosts…

I’m trying the same thing on Mac now, it’s crashing too. I’m just about to see whether it’s in the same place. I’ll keep you posted!


#6

Ok, the AU works, the VST crashes (at the same point). I really don’t know what’s going on here. I have the feeling that the memory is corrupted elsewhere, but then even if I change the order of adding components to the GUI, it always crashes at the same slider. :cry: