hi,
sorry, It is me again. but after a hundred trials and errors, I finally am able to document the problem as understandable as possible. hope someone would help me with a practical solution.
this is the code of TreadWithProgressWindow exctaly defined in juce demo.
class DemoBackgroundThread : public ThreadWithProgressWindow
{
public:
DemoBackgroundThread()
: ThreadWithProgressWindow (T("busy doing some important things..."),
true,
true)
{
setStatusMessage (T("Getting ready..."));
}
~DemoBackgroundThread()
{
}
void run()
{
const int thingsToDo = 10;
for (int i = 0; i < thingsToDo; ++i)
{
// must check this as often as possible, because this is
// how we know if the user's pressed 'cancel'
if (threadShouldExit())
break;
// this will update the progress bar on the dialog box
setProgress (i / (double) thingsToDo);
wait (500);
setStatusMessage (String (thingsToDo - i) + T(" things left to do..."));
}
}
};
now if I run this thread like this :
class aClass
{
public :
aClass () {}
~aClass() {}
void this()
{
DemoBackgroundThread m;
m.runThread();
}
};
everything works file. I am able to run this() for any number of times and no problem. but I really need to define the Thread like below :
class aClass
{
DemoBackgroundThread* m;
public :
aClass ()
{
m = new DemoBackgroundThread;
}
~aClass()
{
delete m;
}
void this()
{
m.runThread();
}
};
and the aClass is not going to be destructed till the end of the application and has many other members and variables. but even in the simplest form like above it has a problem.
when I call this() , for the first time the ThreadWithProgressBar appears and do it’s work fine. if I press cancel . and again call this() no problem occurs. but the first time that the Thread exits normally without clicking the cancel button. the next time by calling this() , visual studio triggers a breakpoint but every variables and everything seems normal. by clicking continue the thread appears and do it’s job normally. but why does it trigger a breakpoint trigger all about ? It is just making me crazy.
please I really need to use the threadWithProgressWindow in this way with new and delete operators. it would be great if someone really test this code. I think it might be bug.
:: Nikola Williams