Re: Export a splitter view from a DLL using WTL.
I think it's ATL::_pAtlModule which caused the problem. We can see
that CStaticDataInitCriticalSectionLock use the ATL::_pAtlModule-
m_csStaticDataInitAndTypeInfo to initialize the variable m_cslock:
class CStaticDataInitCriticalSectionLock
{
public:
#if (_ATL_VER >= 0x0700)
ATL::CComCritSecLock<ATL::CComCriticalSection> m_cslock;
CStaticDataInitCriticalSectionLock() : m_cslock
(ATL::_pAtlModule->m_csStaticDataInitAndTypeInfo, false)
{ }
#endif // (_ATL_VER >= 0x0700)
HRESULT Lock()
{
#if (_ATL_VER >= 0x0700)
return m_cslock.Lock();
#else // !(_ATL_VER >= 0x0700)
::EnterCriticalSection(&ATL::_pModule-
m_csStaticDataInit);
return S_OK;
#endif // !(_ATL_VER >= 0x0700)
}
void Unlock()
{
#if (_ATL_VER >= 0x0700)
m_cslock.Unlock();
#else // !(_ATL_VER >= 0x0700)
::LeaveCriticalSection(&ATL::_pModule-
m_csStaticDataInit);
#endif // !(_ATL_VER >= 0x0700)
}
};
Actually, the ATL::_pAtlModule is null when we call the constructor.
Also, I test another issue: If we commented the lines related to
CStaticDataInitCriticalSectionLock, create two nested views derive
from CWindowImpl<T,CAxWindow>, it can also cause crash. Because
CAxWindow will call the ATL::_pModule->lock() when they are created.
But if we use them in the way of not exported from DLL, they all work
fine. So, that's the problem: why aren't we able to use them exported
from a DLL file?