Print Page | Close Window

Crash caused by XTPSkinManager

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=19227
Printed Date: 18 June 2025 at 9:10pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Crash caused by XTPSkinManager
Posted By: MacW
Subject: Crash caused by XTPSkinManager
Date Posted: 26 November 2011 at 10:04am
My app uses

to skin it. I tried for two days to find the reason for a crash caused when my app closes and opens views, and finally pinned it to the skin manager.

The problem causing the crash is that creating XTPCommandBars suddenly fails inside MFC, where the hooks created by MFC do not longer set the internal m_hWnd of CWnds correctly during Create or CreateEx.

These MFC hooks are intercepted by the XTP skin manager. I can repro the effect by opening and closing and opening again a view my application creates. The view contains a ton of child windows, many of them using command bars and other CodeJock classes.
My application uses several working threads, but none of them uses MFC classes or windows.

When the problem appears, the view fails during creating child windows after firing many ASSERTS inside the Create / CreateEx methods. The failure can happen in command bars, in XTP tooltips and elsewhere.

This is reproducible.

As soon as I comment out the calls to the skin manager methods the problem goes away. I *think* this problem crept in with one of the latest updates. I have not changed anything with the skin manager handing in six months, but now I have this problem.


XTPSkinManager()->EnableCurrentThread();   
XTPSkinManager()->SetApplyOptions(xtpSkinApplyFrame | xtpSkinApplyColors | xtpSkinApplyMetrics);
XTPSkinManager()->SetAutoApplyNewThreads(FALSE);


As soon as I comment out the three lines above (I call them in the ctor of CMainFrame) the problem is gone. I can close and open the view dozens of times without problems. Re-enabling the skinning cases the view to fail to create during create view / destroy view / create view.





Replies:
Posted By: MacW
Date Posted: 27 November 2011 at 6:59am
BOOL CWnd::CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,

...

    if (!AfxUnhookWindowCreate())
        PostNcDestroy();        // cleanup if CreateWindowEx fails too soon

    if (hWnd == NULL)
        return FALSE;
    ASSERT(hWnd == m_hWnd); // should have been set in send msg hook
  
 return TRUE;
}


Posted By: MacW
Date Posted: 07 December 2011 at 5:05am
The problem only happens when I enable skinning for my application. As soon as I comment out the EnableCurrentThead() call, things work as before.

Could somebody from Codejock please at least respond to this, perhaps with some tips on where too look? Did you change anything with your message hooking code / skin manager recently. This error was not there in earlier releases XTP.

The problem usually happen in XTP controls, e.g. dockbars:

BOOL CXTPDockBar::Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID)
{
    ASSERT(pParentWnd != NULL);

    // save the xtp
    m_dwStyle = (dwStyle & CBRS_ALL);

    XTPBarPosition barPosition = GetPosition();
    CString strWindowName = barPosition == xtpBarTop ? _T("xtpBarTop") :
        barPosition == xtpBarLeft ? _T("xtpBarLeft") :
        barPosition == xtpBarBottom ? _T("xtpBarBottom") : _T("xtpBarRight");

// This fails, Windows cannot create the window...

    return CWnd::Create(_T("XTPDockBar"), strWindowName, dwStyle, CXTPEmptyRect(), pParentWnd, nID);
}


Posted By: ABuenger
Date Posted: 07 December 2011 at 11:50am
Hi,

is it possible for you to reproduce the crash and provide a sample?

Andre



-------------
Codejock support


Posted By: MacW
Date Posted: 07 December 2011 at 2:02pm
I can reliably reproduce the crash in my application.
I'm not sure that it can be reproduced easily in a smaller sample.

My application uses dozens of panels and many of these panels have command bars. All of these windows are hosted in a CMainFrame window, which is declared as

class CMainFrame : public CXTPFrameWnd, CXTPOffice2007FrameHook

In response to certain commands, CMainFrame closes all child windows and panels, and then re-opens them.

This runs the same code that is run when the application closes and starts, e.g. it stores commandbar layouts and loads these layouts again.

This never causes trouble if the application is closed and started.

But when I do that without shutting down the application (the Codejock SkinManager remains running) the described problem with creating the command bars happens. Always. And always CreateWindow fails in one of the command bar classes, XTP status bar or toolbar or similar.






Posted By: znakeeye
Date Posted: 09 December 2011 at 4:22am

Hm. I sense a bad system-wide hook dll here. Look in the output window for suspect dlls being loaded. I know I had a similar problem with some Logitech mouse hook...ยจ

 
When you find it, exclude it using the ExcludeModule() API.
 
http://forum.codejock.com/forum_posts.asp?TID=14967&title=skinframeworkexcludemodule-known-bad-modules-list - http://forum.codejock.com/forum_posts.asp?TID=14967&title=skinframeworkexcludemodule-known-bad-modules-list


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: MacW
Date Posted: 10 December 2011 at 8:05am
Thanks for the tip, I will do that Smile
Hopefully the suggestions in the post you linked help.


Posted By: MacW
Date Posted: 11 December 2011 at 8:30am
Unfortunately, this was not the reason.
No unusual DLLs are on the call stack when the XTP hooks crash.

It always crashes in the creation of command bars, and only when I create the window containing all the panels and command bars the second time (after closing/destroying) it.

Is there some way to trace what XTP is doing? Perhaps something is not initialized correctly.

I wonder when this effect crept in because it worked for over a year. Not sure which XTP update causes the effect.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net