Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Crash in CXTPPaintManager::DrawControl()
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Crash in CXTPPaintManager::DrawControl()

 Post Reply Post Reply
Author
Message
jasonaross View Drop Down
Newbie
Newbie
Avatar

Joined: 24 August 2009
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote jasonaross Quote  Post ReplyReply Direct Link To This Post Topic: Crash in CXTPPaintManager::DrawControl()
    Posted: 24 August 2009 at 2:45pm

My application crashes when dereferencing a null pointer within DrawControl. Any ideas on whether this is a codejock issue or something i can prevent? My application has framework that can load different dlls/components dependent on the user action. As different components are loaded, we remove controls in the CXTPMenu bar and add some back.

CXTPPaintManager::DrawControl(CDC* pDC, CXTPControl* pButton, BOOL bDraw)

return (pButton->GetParent()->GetType() == xtpBarTypePopup)? //crashes when getting the type for the parent of the button

DrawControlPopupParent(pDC, pButton, bDraw): DrawControlToolBarParent(pDC, pButton, bDraw);

Rewritten..

CXTPCommandBar* pjCXTPCommandBar = pButton->GetParent();

XTPBarType aXTPBarType = pjCXTPCommandBar->GetType(); //crashes here as pjCXTPCommandBar is NULL

return (aXTPBarType == xtpBarTypePopup)?

DrawControlPopupParent(pDC, pButton, bDraw): DrawControlToolBarParent(pDC, pButton, bDraw);

CXTPControl::Draw(

CXTPCommandBar::DrawCommandBar(

CXTPCommandBar::OnPaint()

CXTPCommandBar::OnWndMsg(

CXTPCommandBar::DrawCommandBar(

CXTPCommandBar::OnPaint()

CXTPCommandBar::OnWndMsg(

CWnd::UpdateWindow()

CXTPPopupBar::SetTrackingMode(int 0, int 1, int 0)

CXTPCommandBar::OnDestroy()

CXTPCommandBar::OnWndMsg(

CXTPHookManager::HookWndProc(

CXTPCommandBar::OnFinalRelease()

CXTPControlPopup::~CXTPControlPopup()

CXTPControlPopup::`vector deleting destructor'(

CXTPControls::RemoveAll()

CEnhancedMenuController::AddComponentMenu //from my app

It seems the CXTPControl objects' parent is set to null within CXTPControls::RemoveAll().

void CXTPControls::RemoveAll(void)

{

for (int nIndex = 0; nIndex < GetCount(); nIndex++)

{

CXTPControl* pControl = m_arrControls.GetAt(nIndex);

pControl->m_pControls = NULL;

//pControl->m_pParent = NULL; commenting out this line prevents the crash

pControl->InternalRelease();

}

m_arrControls.RemoveAll();

}

------------------

void CEnhancedMenuController::AddComponentMenu(long hMenu)
{
componentCommandIds.RemoveAll();
CString menuString;
try
{
CPVFrame* ownerFrame = dynamic_cast<CPVFrame*> (m_ownerWnd);
if (ownerFrame == NULL)
{
MsgWriteF (MSG_DEFAULT, eMsgLog_Commit, _T("PVAPP"), eMsgLvl_Info, _T("CEnhancedMenuController::AddComponentMenu cast of m_ownerWnd to PVFrame* returned NULL"));
return;
}
CXTPCommandBars *pCommandBars = ownerFrame->GetCommandBars();

//The codejock menu bar
CXTPMenuBar* pMenuBar = static_cast<CXTPMenuBar*> (pCommandBars->GetMenuBar());
//CMenu we build first
CMenu* pMenu = NULL;
if (m_hFrameworkMenu == NULL)
{
pMenu = new CMenu();
pMenu->CreateMenu();
m_hFrameworkMenu = pMenu->m_hMenu;
}
else
{
pMenu = CMenu::FromHandle(m_hFrameworkMenu);
for (int i = pMenu->GetMenuItemCount() - 1; i >= 0; i--)
{
pMenu->RemoveMenu(i, MF_BYPOSITION);
}
}

//remove anything currently in the array
CleanUpMenuArray();

CXTPControls* curControls = pMenuBar->GetControls();
curControls->RemoveAll(); //sets off the crash

-----------

Thanks in advance!

     Product: Xtreme Toolkit Pro v9.70
     Platform: Windows XP (32bit) - SP 2
     Language: Visual C++ 6.0
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: 25 August 2009 at 5:39am

Hi

I guess problem somewhere else in your code. Maybe you store some pointer to some control and call it after you removed it and it not valid anymore.
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.047 seconds.