I want to use the TimeSliceThread and TimeSliceClient classes to create a kind of “system timer” which regularly updates some objects (im assuming this is how these classes are used).
So, I’ve started a little test app to work things out and have come across some problems.
I have a custom widget which inherits Component, ButtonListener, ChangeListener, and TimeSliceClient. I have implemented useTimeSlice().
I then create a TimeSliceThread in another component, and call addTimeSliceClient().
Here is pretty much how I setup the TimeSliceThread:
mTimeSliceThread = new TimeSliceThread();
mTimeSliceThread->addTimeSliceClient((TimeSliceClient*const)mMetronome);
mTimeSliceThread->startThread();
This is what my MetronomeWidget class looks like:
class MetronomeWidget : public Component,
public ButtonListener,
public ChangeListener,
public TimeSliceClient
{
[...]
And this is my implementation of useTimeSlice():
bool useTimeSlice()
{
return false;
}
When I compile and run this code, using visual c++ and debug settings, I get a run-time exception:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
It then opens juice_timeslicethread.cpp and points to line 132:
if (clientBeingCalled->useTimeSlice())
Here is a zip of the complete project http://www.puresimplicity.net/~ldb/hacks/juce/SoundMachine.zip
Any help would be greatly appreciated! I have a feeling im probably doing something really stupid, I just cant see what at the moment.
Levi
