Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - DockingPane wincore assertion
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DockingPane wincore assertion

 Post Reply Post Reply
Author
Message
Paolo View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paolo Quote  Post ReplyReply Direct Link To This Post Topic: DockingPane wincore assertion
    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
}
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Paolo View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paolo Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.233 seconds.