If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
I did implement the thread deletion logic inside OnClose() as in the documentation. What I'd like to avoid is calling wxThread::Delete() in the middle of the "function_call". Something like this:
I can make a member variable inside the thread class and check if its safe to delete the thread object and check if this flag is set as in the code above. But maybe such mechanism is already exists?
Last edited by ONEEYEMAN on Tue Jun 26, 2018 2:26 pm, edited 1 time in total.
I can make a member variable inside the thread class and check if its safe to delete the thread object and check if this flag is set as in the code above.
I don't see what difference that would make. If you call wxThread::Delete(), the thread doesn't get killed immediately. It only sets an internal flag which is checked with TestDestroy(). A detached thread will destroy (as in delete) itself when it terminates. (After you return from Entry()).
doublemax,
No, it does not.
But with current code I have a not released pointer, because the call to Delete was executed in the middle of the some function call.
That's why I'd like to have a flag indicating that the function finished and its ok to delete the thread with Delete() call.
Now this function is a member of another class which is a member of my thread class. So its like this:
doublemax,
I don't know. I guess its just a timing issue.
But I think I might have a solution. I will do a clean-up in two places: when I don't need the resource and in the thread class destructor, making the resource a class member. That way everything should be good.