Print Page | Close Window

DockingPane wincore assertion

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=12809
Printed Date: 23 November 2024 at 9:15am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: DockingPane wincore assertion
Posted By: Paolo
Subject: DockingPane wincore assertion
Date Posted: 27 November 2008 at 8:19am
I Created a Dialog and attached it to a DockingPane.
When I show that pane I get a false assertion in wincore.cpp. This happens in debug version.
When I show that pane in the release version my application crashes.

I have no idea of what could be wrong, looking at methods name I feel that is something related to parent pointer, but it's just a feeling.

Here's my call stack:

- mfc90d.dll!CWnd::AssertValid()  Row 900 + 0x19 byte    C++
- mfc90d.dll!AfxAssertValidObject(const CObject * pOb=0x0859fe40, const char * lpszFileName=0x643dd0cc, int nLine=399)  Row 107    C++
- mfc90d.dll!CCmdTarget::GetIDispatch(int bAddRef=1)  Row 400    C++
- ToolkitPro1200vc90D.dll!CXTPDockingPane::GetAccessibleParent(IDispatch * * ppdispParent=0x0c008b58)  Row 408 + 0x3d byte    C++
- ToolkitPro1200vc90D.dll!CXTPAccessible::XAccessible::get_accParent(IDispatch * * ppdispParent=0x0c008b58)  Row 621 + 0x13 byte    C++

and here I copied these methods code (call stack line of each method is highlighted by "// this is the row")


void CWnd::AssertValid() const
{
    if (m_hWnd == NULL)
        return;     // null (unattached) windows are valid

    // check for special wnd??? values
    ASSERT(HWND_TOP == NULL);       // same as desktop
    if (m_hWnd == HWND_BOTTOM)
        ASSERT(this == &CWnd::wndBottom);
    else if (m_hWnd == HWND_TOPMOST)
        ASSERT(this == &CWnd::wndTopMost);
    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);     // this is the row

        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

        // Note: if either of the above asserts fire and you are
        // writing a multithreaded application, it is likely that
        // you have passed a C++ object from one thread to another
        // and have used that object in a way that was not intended.
        // (only simple inline wrapper functions should be used)
        //
        // In general, CWnd objects should be passed by HWND from
        // one thread to another.  The receiving thread can wrap
        // the HWND with a CWnd object by using CWnd::FromHandle.
        //
        // It is dangerous to pass C++ objects from one thread to
        // another, unless the objects are designed to be used in
        // such a manner.
    }
}

void AFXAPI AfxAssertValidObject(const CObject* pOb,
    LPCSTR lpszFileName, int nLine)
{
    if (pOb == NULL)
    {
        TRACE(traceAppMsg, 0, "ASSERT_VALID fails with NULL pointer.\n");
        if (AfxAssertFailedLine(lpszFileName, nLine))
            AfxDebugBreak();
        return;     // quick escape
    }
    if (!AfxIsValidAddress(pOb, sizeof(CObject)))
    {
        TRACE(traceAppMsg, 0, "ASSERT_VALID fails with illegal pointer.\n");
        if (AfxAssertFailedLine(lpszFileName, nLine))
            AfxDebugBreak();
        return;     // quick escape
    }

    // check to make sure the VTable pointer is valid
    ASSERT(sizeof(CObject) == sizeof(void*));
    if (!AfxIsValidAddress(*(void**)pOb, sizeof(void*), FALSE))
    {
        TRACE(traceAppMsg, 0, "ASSERT_VALID fails with illegal vtable pointer.\n");
        if (AfxAssertFailedLine(lpszFileName, nLine))
            AfxDebugBreak();
        return;     // quick escape
    }

    if (!AfxIsValidAddress(pOb, pOb->GetRuntimeClass()->m_nObjectSize, FALSE))
    {
        TRACE(traceAppMsg, 0, "ASSERT_VALID fails with illegal pointer.\n");
        if (AfxAssertFailedLine(lpszFileName, nLine))
            AfxDebugBreak();
        return;     // quick escape
    }
    pOb->AssertValid();     // this is the row
}

// return addref'd IDispatch part of CCmdTarget object
LPDISPATCH CCmdTarget::GetIDispatch(BOOL bAddRef)
{
    ASSERT_VALID(this);
    ASSERT(m_xDispatch.m_vtbl != 0);    // forgot to call EnableAutomation?   // this is the row

    // AddRef the object if requested
    if (bAddRef)
        ExternalAddRef();

    // return pointer to IDispatch implementation
    return (LPDISPATCH)GetInterface(&IID_IDispatch);
}

HRESULT CXTPDockingPane::GetAccessibleParent(IDispatch* FAR* ppdispParent)
{
    SAFE_MANAGE_STATE(m_pModuleState);

    *ppdispParent = NULL;

    if (m_pParentContainer)
    {
        *ppdispParent = ((CXTPDockingPaneTabbedContainer*)m_pParentContainer)->GetIDispatch(TRUE);    // this is the row
        return S_OK;
    }
    return E_FAIL;
}

STDMETHODIMP CXTPAccessible::XAccessible::get_accParent(IDispatch* FAR* ppdispParent)
{
    TRACE_ACCESSIBLE(_T("get_accParent\n"));
    METHOD_PROLOGUE_EX_(CXTPAccessible, ExternalAccessible);

    return pThis->GetAccessibleParent(ppdispParent);    // this is the row
}



Replies:
Posted By: Oleg
Date Posted: 27 November 2008 at 2:26pm
Hi,
 
Do you see it with some our sample ? ActivePaneView also has attached dialog - please check it.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Paolo
Date Posted: 02 December 2008 at 6:27am
I checked ActivePaneView sample as you suggested. There's code to create a pane and to attach a dialog to it. But I can't find any way to show that pane.
In my application the debug assertion is displayed only after I've shown the pane attached to the dialog.

Methods
- CWnd::AssertValid
- AfxAssertValidObject
- CCmdTarget::GetIDispatch

are called on a "CXTPDockingPaneTabbedContainer" instance.

As a note: in CCmdTarget::GetIDispatch the failing instruction is
ASSERT_VALID(this);
(in my previous post I pointed a row below)


Posted By: Oleg
Date Posted: 05 December 2008 at 3:43am

Hi,

Create demo project, reproduce problem and attach here. With this stack I have no idea what actually you do.
Or better just follow our samples.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net