Well, I got the problem solved. It was one factor I did not expect (aren't they all!).
the problem was in a method in the object that gets destroyed and re-instantiated. I knew that the crash had something to do with allocating the object again, or with deleting the old one.
It turns out that it was a problem with a 'static' variable. I had wanted to have a variable whose value was retained across calls to a method (one which parses a lane read from a file for the putpose of filling data arrays).
so I wrote the method thusly:
Code: Select all
void CapturedData::ParseLine(wxString *line)
{
wxString variable;
wxString value;
size_t length;
long nValue;
static int ptr = 0;
int loc;
.
.
.
loc = line->Find((wxChar)'@');
value = line->Mid(0,loc);
if (!value.ToLong(&nValue,16) )nValue = 0;
values[ptr] = (int)nValue;
value = line->Mid(loc+1);
if (!value.ToLong(&nValue,10) )nValue = 0;
timestamps[ptr] = nValue;
ptr++;
.
.
.
When I make the 'ptr' variable a private class variable, which is initialized to zero in the constructor, then everything works. When I simply make the scope of the 'ptr' variable just the method (and make it static in the method), then it does not work.
I had thought that it was OK to allocate static variables inside methods and it will work as I had expected!