debug assertion failed! mfc/winocc.cpp line 381
2015-03-16 17:29
1146 查看
在当前对话框下采集下位机数据的过程中,直接点击返回上一对话框按钮在debug模式弹出debug错误(在release模式下没有报错)的原因分析。
void CTrainDlg::OnBnClickedButtonReturn()
{
// TODO: 在此添加控件通知处理程序代码
if (m_bUpload==true)
{
//需要测试
Upload();
}
OnCancel();
}
1) debug错误
2)点击重试 点击中断 查看调用堆寨窗口
CWnd::InvokeHelper()说明:当在项目中插入ActiveX控件ClassWizard生成的CWnd的派生类时,在C++类中可以看到其成员函数的代码中都有对InvokeHelper函数的调用,InvokeHelper函数的第一个参数都和对应的属性或方法在ActiveX控件中的分发(dispatch)ID(标识ActiveX控件的方法或属性的)相对应。通过查看ActiveX控件help文件可以发现,ActiveX控件的方法在生存的C++类中都有同名的成员函数与之对应,ActiveX控件的属性都有一组Get和Set函数对其操作,其中ActiveX控件的方法和属性操作与生成的C++类成员函数相关联都是通过InvokeHelper函数的调用来完成的,InvokeHelper函数的第一个参数是由Component
Gallery(控件提供者)提供的。因为经过这样的处理,所以我们如果要调用ActiveX控件的方法或对其属性进行取和设置操作,只需调用生成的C++类对应的成员函数便可。
3)通过上述窗口定位错误位置
[cpp] view
plaincopy
void CTrainDlg::AnalyzeSampledData(LPARAM lParam,int wNums)
{```````
if(lfForce>30)
{
//在plot上控件上实时绘制控制桨频下的曲线
m_lAxisX=m_lAxisX+1;
m_ixyPlotForce.GetChannel(0).AddXY(m_lAxisX,lfForce);//程序退出时debug下提示错误
}
else
{
//清除界面,并添加标准曲线
m_lAxisX=1;
m_ixyPlotForce.ClearAllData();
}
[cpp] view
plaincopy
````````
}
4)分析错误原因:
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
[cpp] view
plaincopy
原因在于点击返回时,窗口已经销毁,但是采集线程仍然在发送数据,<pre name="code" class="cpp">WindowProc()仍然处理消息,因此执行到<span style="font-family:Arial,Helvetica,sans-serif">m_ixyPlotForce.ClearAllData();这一句时一定会报错,</span></pre><pre name="code" class="cpp"><span style="font-family:Arial,Helvetica,sans-serif">因为这个时候窗口已经销毁了,</span><span style="font-family:Arial,Helvetica,sans-serif">m_ixyPlotForce对应的控件已经没有了!</span></pre><pre name="code" class="cpp"><span style="font-family:Arial,Helvetica,sans-serif">5)解决:</span></pre><pre name="code" class="cpp"><span style="font-family:Arial,Helvetica,sans-serif">在返回按钮中加入代码保护,通过设定一个标志位,如果在比赛过程中就直接退出的话,要先关闭采集线程等资源。
</span><span style="font-family:Arial,Helvetica,sans-serif"></span><pre name="code" class="cpp"></pre></pre>
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
void CTrainDlg::OnBnClickedButtonReturn()
{
// TODO: 在此添加控件通知处理程序代码
if (m_bUpload==true)
{
//需要测试
Upload();
}
OnCancel();
}
1) debug错误
2)点击重试 点击中断 查看调用堆寨窗口
CWnd::InvokeHelper()说明:当在项目中插入ActiveX控件ClassWizard生成的CWnd的派生类时,在C++类中可以看到其成员函数的代码中都有对InvokeHelper函数的调用,InvokeHelper函数的第一个参数都和对应的属性或方法在ActiveX控件中的分发(dispatch)ID(标识ActiveX控件的方法或属性的)相对应。通过查看ActiveX控件help文件可以发现,ActiveX控件的方法在生存的C++类中都有同名的成员函数与之对应,ActiveX控件的属性都有一组Get和Set函数对其操作,其中ActiveX控件的方法和属性操作与生成的C++类成员函数相关联都是通过InvokeHelper函数的调用来完成的,InvokeHelper函数的第一个参数是由Component
Gallery(控件提供者)提供的。因为经过这样的处理,所以我们如果要调用ActiveX控件的方法或对其属性进行取和设置操作,只需调用生成的C++类对应的成员函数便可。
3)通过上述窗口定位错误位置
[cpp] view
plaincopy
void CTrainDlg::AnalyzeSampledData(LPARAM lParam,int wNums)
{```````
if(lfForce>30)
{
//在plot上控件上实时绘制控制桨频下的曲线
m_lAxisX=m_lAxisX+1;
m_ixyPlotForce.GetChannel(0).AddXY(m_lAxisX,lfForce);//程序退出时debug下提示错误
}
else
{
//清除界面,并添加标准曲线
m_lAxisX=1;
m_ixyPlotForce.ClearAllData();
}
[cpp] view
plaincopy
````````
}
4)分析错误原因:
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
[cpp] view
plaincopy
原因在于点击返回时,窗口已经销毁,但是采集线程仍然在发送数据,<pre name="code" class="cpp">WindowProc()仍然处理消息,因此执行到<span style="font-family:Arial,Helvetica,sans-serif">m_ixyPlotForce.ClearAllData();这一句时一定会报错,</span></pre><pre name="code" class="cpp"><span style="font-family:Arial,Helvetica,sans-serif">因为这个时候窗口已经销毁了,</span><span style="font-family:Arial,Helvetica,sans-serif">m_ixyPlotForce对应的控件已经没有了!</span></pre><pre name="code" class="cpp"><span style="font-family:Arial,Helvetica,sans-serif">5)解决:</span></pre><pre name="code" class="cpp"><span style="font-family:Arial,Helvetica,sans-serif">在返回按钮中加入代码保护,通过设定一个标志位,如果在比赛过程中就直接退出的话,要先关闭采集线程等资源。
</span><span style="font-family:Arial,Helvetica,sans-serif"></span><pre name="code" class="cpp"></pre></pre>
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
注意:AnalyzeSampledData()函数是在WindowProc()函数中调用。
相关文章推荐
- debug assertion failed! winocc.cpp line 381
- Debug Assertion Failed!……File:winocc.cpp Line:345……(Press Retry to debug the application)
- MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误
- MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误
- MFC学习笔记之VC++ Debug Assertion Failed! 错误(File: strex.cpp Line: 690)
- VC Debug Assertion Failed File:dlgdata.cpp Line 43
- 引用 Debug Assertion Failed!File:wingdi.cpp Line:1120
- debug assertion failed, file:dlgdata.cpp,line"43
- VS2008解决objcore.cpp Line: 40 Debug Assertion Failed!
- Debug Assertion Failed! occont.cpp line:926
- debug assertion failed, file:dlgdata.cpp,line43
- MFC程序出现“Debug Assertion Failed! File:afx.inl Line:177”错误
- Debug Assertion Failed File:dgbdel.cpp Line 52
- Debug Assertion Failed! File:cmdtarg.cpp Line:52
- MFC程序出现“Debug Assertion Failed! File:afx.inl Line:177”错误
- 调试错误 debug assertion failed; file:dlgdata.cpp; line 43 分析析
- VC++ Debug Assertion Failed! 错误(File: winmdi.cpp Line: 141)
- Debug Assertion Failed! FILE viewform.cpp , line 69
- VC错误: debug assertion failed; file dlgdata.cpp; line43
- 关于 debug assertion failed, file:dlgdata.cpp,line"44 错误