DS-4000系列板卡SDK and Demo Version 5.1 中的错误
2011-05-09 16:34
781 查看
错误定位
1,工程名字:Src/NetDemoSource/NetServerDemo 工程名: HKVision。服务器端的demo。2,文件和错误定位:
1)中断出现在HKVision.cpp中86行的语句: int nResponse = dlg.DoModal();
BOOL CHKVisionApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif int w = GetSystemMetrics(SM_CXSCREEN); int h = GetSystemMetrics(SM_CYSCREEN); if((w < 1024)||(h < 768)){ AfxMessageBox("You must set display resolution to 1024x768 or more in order to run the program/n"); return FALSE; } CHKVisionDlg dlg; m_pMainWnd = &dlg; RegisterLogRecordCallback(LogRecordFunc, &dlg); int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
2)调试跟踪到了HKVisionDlg.cpp中函数BOOL CHKVisionDlg::OnInitDialog()中语句:
if (!MP4_ServerStart(&videoinfo))
{
MessageBox("error","error",MB_OK);
}
具体位置在459行。
3)最终错误定位在函数:
int __cdecl StreamDirectReadCallback(ULONG channelNum,void *DataBuf,DWORD Length,int frameType,void *context)
该函数中的:
CHKVisionDlg *pMain = (CHKVisionDlg *)AfxGetMainWnd();
pMain->GetDlgItem(IDC_BPS)->SetWindowText((LPCTSTR)str);
错误分析:
MP4_ServerStart时候,调用回调函数StreamDirectReadCallback函数,估计(源码未公开)是专门开了一个线程调用StreamDirectReadCallback函数。在StreamDirectReadCallback函数中使用了AfxGetMainWnd()。而AfxGetMainWnd函数返回null,可以google “AfxGetMainWnd null” "AfxGetMainWnd 失效"。http://topic.csdn.net/u/20100430/10/1FF4D768-E1A3-4B4D-8F77-0EFB2A3DFD08.html
解决方法:
将pMain作为全局的CHKVisionDlg*指针,初始化为NULL,在CHKVisionDlg::OnInitDialog 中,函数结尾处添加:pMain = this;
最后再StreamDirectReadCallback中可以直接使用pMain了。。。
后记
错误定位最为痛苦。步骤1,到步骤2,再到步骤3的跟踪很需要想象力,直接F11根本跟不过去,一个下午才解决。所以写出来~,跟大家分享~相关文章推荐
- 海康威视DS-4100、4000HC 系列板卡SDK编程指南
- Android错误之--Platform MNC is a preview and requires application manifest to set minSdkVersion to 'MNC
- 微软BI 之SSIS 系列 - ETL 转换时关于 Code Page (1252 and 936) 转换错误的原因和解决方法
- xcode 4.6 install older version iphone sdk and iphone simulator
- Android之 compileSdkVersion, minSdkVersion, and targetSdkVersion
- Android App支付系列(二):支付宝SDK接入详细指南(附官方支付demo)
- On SDK version 23 and up, your app data will be automatically backed up and restored on app install.
- This Android SDK requires And...e ADT to the latest version.
- 关于解决vs215c++出现的错误 the windows sdk version for 8.1 was not found
- 更新android sdk后提示This Android SDK requires And...e ADT to the latest version.
- 更新android sdk后提示This Android SDK requires And...e ADT to the latest version.
- 安卓安装提示:Android SDK requires Android Developer Toolkit version 21.1.0 or above. (错误解决方法)
- IBM FASTT StorageManager的使用(DS4000系列存储管理软件)
- Android studio导入Vitamio类库报ANDROID_BUILD_SDK_VERSION' for project ':vitamio' 错误
- 4000 ubuntu caffe ssd 服务器上运行自带demo 错误:import error no module named caffe
- 打开eclipse的opens the android sdk and avd manager提示错误:error:location of the android sdk has not been
- 支付宝sdkdemo报错 15个错误,别着急 -.-支持真机调试
- Android App支付系列(二):支付宝SDK接入详细指南(附官方支付demo)
- Your version of the Windows SDK is earlier than 6.0 Try setting the 'WINVER' and '_WIN32_WINNT' defi
- This Android SDK requires Android Developer Toolkit version 20.0.0 or above错误问题解决