FIX: Assert in Appui1.cpp Line 215 in MFC SDI/MDI application (193102)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q193102 SYMPTOMS
When you try to display a modal window without explicitly specifying a
parent in a command handler of an MFC SDI/MDI application, where the frame
window is destroyed in the command handler before displaying the modal
window, you might get an assertion in CCmdTarget::GetRoutingFrame_()
(Appui1.cpp line: 215) with debug builds.
In the release builds of the application, modal windows may behave similar
to modeless windows. This will also be the case if you update an MFC
application from Visual C++ 5.0 to Visual C++ 6.0 (both versions of Visual C++ use the MFC DLL
named MFC42.dll).
CAUSE
Modal windows now use the routing frame data member (m_pRoutingFrame) of
the thread state to decide on the owner in GetSafeOwner(). The problem is
that the CFrameWnd set as the thread state's current routing frame
is deleted, but the thread state is not updated to reflect that fact.
RESOLUTION
Set the thread state's current routing frame to NULL in the destructor of
your CFrameWnd derived class that is being destroyed:
CMyFrameWnd::~CMyFrameWnd()
{
if( AfxGetThreadState()->m_pRoutingFrame == this )
{
AfxGetThreadState()->m_pRoutingFrame = NULL;
}
}
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug has been fixed in the Visual
Studio 6.0 Service Pack 1.
To obtain this service pack, please see:
REFERENCES
For more information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:
194022
Visual Studio 6.0 service packs, what, where, why
194295 How to tell that a Visual Studio service pack is installed
193009 INFO: Visual Studio 6.0 Service Pack 1 Readme
Modification Type: | Major | Last Reviewed: | 4/20/2006 |
---|
Keywords: | kbQFE kbBug kbDocView kbfix kbVC600SP1Fix kbVS600SP1fix kbVS600sp2fix KB193102 kbAudDeveloper kbAudITPRO |
---|
|