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 » Possible bug in CExtPageNavigatorWnd? Collapse All
Subject Author Date
Krustys Donuts Jul 6, 2005 - 8:20 AM

Hi, when we upgraded from 2.30 to 2.33 (and 2.40 as well), our application started to crash immediately when adding items to our CExtPageNavigatorWnd object. I attempted to debug the problem (uh oh), and found something that didn’t make sense to me:

    LONG nCount = ItemGetCount();
    if( nIndex < 0 || nIndex > nCount )
        nIndex = nCount;
    PAGE_ITEM_INFO * pPII = new PAGE_ITEM_INFO( sText, hIconExpanded, hIconCollapsed,
                                                                              dwData, this);
    ASSERT_VALID( pPII );
    nIndex++;
    m_arrItems.InsertAt( nIndex, pPII );

As CArrays are 0-based, why is it that nIndex is incremented before the call to InsertAt()? If I change the code to increment nIndex after the call to InsertAt(), everything *seems* to operate normally. Well, at least the application doesn’t crash.

Any info would be really appreciated! Thank you!

Technical Support Jul 7, 2005 - 2:19 AM

The first (zero) element in the m_arrItems array is always associated with the Configure Buttons item, so we need to increment nIndex before inserting user items. Anyway InsertAt will be valid even if the nIndex is greater than the array size. When you add a new element at a position beyond the end of the array, the array just grows to this new size and nIndex will always be valid.

We fixed a bug in v.2.33 with icorrect insert/delete operations at run time. May be this somehow relates to your problem. Please provide us with more details about the problem (like call stack, source code in which you create and initialize the page navigator, and etc.).

Krustys Donuts Jul 7, 2005 - 8:18 AM

Thanks for the reply. I knew that a "bug find" like that was too good to be true. :)

So anyhow, our project crashes when our page navigator gets created:

int CTasksAvailablePageNavigator::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CExtPageNavigatorWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    HICON h_icon1 = 0;
    HICON h_icon2 = 0;
    CExtPageNavigatorWnd::PAGE_ITEM_INFO *p_pii = NULL;

    h_icon1 = ( HICON)::LoadImage( global_GUI_Framework_Instance, MAKEINTRESOURCE(     IDI_PLATE_HANDLING), IMAGE_ICON, 24, 24, 0 );
    h_icon2 = ( HICON)::LoadImage( global_GUI_Framework_Instance, MAKEINTRESOURCE( IDI_PLATE_HANDLING), IMAGE_ICON, 16, 16, 0 );
    // "pages" is a vector<CExtPageNavigatorWnd::PAGE_ITEM_INFO*>
    // code crashes when ItemInsert gets called
    pages.push_back( p_pii = ItemInsert( -1, _T( "Pane #1"), h_icon1, h_icon2));
    ...
}


This is what the call stack looks like:
ProfUIS240md.dll!CExtPageNavigatorWnd::AssertValid()  Line 923 + 0x19	C++
mfc71d.dll!AfxAssertValidObject(const CObject * pOb=0x00abda00, const char * lpszFileName=0x1057d398, int nLine=442)  Line 104	C++
ProfUIS240md.dll!CExtPageNavigatorWnd::ItemGetCount()  Line 443	C++
ProfUIS240md.dll!CExtPageNavigatorWnd::ItemInsert(long nIndex=1, const char * sText=0x005adc90, HICON__ * hIconExpanded=0x000404e3, HICON__ * hIconCollapsed=0x02b104f7, unsigned long dwData=0, bool bUpdate=false)  Line 2198 + 0x8	C++
krustysdonuts.dll!CMyPageNavigator::OnCreate(tagCREATESTRUCTA * lpCreateStruct=0x0012dc20)  Line 42 + 0x1e	C++


Hopefully, this info helps! Thank you.

Krustys Donuts Jul 7, 2005 - 8:19 AM

by the way, I had renamed our class in the call stack, but not in the code... sorry if that confuses anything.

Technical Support Jul 7, 2005 - 9:51 AM

Thank you for the code snippet. We found out what the problem was. You initialized page navigator items in the OnCreate method of a class derived from CExtPageNavigatorWnd. This method in your derived class is called before we make some important operations, so you encountered the error. We fixed this problem and sent an update to you. Just replace old files with new ones and recompile the library.