Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Crash on PaintManager destructor
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Crash on PaintManager destructor

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

Joined: 19 August 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_shehadeh Quote  Post ReplyReply Direct Link To This Post Topic: Crash on PaintManager destructor
    Posted: 24 January 2007 at 3:28pm
I'm seeing a crash with the following stack when I shutdown my application:

mfc80d.dll!AfxImageList_Destroy(_IMAGELIST * himl=0x0019d148) 
mfc80d.dll!CImageList::DeleteImageList()  C++
mfc80d.dll!CImageList::~CImageList()    ToolkitPro1031vc80D.dll!XTPPaintThemes::CXTPOffice2003Theme::~CXTPOffice2003Theme()
ToolkitPro1031vc80D.dll!XTPPaintThemes::CXTPOffice2003Theme::`vector deleting destructor'()
mfc80d.dll!CCmdTarget::OnFinalRelease()
mfc80d.dll!CCmdTarget::InternalRelease() 
ToolkitPro1031vc80D.dll!CXTPPaintManager::Done()  ToolkitPro1031vc80D.dll!CXTPPaintManager::CPaintManagerDestructor::~CPaintManagerDestructor()

The crash is occuring because m_hImageList is NULL  inside of the CImageList class.  What's interesting is that the class checks for NULL just before it calls AfxImageList_Destroy. 

This began happening when I added code to a view that puts a CXTPToolBar at the top of the window.  In the OnCreate of my CView-derived class I added the following code:
   m_wndCameraToolBar.CreateToolBar(WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBRS_TOOLTIPS, this)
m_wndCameraToolBar.SetOwner (this);
m_wndCameraToolBar.LoadToolBar(IDR_CAMERA_TOOLBAR);


Where IDR_CAMERA_TOOLBAR is a toolbar resource that has button names that are the same as some button names in the main application toolbar (I think that might be relevant).

When I remove the code above, the crash no longer happens.  I know this is a somewhat complicated situation to describe so I modified one of the CodeJock samples that does the same thing (but doesn't crash).  The fact that the sample doesn't crash suggests that there's something else going on.  Here is some other information that might be relevant:

1) The main app used codejock and mfc dynamically
2) The main app loads a DLL that also uses codejock and mfc dynamically
3) There is one other toolbar in the application that are created and used this way but instead of using LoadToolbar, it does this:

        CXTPImageManager objecttypes;
        objecttypes.SetIcons (IDR_OBJECT_TYPES);
        m_wndToolBar.GetImageManager ()->AddIcons (&objecttypes);

See linked file for an example of what I'm trying to do (see CGUI_VisualStudio7View::OnCreate for new code):

http://iwonderdesigns.com/downloads/GUI_VisualStudio7.zip

Thanks for your help,
Karim

Karim Shehadeh
iWonder Designs
http://www.iwonderdesigns.com
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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 January 2007 at 1:09am

Hi,

think problem that dll and main application use diffrent paintmanagers.
 
try to call pPaintManager->Done() ; in your dll manually.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
k_shehadeh View Drop Down
Newbie
Newbie
Avatar

Joined: 19 August 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_shehadeh Quote  Post ReplyReply Direct Link To This Post Posted: 25 January 2007 at 8:54am
At what point in the DLL should I call Done in the DLL?  Should it be in the applicaiton object's ExitInstance?  And what's the best way to access the paint manager for the DLL?  Is it a global object?
Karim Shehadeh
iWonder Designs
http://www.iwonderdesigns.com
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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 January 2007 at 1:47pm
Hello, yes, think ExitInstance good place.  call
XTPPaintManager()->Done();
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
k_shehadeh View Drop Down
Newbie
Newbie
Avatar

Joined: 19 August 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_shehadeh Quote  Post ReplyReply Direct Link To This Post Posted: 25 January 2007 at 2:06pm
Hm.  I tried that and now I'm getting a crash in a different place during the ExitInstance stack but still inside some paintmanager code:

void CXTPWinThemeWrapper::CloseThemeData()
{
    if (m_hTheme && !m_bDllDetached)
    {
        TRY_POINTER_CALL(CloseThemeData)
            POINTER_CALL(m_hTheme);
        CATCH_POINTER_CALL()
    }

    m_hTheme = NULL;
}


...

with the following stack:

     uxtheme.dll!CAutoCS::CAutoCS()  + 0x11 bytes   
     uxtheme.dll!CRenderList::CloseRenderObject()  + 0x16 bytes   
     uxtheme.dll!_CloseThemeData@4()  + 0x1f bytes   
>    ToolkitPro1031vc80D.dll!CXTPWinThemeWrapper::CloseThemeData()  Line 106 + 0xc bytes    C++
     ToolkitPro1031vc80D.dll!CXTPWinThemeWrapper::~CXTPWinThemeWrapper()  Line 82    C++
     ToolkitPro1031vc80D.dll!CXTPControlGalleryPaintManager::~CXTPControlGalleryPaintManager()  + 0x2e bytes    C++
     ToolkitPro1031vc80D.dll!CXTPControlGalleryPaintManager::`scalar deleting destructor'()  + 0x2b bytes    C++
     ToolkitPro1031vc80D.dll!CXTPPaintManager::~CXTPPaintManager()  Line 160 + 0x31 bytes    C++
     ToolkitPro1031vc80D.dll!XTPPaintThemes::CXTPOfficeTheme::~CXTPOfficeTheme()  + 0x2b bytes    C++
     ToolkitPro1031vc80D.dll!XTPPaintThemes::CXTPOffice2003Theme::~CXTPOffice2003Theme()  Line 67 + 0x1d bytes    C++
     ToolkitPro1031vc80D.dll!XTPPaintThemes::CXTPOffice2003Theme::`vector deleting destructor'()  + 0x6c bytes    C++
     mfc80d.dll!CCmdTarget::OnFinalRelease()  Line 579 + 0x21 bytes    C++
     mfc80d.dll!CCmdTarget::InternalRelease()  Line 138    C++
     ToolkitPro1031vc80D.dll!CXTPPaintManager::Done()  Line 254    C++
     typhon.dll!CTyphonApp::ExitInstance()  Line 70 + 0xd bytes    C++

Karim Shehadeh
iWonder Designs
http://www.iwonderdesigns.com
Back to Top
k_shehadeh View Drop Down
Newbie
Newbie
Avatar

Joined: 19 August 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_shehadeh Quote  Post ReplyReply Direct Link To This Post Posted: 26 January 2007 at 12:07pm
While it didn't work in Exit Instance of the DLL, calling it in the deinit of the main application did work.  Thanks!

(Though I'm still not clear what the source of the problem is)
Karim Shehadeh
iWonder Designs
http://www.iwonderdesigns.com
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 26 January 2007 at 2:21pm

Hi,

You have debug strings of uxtheme.dll? How?? Where? :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Sven View Drop Down
Senior Member
Senior Member


Joined: 21 August 2003
Location: Germany
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sven Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2007 at 5:37am
Add http://msdl.microsoft.com/download/symbols as symbol directory in VC8 you will get debug information for all Windows dll's.
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 29 January 2007 at 1:02am
Thanks! :)
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.061 seconds.