Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Problem with dynamic bars. Collapse All
Subject Author Date
Darlene Gariepy Apr 11, 2012 - 1:50 PM

We’ve found what looks like a bug.  It can be reproduced with the following steps using your MDI_DynamicBars sample.



1. Launch the sample.  We used Unicode DEBUG.

2. Remove all control bars from the document tab.  The only thing that should be left in the document area is MDIDOC1.

3. Move the "Persistent Bar" to the document area (i.e. Select "Tabbed Document" from the bar’s menu).

4. Save the layout (i.e. *** Bar State Persistence *** -> Save resizable bar to file).

5. Repeat step 4.



In step 5, after the second attempt to save, a failed assertion will trigger in ExtControlBar.cpp, line 28285:  ASSERT( m_listBarsInDocMode.Find( pBar ) != NULL );


We are using version 2.9.2.

Technical Support Apr 23, 2012 - 9:04 AM

Thank you for additional information. To fix this issue, please update the source code for the following method:

bool CExtDynamicBarSite::StateSerialize(
    CArchive & ar,
    bool bEnableThrowExceptions // = false
    )
{
    ASSERT( this != NULL );
DWORD dwGeneralFlags = 0;
DWORD dwReserved = 0L;
    try
    {
        if( ar.IsStoring() )
        {
            ar << dwGeneralFlags;
            ar << dwReserved;
            ar << dwReserved;
            ar << dwReserved;
            ar << dwReserved;
            DWORD dwCount = (DWORD)BarEnumGetCount();
            ar << dwCount;
            POSITION pos;
            for( pos = BarEnumGetStartPosition(); pos != NULL; )
            { // delayed rebuild of visible documents list after reloading
                CExtDynamicControlBar * pBar = BarEnumGetNext( pos );
                ASSERT_VALID( pBar );
                POSITION posInListBarsInDocMode = m_listBarsInDocMode.Find( pBar );
                bool bVisibleState = false;
                if( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT )
                {
                    if( bVisibleState )
                    {
                        if( posInListBarsInDocMode == NULL )
                            m_listBarsInDocMode.AddTail( pBar );
                        continue;
                    } // if( bVisibleState )
                } // if( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT )
                if( posInListBarsInDocMode != NULL )
                    m_listBarsInDocMode.RemoveAt( posInListBarsInDocMode );
            } // delayed rebuild of visible documents list after reloading
            for( pos = BarEnumGetStartPosition(); pos != NULL; )
            { // serialize per-bar dynamic properties
                CExtDynamicControlBar * pBar = BarEnumGetNext( pos );
                ASSERT_VALID( pBar );
                bool bVisibleState = false;
                if( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT )
                {
                    if( bVisibleState )
                    {
                        ASSERT( m_listBarsInDocMode.Find( pBar ) != NULL );
                        continue;
                    } // if( bVisibleState )
                } // if( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT )
                ASSERT( m_listBarsInDocMode.Find( pBar ) == NULL );
                UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
                ar << DWORD(nCmdID);
                bool bPersistentBar = pBar->IsPersistentBar(); 
                DWORD dwSerializeFlags = 0;
                if( bPersistentBar )
                    dwSerializeFlags |= 0x01;
                ar << dwSerializeFlags;
                if( ! bPersistentBar )
                {
                    CRuntimeClass * pRTC = pBar->GetRuntimeClass();
                    ASSERT( pRTC != NULL );
                    ar.WriteClass( pRTC );
                } // if( ! bPersistentBar )
                ar << pBar->m_strCaptionText;
                pBar->m_icon.Serialize( ar );
                pBar->OnSerializeDynamicProps( ar );
            } // serialize per-bar dynamic properties
            CTypedPtrList < CPtrList, CExtDynamicControlBar * > _listSerialize;
            bool bUseDefaultOrder = true;
            CExtDynamicBarSite::eDetectedUiType_t eDUIT    = GetDetectedUiType();
            eDUIT;
#if (!defined __EXT_MFC_NO_TABMDI_CTRL)
            if( eDUIT == __EDUIT_MDI_WITH_TABS )
            { // detect MDI order using tabs
                CExtTabWnd * pTabs = GetMdiTabs();
                if( pTabs != NULL )
                {
                    LONG nIndex, nCount = pTabs->ItemGetCount();
                    for( nIndex = 0L; nIndex < nCount; nIndex ++ )
                    {
                        HWND hWnd = (HWND)pTabs->ItemGet( nIndex )->LParamGet();
                        CWnd * pWndPremanent = CWnd::FromHandlePermanent( hWnd );
                        if( pWndPremanent == NULL )
                            continue;
                        CExtDynamicMDIChildWnd * pWndMdiChild = DYNAMIC_DOWNCAST( CExtDynamicMDIChildWnd, pWndPremanent );
                        if( pWndMdiChild == NULL )
                            continue;
                        if( pWndMdiChild->GetBarSite() != this )
                            continue;
                        CExtDynamicControlBar * pBar = pWndMdiChild->GetBar();
                        if( pBar == NULL )
                            continue;
                        if( m_listBarsInDocMode.Find( pBar ) == NULL )
                            continue;
                        _listSerialize.AddTail( pBar );
                    } // for( nIndex = 0L; nIndex < nCount; nIndex ++ )
                    if( _listSerialize.GetCount() == m_listBarsInDocMode.GetCount() )
                        bUseDefaultOrder = false;
                    else
                        _listSerialize.RemoveAll();
                } // if( pTabs != NULL )
            } // detect MDI order using tabs
#endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
#if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
            if( eDUIT == __EDUIT_SDI_TAB_PAGE_CONTAINER )
            { // detect document mode order using SDI tab page container
                CExtTabPageContainerWnd * pWndTabPageContainer = GetTabPageContainer();
                if( pWndTabPageContainer->GetSafeHwnd() != NULL )
                {
                    ASSERT_VALID( pWndTabPageContainer );
                    CTypedPtrList < CPtrList, CExtDynamicControlBar * >  _listFound;
                    INT nIndex = 0, nCount = pWndTabPageContainer->PageGetCount();
                    for( nIndex = 0; nIndex < nCount; nIndex ++ )
                    {
                        HWND hWndPage = pWndTabPageContainer->PageHwndGetSafe( nIndex );
                        if( hWndPage == NULL )
                            continue;
                        CExtDynamicControlBar * pBar = BarFindByChildHWND( hWndPage );
                        if( pBar == NULL )
                            continue;
                        ASSERT_VALID( pBar );
#ifdef _DEBUG
                        bool bVisibleState = false;
                        ASSERT( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT );
                        ASSERT( bVisibleState );
#endif // _DEBUG
                        if( m_listBarsInDocMode.Find( pBar ) == NULL )
                            continue;
                        _listSerialize.AddTail( pBar );
                    }
                    if( _listSerialize.GetCount() == m_listBarsInDocMode.GetCount() )
                        bUseDefaultOrder = false;
                    else
                        _listSerialize.RemoveAll();
                }
            } // detect document mode order using SDI tab page container
#endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
            if( bUseDefaultOrder )
                _listSerialize.AddTail( &m_listBarsInDocMode );
            for( pos = _listSerialize.GetTailPosition(); pos != NULL; )
            { // serialize per-bar dynamic properties
                CExtDynamicControlBar * pBar = _listSerialize.GetPrev( pos );
                ASSERT_VALID( pBar );
                ASSERT( pBar->BarStateGet() == CExtDynamicControlBar::__EDBS_DOCUMENT );
                UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
                ar << DWORD(nCmdID);
                bool bPersistentBar = pBar->IsPersistentBar(); 
                DWORD dwSerializeFlags = 0;
                if( bPersistentBar )
                    dwSerializeFlags |= 0x01;
                ar << dwSerializeFlags;
                if( ! bPersistentBar )
                {
                    CRuntimeClass * pRTC = pBar->GetRuntimeClass();
                    ASSERT( pRTC != NULL );
                    ar.WriteClass( pRTC );
                } // if( ! bPersistentBar )
                ar << pBar->m_strCaptionText;
                pBar->m_icon.Serialize( ar );
                pBar->OnSerializeDynamicProps( ar );
            } // serialize per-bar dynamic properties
        } // if( ar.IsStoring() )
        else
        {
            ar >> dwGeneralFlags;
            ar >> dwReserved;
            ar >> dwReserved;
            ar >> dwReserved;
            ar >> dwReserved;
            BarFreeAll( false, true );
            m_listBarsInDocMode.RemoveAll();
            ASSERT( BarEnumGetCount( false, true ) == 0 );
            DWORD dwCount;
            ar >> dwCount;
            for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++ )
            {
                UINT nCmdID;
                DWORD dwTmp;
                ar >> dwTmp;
                nCmdID = UINT(dwTmp);
                DWORD dwSerializeFlags;
                ar >> dwSerializeFlags;
                CExtDynamicControlBar * pBar = NULL;
                if( (dwSerializeFlags & 0x01) != 0 )
                { // if serializing persistent bar
                    pBar = BarGetByCmdID( nCmdID );
                    if( pBar == NULL )
                    {
                        ASSERT( FALSE );
                        BarFreeAll( false, true );
#if _MFC_VER >= 0x0800
                        ::AfxThrowArchiveException( CArchiveException::genericException );
#else
                        ::AfxThrowArchiveException( CArchiveException::generic );
#endif
                    } // if( pBar == NULL )
                    ASSERT_VALID( pBar );
                    ar >> pBar->m_strCaptionText;
                    pBar->m_icon.Serialize( ar );
                } // if serializing persistent bar
                else
                { // if serializing dynamic bar
                    CRuntimeClass * pRTC = ar.ReadClass();
                    ASSERT( pRTC != NULL );
                    CExtSafeString strCaptionText;
                    ar >> strCaptionText;
                    CExtCmdIcon icon;
                    icon.Serialize( ar );
                    pBar =
                        BarAlloc(
                            strCaptionText,
                            icon,
                            nCmdID,
                            pRTC
                            );
                    if( pBar == NULL )
                    {
                        ASSERT( FALSE );
                        BarFreeAll( false, true );
#if _MFC_VER >= 0x0800
                        ::AfxThrowArchiveException( CArchiveException::genericException );
#else
                        ::AfxThrowArchiveException( CArchiveException::generic );
#endif
                    } // if( pBar == NULL )
                } // if serializing dynamic bar
                ASSERT_VALID( pBar );
                pBar->OnSerializeDynamicProps( ar );
            } // for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++ )
            ASSERT( ((DWORD)BarEnumGetCount()) == dwCount );
        } // else from if( ar.IsStoring() )
        return true;
    } // try
    catch( CException * pException )
    {
        if( bEnableThrowExceptions )
            throw;
        pException->Delete();
    } // catch( CException * pException )
    catch( ... )
    {
        if( bEnableThrowExceptions )
            throw;
    } // catch( ... )
dwGeneralFlags;
dwReserved;
    return false;
}

Darlene Gariepy Apr 17, 2012 - 8:18 AM

Try these alternate steps:



1. Delete the registry state (e.g. HKEY_CURRENT_USER\Software\Foss\MDI_DynamicBars).

2. Launch the app in debug.

3. Remove "Auto-Hide" from "Persistant Bar" (i.e. click on Pin button in bar title).

4. Right-click "Persistant Bar" title bar and choose "Tabbed Document".

5. Save the layout (i.e. *** Bar State Persistence *** -> Save resizable bar to file).

6. Load the layout from step 5.

7. Close the application.

Technical Support Apr 17, 2012 - 4:37 AM

We cannot reproduce this issue. We assume step 2 is hiding bars or switching bars into docked state. Could you send us the state file you saved during your test?