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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Assertion Failed in OnCancel

Assertion Failed in OnCancel

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingquestion
10 Posts 3 Posters 1 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.
  • B Offline
    B Offline
    BoudewijnEctor
    wrote on last edited by
    #1

    Hi, I have got a CDialog instance, and it has a Cancel and an OK button, OnOk works, but if I call OnCancel, or EndDialog(x), I'm getting an error (in runtime:mad). It says this: Debug Assertion Failed! file: wincore.cpp line: 4184 Can this be caused by the fact that I've got another CDialog instance wich calls the DoModal of the one above? Please help me solve this problem!

    J D 2 Replies Last reply
    0
    • B BoudewijnEctor

      Hi, I have got a CDialog instance, and it has a Cancel and an OK button, OnOk works, but if I call OnCancel, or EndDialog(x), I'm getting an error (in runtime:mad). It says this: Debug Assertion Failed! file: wincore.cpp line: 4184 Can this be caused by the fact that I've got another CDialog instance wich calls the DoModal of the one above? Please help me solve this problem!

      J Offline
      J Offline
      Jagadeesh VN
      wrote on last edited by
      #2

      Its not possible to figure out what cud be the issue with the above description. Would like to know from where that dialog created, what happens after the dialog is dismissed, et al. "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

      J B 2 Replies Last reply
      0
      • J Jagadeesh VN

        Its not possible to figure out what cud be the issue with the above description. Would like to know from where that dialog created, what happens after the dialog is dismissed, et al. "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

        J Offline
        J Offline
        Jagadeesh VN
        wrote on last edited by
        #3

        You can also check the CallStack by running the program in DEBUG mode, and see from where it got to Wincore.cpp "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

        1 Reply Last reply
        0
        • J Jagadeesh VN

          Its not possible to figure out what cud be the issue with the above description. Would like to know from where that dialog created, what happens after the dialog is dismissed, et al. "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

          B Offline
          B Offline
          BoudewijnEctor
          wrote on last edited by
          #4

          OK, If I simplify the situation the following happes: diag2 : diag2.DoModal diag2 : do some work etc... diag2 : when ready (or user presses cancel) EndDialog() or diag2 : when ready (or user presses cancel) OnCancel()

          J 2 Replies Last reply
          0
          • B BoudewijnEctor

            OK, If I simplify the situation the following happes: diag2 : diag2.DoModal diag2 : do some work etc... diag2 : when ready (or user presses cancel) EndDialog() or diag2 : when ready (or user presses cancel) OnCancel()

            J Offline
            J Offline
            Jagadeesh VN
            wrote on last edited by
            #5

            Is it like this ?? In Dlgdiag2.cpp CDlgdiag2::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } CDlgDiag2::OnCancel() { EndDialog(); OR OnCancel(); } "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

            B 1 Reply Last reply
            0
            • B BoudewijnEctor

              OK, If I simplify the situation the following happes: diag2 : diag2.DoModal diag2 : do some work etc... diag2 : when ready (or user presses cancel) EndDialog() or diag2 : when ready (or user presses cancel) OnCancel()

              J Offline
              J Offline
              Jagadeesh VN
              wrote on last edited by
              #6

              If possible, post the code. OR you can use CallStack( Right click anywhere on the toolbar, and select CallStack ) in debug mode to see how the control reached wincore "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

              1 Reply Last reply
              0
              • B BoudewijnEctor

                Hi, I have got a CDialog instance, and it has a Cancel and an OK button, OnOk works, but if I call OnCancel, or EndDialog(x), I'm getting an error (in runtime:mad). It says this: Debug Assertion Failed! file: wincore.cpp line: 4184 Can this be caused by the fact that I've got another CDialog instance wich calls the DoModal of the one above? Please help me solve this problem!

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                BoudewijnEctor wrote: file: wincore.cpp line: 4184 Strange as wincore.cpp does not have that many lines. Are you using VS6 or VS.NET?


                Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                J 1 Reply Last reply
                0
                • D David Crow

                  BoudewijnEctor wrote: file: wincore.cpp line: 4184 Strange as wincore.cpp does not have that many lines. Are you using VS6 or VS.NET?


                  Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                  J Offline
                  J Offline
                  Jagadeesh VN
                  wrote on last edited by
                  #8

                  I was also little bit confused!!! :confused: :confused: :confused: "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

                  1 Reply Last reply
                  0
                  • J Jagadeesh VN

                    Is it like this ?? In Dlgdiag2.cpp CDlgdiag2::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } CDlgDiag2::OnCancel() { EndDialog(); OR OnCancel(); } "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

                    B Offline
                    B Offline
                    BoudewijnEctor
                    wrote on last edited by
                    #9

                    Jagadeesh VN wrote: CDlgdiag2::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } CDlgDiag2::OnCancel() { EndDialog(); OR OnCancel(); It is: CDlgdiag1::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } CDlgDiag2::OnCancel() { EndDialog(); OR OnCancel(); }

                    J 1 Reply Last reply
                    0
                    • B BoudewijnEctor

                      Jagadeesh VN wrote: CDlgdiag2::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } CDlgDiag2::OnCancel() { EndDialog(); OR OnCancel(); It is: CDlgdiag1::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } CDlgDiag2::OnCancel() { EndDialog(); OR OnCancel(); }

                      J Offline
                      J Offline
                      Jagadeesh VN
                      wrote on last edited by
                      #10

                      If you are calling OnCancel(), you are in trouble. It will take you to an infinite loop. So you should be using CDialog::OnCancel() I know, thats not the problem you are facing. But apart from that, I just can't find anything odd in this piece of code. You can do one thing. As I have suggested earlier put a breakpoint in CDlgDiag2::OnCancel() { EndDialog(); //HERE } put another break point in CDlgdiag1::OnSomeAction() { CDlgdiag2 diag2; diag2.DoModal(); } // HERE run the program in DEBUG mode( press F5 ), and then press the Cancel button, then you will be in EndDialog fn. press F5 again, then either the control will reach the 2nd break point, or else it will ASSERT. When it ASSERTs, right click anywhere on the toolbar and select the 'CallStack' option. If you are not getting any idea on what it is, just dump it here, so that we can have a look at where its going wrong. Another thing I noticed is, wincore.cpp has only 3948 lines. How come you got an error in 4198 ? "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

                      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