MFC SetTitle() causing weird debug assertion

2019-09-01 10:15发布

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.

0条回答
登录 后发表回答