Re: Unhandled exception - caused by not deleting vector?
- From: Ulrich Eckhardt <eckhardt@xxxxxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 12:44:24 +0100
Si wrote:
> UINT CChooseCampaignDlg::ThreadGetCampaigns(LPVOID pParam)
> {
> CChooseCampaignDlg* pDlg = static_cast<CChooseCampaignDlg*>(pParam);
> WPARAM wParam = (WPARAM) new
> vector<Campaign>(pDlg->manager.RequestCampaigns()); //line I provided
> earlier
> pDlg->PostMessage(UWM_MY_MESSAGE1, wParam, (LPARAM)0);
> return 0;
> }
I see a totally unrelated problem here: you can't use a CWnd* derived object
to send messages from a different thread, you need to use the plain win32
API here: PostMessage( pDsg->m_hWnd, UWM_MY_MESSAGE1, ...).
> The line of code it reaches when the crash happens is in the catch of the
> exception when it fails to connect :
>
> CATCH(CInternetException, pEx)
> {
> campaigns.push_back(Campaign(-1, _T("No campaign"))); //crash happens
> here!!!
> }
OK, if I understand you right, this is somewhere in the function
RequestCampain() of the manager object of the dialog. Of course, if you
close the dialog and the dialog object is destroyed, this will fail if it
is executed later. You need to prevent that from happening.
Put TRACE() macros in the ctors and dtors of all related classes and you
might see what is going on in what order.
BTW: you asked about a follow-up, this is used to direct traffic to just one
group and should be done when cross-posting to more than a group.
Uli
.
- Prev by Date: Re: Unhandled exception - caused by not deleting vector?
- Next by Date: const and call by value parameters
- Previous by thread: Re: Unhandled exception - caused by not deleting vector?
- Next by thread: const and call by value parameters
- Index(es):
Relevant Pages
|