Print causes in afxtls.cpp
-
I have a small program. I compile the executable. If I find the executable and double click on it, everything works fine. I can print, print preview; all is well. If within visual studio I hit the green triangle to run the executable and then I try to print or print preview, I get an error in this code:
inline void* CThreadSlotData::GetThreadValue(int nSlot)
{
EnterCriticalSection(&m_sect);
ASSERT(nSlot != 0 && nSlot < m_nMax);
ASSERT(m_pSlotData != NULL);
ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
ASSERT(m_tlsIndex != (DWORD)-1);
if( nSlot <= 0 || nSlot >= m_nMax ) // check for retail builds.
{
LeaveCriticalSection(&m_sect);
return NULL;
}CThreadData\* pData = (CThreadData\*)TlsGetValue(m\_tlsIndex); if (pData == NULL || nSlot >= pData->nCount) { LeaveCriticalSection(&m\_sect); return NULL; } void\* pRetVal = pData->pData\[nSlot\]; LeaveCriticalSection(&m\_sect); return pRetVal;
}
It breaks at LeaveCriticalSection(). Im really perplexed as to why this error has arisen and what to do to get it to go away. If you have any insight, please let me know.
-
I have a small program. I compile the executable. If I find the executable and double click on it, everything works fine. I can print, print preview; all is well. If within visual studio I hit the green triangle to run the executable and then I try to print or print preview, I get an error in this code:
inline void* CThreadSlotData::GetThreadValue(int nSlot)
{
EnterCriticalSection(&m_sect);
ASSERT(nSlot != 0 && nSlot < m_nMax);
ASSERT(m_pSlotData != NULL);
ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
ASSERT(m_tlsIndex != (DWORD)-1);
if( nSlot <= 0 || nSlot >= m_nMax ) // check for retail builds.
{
LeaveCriticalSection(&m_sect);
return NULL;
}CThreadData\* pData = (CThreadData\*)TlsGetValue(m\_tlsIndex); if (pData == NULL || nSlot >= pData->nCount) { LeaveCriticalSection(&m\_sect); return NULL; } void\* pRetVal = pData->pData\[nSlot\]; LeaveCriticalSection(&m\_sect); return pRetVal;
}
It breaks at LeaveCriticalSection(). Im really perplexed as to why this error has arisen and what to do to get it to go away. If you have any insight, please let me know.
It would help if you gave us the details of the error you're getting. There's no way we can guess. Also, what line of code does it occur on? You have LeaveCriticalSection in three different lines.
The difficult we do right away... ...the impossible takes slightly longer.