对对话框里的列表框鼠标双击操作出现的问题,File:cmdtarg.cpp Line:52
软件以前运行都是正常的,但是昨天加了一段代码,运行都正常,但是软件一旦结束,退出后就会弹出如下的对话框:
Debug Assertion Failed!
Program:D:\MFC\Debug\newlist.exe
File:cmdtarg.cpp
Line:52
For information on how your program can cause an assertion
failure,see the Visual C++ documentation on asserts
(Press Retry to debug the application)
cmdtarg.cpp 中52行代码为:
CCmdTarget::~CCmdTarget()
{
#ifndef _AFX_NO_OLE_SUPPORT
if (m_xDispatch.m_vtbl != 0)
((COleDispatchImpl*)&m_xDispatch)->Disconnect();
ASSERT(m_dwRef <= 1);
#endif
#ifdef _AFXDLL
m_pModuleState = NULL;
#endif
}
52行是这样的,ASSERT(m_dwRef <= 1);用release版本后没问题.
添加的代码是对对话框里的列表框鼠标双击操作,
void CNewlistDlg::OnDblclkListdir(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION pos = m_ListCtrl.GetFirstSelectedItemPosition();
m_nIndex = m_ListCtrl.GetNextSelectedItem(pos); // 得到项目索引
m_ComString = m_ListCtrl.GetItemText(m_nIndex,0);
char str[256]; //= _T("");
memset(str,0,256);
sprintf( str,"%s%s",m_cCurrentFullDir,m_ComString);
SetDlgItemText(IDC_COMBO1, str);
*pResult = 0;
}
其中,private:
CStringm_ComString;
char m_cCurrentFullDir[256];
是在对话框类中声明的私有变量
跟踪进去后弹出一个对话框,提示“user breakpoint called from code at 0x5f4373c9”
点确定后光标停在0x5f4373c9这行,
有一句: int 3
5F4373A7 mov edx,dword ptr [ebp-10h]
5F4373AA mov eax,dword ptr [edx+10h]
5F4373AD call dword ptr [eax+1Ch]
5F4373B0 mov ecx,dword ptr [ebp-10h]
5F4373B3 cmp dword ptr [ecx+4],1
5F4373B7 jle 5F4373CA
5F4373B9 push 34h
5F4373BB push 5F4CD6E8h
5F4373C0 call 5F476AF0
5F4373C0 call 5F476AF0
5F4373C5 test eax,eax
5F4373C7 je 5F4373CA
5F4373C9 int 3 //调试时停在的位置
5F4373CA xor edx,edx
5F4373CC test edx,edx
5F4373CE jne 5F4373B0
5F4373D0 mov eax,dword ptr [ebp-10h]
5F4373D3 mov dword ptr [eax+1Ch],0
5F4373DA mov dword ptr [ebp-4],0FFFFFFFFh
5F4373E1 mov ecx,dword ptr [ebp-10h]
5F4373E4 call 5F476B57
按f10后运行,到后面发现很多 int 3的地方,不过程序不跑那
--- No source file -----
0040147F int 3
00401480 int 3
00401481 int 3
00401482 int 3
00401483 int 3
00401484 int 3
00401485 int 3
00401486 int 3
麻烦高人指点啊。。。
[解决办法]
断言出错检查m_dwRef相关操作
[解决办法]
好像是COM对象释放的问题,程序是做什么的?
[解决办法]
你这个sprintf会不会越界啊,要检查一下。
[解决办法]