Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Try and catch but there is debug

Try and catch but there is debug

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad
    wrote on last edited by
    #1

    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

    J C 2 Replies Last reply
    0
    • A Ahmad

      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

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Off the top of my hat, try replacing OnCancel() with EndDialog(IDCANCEL). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      1 Reply Last reply
      0
      • A Ahmad

        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

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups