Heap Corruption issue
-
I've got an application which has two dialogs, I use a deque and Direct2D in one dialog within a thread. Now, if I close the application via handling WM_CLOSE I have no problem but when I try and close it by clicking on 'Close Window' in the task bar or using Alt F4 I get a breakpoint triggered on
if (!HeapFree(select_heap(block), 0, block))
I know it's a long shot since I have given so little detail - but seeing as the difference seems to be in the way I close the app down I was hoping there might be a quick and easy fix for this. Yours hopefully, Ben *Update since I posted in this it the next door forum, this morning, by mistake: I still get the same error if the thread (and hence the direct2d drawing) isn't running. Perhaps it is something to do with the way I set up the dialogs.
-
I've got an application which has two dialogs, I use a deque and Direct2D in one dialog within a thread. Now, if I close the application via handling WM_CLOSE I have no problem but when I try and close it by clicking on 'Close Window' in the task bar or using Alt F4 I get a breakpoint triggered on
if (!HeapFree(select_heap(block), 0, block))
I know it's a long shot since I have given so little detail - but seeing as the difference seems to be in the way I close the app down I was hoping there might be a quick and easy fix for this. Yours hopefully, Ben *Update since I posted in this it the next door forum, this morning, by mistake: I still get the same error if the thread (and hence the direct2d drawing) isn't running. Perhaps it is something to do with the way I set up the dialogs.
Isn't the
WM_CLOSE
message being sent whether you terminate the app via Task Manager or by using Alt+F4?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Isn't the
WM_CLOSE
message being sent whether you terminate the app via Task Manager or by using Alt+F4?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
Thanks for your reply! I don't know, to be honest. The problem was occurring when I AltF4ed or clicked on Close Window but not when I clicked on my 'Exit' button. However, it looks like it was a corrupt memory problem I had with a member variable I'd assigned to the heap and was using to pass data between threads. I've changed the communication to the following: In the sending thread:
ControlDlg \* pParent = (ControlDlg \*) this->GetParent(); ColourAlphaEnvelope \* s = new ColourAlphaEnvelope; \*s = m\_ColourEnvelope; pParent->PostMessage(CM\_COLOURBOUNDS, reinterpret\_cast<WPARAM>(s));
and in the recieving dialog I used
afx_msg LRESULT CRectArtDlg::OnCmColourbounds(WPARAM wParam, LPARAM lParam)
{
std::auto_ptr<ColourAlphaEnvelope> s(reinterpret_cast<ColourAlphaEnvelope*>(wParam));
m_colourEnvelope = *s;
return 0;
}I bet there are dozens of better ways of doing this (not least since a quick Google reveals that auto_ptr is depracated) but I haven't had a crash and the compiler isn't telling me there is a memory leak.