开发者

c++ QThread and boost call back functions

I would like to know whether there is any way to check the validity of a boost call back function.

Issue is as follows

class A; class B;

In class A's initialise function following is done.

boost::function < void(class B) > call_back;

using namespace boost::lambda; call_back = bind(&A::callback_after_preparation, this, boost::lambda::_1);

The problem is that the call back is called from a QThread and before A::callback_after_preparation is called from QThread, 开发者_Python百科A's object is deleted from the application(this is one use case in application)

So the application exits while accessing datambers in A.

Is there any way to check the validity of call_back function ??

Please answer


You are really asking if there is any way of knowing that a specific object has been deleted, presumably in another thread. It is up to your code to handle stuff like that - after all it was your code that performed the deletion, by setting a flag of some sort.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜