当我调用回调时,我收到一个访问冲突错误:
typedef std::function<void(INT_PTR)> DIALOG_CALLBACK;
//Declaration
string userId=getUserId();
DIALOG_CALLBACK callTest=[userID, this] (INT_PTR) -> void{};//Does nothing yet
CustomDialog dlg=new CustomDialog("Are you sure you wish to run this operation", callTest);
....
//Definition
class CustomDialog: DialogBase{
public:
DIALOG_CALLBACK callback;
....
}
//Call
void CustomDialog::OnOK(){
callback(1);//Error occurs within call
}
崩溃发生在标准文件xxfunction
_Ret operator()(_ARG0_A0) const
{ // call through stored object
if (_Impl == 0)
_Xfunc();
return (_Impl->_Do_call(_A0_A1));//Crashes on this line
}
链接:
- Lambda函数
似乎我在某个地方删除了this指针,这就是导致问题的原因。