MFC SetTitle() causing weird debug assertion

别来无恙 提交于 2019-12-25 05:36:05

问题


Whenever I call SetTitle() in my MFC application, I get a debug assertion failed. But I haven't set to assert anything; in truth I'm not really sure how to explain what's going on.

I actually get three debug assertions that loop round continuously about a dozen times before the application continues. If I keep clicking "Ignore" then after about 20 clicks the boxes go away and the applciation continues running as normal.

The first two assertions are thrown from wincore.cpp lines 952 and 954. The area of code is:

else if (m_hWnd == HWND_NOTOPMOST)
    ASSERT(this == &CWnd::wndNoTopMost);
else
{
    // should be a normal window
    ASSERT(::IsWindow(m_hWnd));

    // should also be in the permanent or temporary handle map
    CHandleMap* pMap = afxMapHWND();
    ASSERT(pMap != NULL);

    CObject* p=NULL;
    if(pMap)
    {
        ASSERT( (p = pMap->LookupPermanent(m_hWnd)) != NULL ||
                (p = pMap->LookupTemporary(m_hWnd)) != NULL);
    }
    ASSERT((CWnd*)p == this);   // must be us

The third assertion is thrown from dbgrptt.c, line 85. The offending code snippet is:

_CRTIMP void _cdecl _CrtDbgBreak(
    void
    )
{
    __debugbreak();
}

(it's breaking at the __debugbreak() function).

I am not really sure where to start with this. My call stack is visible here: http://s18.postimg.org/lhoz1rwqh/callstack.png

Thanks in advance.

来源:https://stackoverflow.com/questions/30757006/mfc-settitle-causing-weird-debug-assertion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!