Try and catch but there is debug
-
Hi every one I use try and catch to initial some things or destroy when some thing wrong. It’s works fine ,but an debug assertion occurred when destroy window. My code like this : BOOL MyDlg::OnInitDialog() { m_dat = new CDaoDatabase; try { m_dat->Open("dat.mdb"); } catch (CDaoException* e){ delete m_dat; m_dat=NULL; e->ReportError(); e->Delete(); CDialog::OnCancel(); } } I hope for any one can help me to avoid that debug assertion and tell me more about it ... Thank you,,, AHMAD ALWASHALI
-
Hi every one I use try and catch to initial some things or destroy when some thing wrong. It’s works fine ,but an debug assertion occurred when destroy window. My code like this : BOOL MyDlg::OnInitDialog() { m_dat = new CDaoDatabase; try { m_dat->Open("dat.mdb"); } catch (CDaoException* e){ delete m_dat; m_dat=NULL; e->ReportError(); e->Delete(); CDialog::OnCancel(); } } I hope for any one can help me to avoid that debug assertion and tell me more about it ... Thank you,,, AHMAD ALWASHALI
Off the top of my hat, try replacing
OnCancel()
withEndDialog(IDCANCEL)
. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
Hi every one I use try and catch to initial some things or destroy when some thing wrong. It’s works fine ,but an debug assertion occurred when destroy window. My code like this : BOOL MyDlg::OnInitDialog() { m_dat = new CDaoDatabase; try { m_dat->Open("dat.mdb"); } catch (CDaoException* e){ delete m_dat; m_dat=NULL; e->ReportError(); e->Delete(); CDialog::OnCancel(); } } I hope for any one can help me to avoid that debug assertion and tell me more about it ... Thank you,,, AHMAD ALWASHALI
The reason you get a debug assertion is so you can go into the debugger and see where the ASSERT has failed, and therefore do something about it. Often it doesn't actually kill your program, it is warning you however that you've leaked memory or done something else that needs cleaning up. I'd suggest if you have this problem in future, you look at where it is occuring, and if you can't fix it, post where it crashes as well as the block of code that is crashing. Christian As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet. Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.