选择“关闭所有其他"时断言错误.在上下文菜单中 [英] Assertion Error during select of "Close all Other" in context menu

查看:104
本文介绍了选择“关闭所有其他"时断言错误.在上下文菜单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

在MFC应用程序中实现关闭所有其他用户"的更新时,我遇到断言错误,其中,选项卡文档界面(TDI)具有许多选项卡,类似于VS 2008 IDE,并且当用户右键单击上下文菜单时<< ; Close All Other>> ,它具有以下处理程序,

以下代码将关闭除第一个" MDI客户端选项卡组中的活动选项卡之外的所有选项..

Dear All,

I am getting assertion error, on implementing the updates for "Close All Others" in MFC Application,, wherein, Tab Document Interface(TDI) has numerous tabs, similar to VS 2008 IDE, and when user right clicks the context menu <<Close All Other>> , which has the following handler ,

The following code will close all except the active tab in the "first" MDI client tab group..

//Mainframe.cpp

Begin_message_map

..............

ON_COMMAND(ID_TAB_CLOSEOTHER, &CMainFrame::OnTabCloseOther)

............

CMainFrame::OnCloseOtherTab()

{

Line 1. const CObList* tabList = &m_wndClientArea.GetMDITabGroups(); 
Line 2: CMFCTabCtrl* pTabWnd = (CMFCTabCtrl*)tabList->GetHead(); 
Line 3. if (pTabWnd != NULL) 
Line 4: { 
Line 5: int iActiveTab = pTabWnd->GetActiveTab();
Line 6: ASSERT_VALID(pTabWnd);
Line 7: for (int i = pTabWnd->GetTabsNum() - 1; i >= 0; i--)
Line 8: {
Line 9: CMDIChildWndEx* pNextWnd = DYNAMIC_DOWNCAST CMDIChildWndEx........................ }
//MainFrame.h 

CMDIChientAreaWnd m_wndClientArea; 




该断言在第2行的执行中显示.下一行在断言中显示




The assertion is displayed on execution of Line 2. The following line gets displayed on assertion

return AfxWinMain(hInstance, hPrevInstance, lpCmdLine,nCmdShow);


<<<< 0x787d01ec(mfc90d.dll)的未处理异常
在CART.exe中:0xC0000005:访问冲突读取位置x00000008.
请让我知道如何纠正上述解决方案.

带着问候,


<<<<Unhandled exception at 0x787d01ec (mfc90d.dll)
in CART.exe: 0xC0000005: Access violation reading location x00000008.>>>>

Please let me know how to correct the above solution.

With Regards,

推荐答案

CObList :: GetHead()的文档说该列表不能为空,并且会失败.

在获取head元素之前,您当前尚未检查列表的大小.尝试先调用IsEmpty()以确定访问head元素是否会出错.

可能值得逐步检查代码以检查tabList指针在对GetMDITabGroups的调用中是否有效
The documentation for CObList::GetHead() says that the list cannot be empty and would fail.

You are not currently checking the size of the list before getting the head element. Try calling IsEmpty() first to determine whether accessing the head element would be an error.

It may be worth stepping through the code to check the the tabList pointer is valid from the call to GetMDITabGroups


AfxWinMain()是MFC应用程序的入口点,确定吗?在启动过程中不会不小心调用此方法吗?您可能与ID_TAB_CLOSEOTHER发生冲突,或者是在启动时但未初始化成员之前直接调用了某些内容.
AfxWinMain() is the entry point of an MFC application, are you sure you''re not accidentally calling this method during startup? You may have a conflict with ID_TAB_CLOSEOTHER or something is calling that directly upon startup but before the members are initialized.


这篇关于选择“关闭所有其他"时断言错误.在上下文菜单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆