Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. When closing application Exception Triggered.
Forum Update on Monday, May 27th 2025

When closing application Exception Triggered.

Scheduled Pinned Locked Moved Unsolved General and Desktop
24 Posts 5 Posters 1.9k Views
  • 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    Is there anything I can do to help me trace what is causing an Exception Triggered dialog to be displayed when the application is shut down?

    I've put a breakpoint in the class destructor Trainer and single stepped through it, everything looks ok and the exception seems to occur after exiting the exec() function, this is the main body:

    int main(int arc, char *argv[])
    {
        Trainer trainer(argc, argv);
        MainWindow w;
        w.show();
        return trainer.exec();
    }
    

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Nothing is shown in the debugger call stack ?

      SPlattenS 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        Nothing is shown in the debugger call stack ?

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by SPlatten
        #3

        @mrjj , yes the call stack, but there all go directly to assembler. The actual stop point is in:

        RPCRT4!NDRCContextBinding:
            0x759ede63 <+0x0013>  cpp. sword ptr [eax+4], 0FEDCBA98h
        

        Kind Regards,
        Sy

        JonBJ mrjjM 2 Replies Last reply
        0
        • SPlattenS SPlatten

          @mrjj , yes the call stack, but there all go directly to assembler. The actual stop point is in:

          RPCRT4!NDRCContextBinding:
              0x759ede63 <+0x0013>  cpp. sword ptr [eax+4], 0FEDCBA98h
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @SPlatten
          If we know nothing about Trainer, how would we answer?

          Try replacing Trainer trainer with Trainer *trainer = new Trainer. Hopefully that avoids destructor being called. Does it still crash?

          SPlattenS 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @mrjj , yes the call stack, but there all go directly to assembler. The actual stop point is in:

            RPCRT4!NDRCContextBinding:
                0x759ede63 <+0x0013>  cpp. sword ptr [eax+4], 0FEDCBA98h
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            Ok that is not super informative.

            I think its maybe in the clean up phase something explodes.

            You can try this
            https://stackoverflow.com/questions/16735413/how-can-i-make-qtcreator-break-on-exceptions

            It tells the debugger to stop where excpetion is thrown. maybe it can give a hint on whap happens.

            Also I would try

            // MainWindow w;
            // w.show();

            to see if its in trainer OR in the Mainwindow something happens.

            Do you load or link any other DLLS etc ?

            SPlattenS 1 Reply Last reply
            0
            • JonBJ JonB

              @SPlatten
              If we know nothing about Trainer, how would we answer?

              Try replacing Trainer trainer with Trainer *trainer = new Trainer. Hopefully that avoids destructor being called. Does it still crash?

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #6

              @JonB , I've just tried exactly that, its not calling the destructor now, but is still coming up with exactly the same exception dialog when the application is closed.

              Kind Regards,
              Sy

              1 Reply Last reply
              0
              • mrjjM mrjj

                Hi
                Ok that is not super informative.

                I think its maybe in the clean up phase something explodes.

                You can try this
                https://stackoverflow.com/questions/16735413/how-can-i-make-qtcreator-break-on-exceptions

                It tells the debugger to stop where excpetion is thrown. maybe it can give a hint on whap happens.

                Also I would try

                // MainWindow w;
                // w.show();

                to see if its in trainer OR in the Mainwindow something happens.

                Do you load or link any other DLLS etc ?

                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #7

                @mrjj said in When closing application Exception Triggered.:

                https://stackoverflow.com/questions/16735413/how-can-i-make-qtcreator-break-on-exceptions

                Tried that, no different.

                Kind Regards,
                Sy

                mrjjM 1 Reply Last reply
                0
                • SPlattenS SPlatten

                  @mrjj said in When closing application Exception Triggered.:

                  https://stackoverflow.com/questions/16735413/how-can-i-make-qtcreator-break-on-exceptions

                  Tried that, no different.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @SPlatten
                  Hi
                  And we are sure its not in MainWindow ?

                  SPlattenS 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @SPlatten
                    Hi
                    And we are sure its not in MainWindow ?

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #9

                    @mrjj , I've just commented out everything in the MainWindow destructor, recompiled and run and its still doing the same.

                    Kind Regards,
                    Sy

                    mrjjM JonBJ 2 Replies Last reply
                    0
                    • SPlattenS SPlatten

                      @mrjj , I've just commented out everything in the MainWindow destructor, recompiled and run and its still doing the same.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @SPlatten
                      Hi
                      ok. and you not having any members of QObject base in the class ?
                      I mean as non pointer in MainWindow.
                      Its sometimes possible to get double deletes that way.

                      SPlattenS 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @SPlatten
                        Hi
                        ok. and you not having any members of QObject base in the class ?
                        I mean as non pointer in MainWindow.
                        Its sometimes possible to get double deletes that way.

                        SPlattenS Offline
                        SPlattenS Offline
                        SPlatten
                        wrote on last edited by
                        #11

                        @mrjj , at the moment the application is in very early stages for the MainWindow class contains just:

                        DataSets* mpDataSetsDlg;
                        Ui::MainWindow* mpui;
                        

                        In the constructor:

                        MainWindow::MainWindow(QWidget* pParent) : QMainWindow(pParent),
                                                                   mpDataSetsDlg(nullptr),
                                                                   mpui(new Ui:MainWindow)
                        {
                            mpui->setupUi(this);
                            connect(mpui->btnDataSets, &QPushButton->clicked,
                                    this, &MainWindow::dataSetsBtnClicked);
                        }    
                        

                        In the destructor:

                        void MainWindow::~MainWindow()
                        {
                            if ( mpDataSetsDlg != nullptr )
                            {
                                delete mpDataSetsDlg;
                                mpDataSetsDlg = nullptr;
                            }
                            delete mpui;
                            mpui = nullptr;
                        }
                        

                        Kind Regards,
                        Sy

                        1 Reply Last reply
                        0
                        • SPlattenS SPlatten

                          @mrjj , I've just commented out everything in the MainWindow destructor, recompiled and run and its still doing the same.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #12

                          @SPlatten
                          Remove all your #includes, other than what is required to get a minimal Qt program open a main window. It should be 10 lines long. No Trainer object No Trainer include files. Does it work?

                          If your program only crashes with Trainer and its include files, I still don't understand what we can say since we don't even know what it is.

                          SPlattenS 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @SPlatten
                            Remove all your #includes, other than what is required to get a minimal Qt program open a main window. It should be 10 lines long. No Trainer object No Trainer include files. Does it work?

                            If your program only crashes with Trainer and its include files, I still don't understand what we can say since we don't even know what it is.

                            SPlattenS Offline
                            SPlattenS Offline
                            SPlatten
                            wrote on last edited by
                            #13

                            @JonB , I modified main.cpp to:

                            #include <QApplication> //Add this
                            #include "main window.h"
                            //#include "trainer.h"
                            
                            int main(int argc, char* argv[])
                            {
                                //Trainer trainer(argc, argv);
                                QApplication a(argc, argv);
                                MainWindow w;
                                w.show();
                                return a.exec();
                                //return trainer.exec();
                            }
                            

                            Rebuilt and it does exactly the same, crash location is in exactly the same place.

                            Kind Regards,
                            Sy

                            J.HilkJ JonBJ 2 Replies Last reply
                            0
                            • SPlattenS SPlatten

                              @JonB , I modified main.cpp to:

                              #include <QApplication> //Add this
                              #include "main window.h"
                              //#include "trainer.h"
                              
                              int main(int argc, char* argv[])
                              {
                                  //Trainer trainer(argc, argv);
                                  QApplication a(argc, argv);
                                  MainWindow w;
                                  w.show();
                                  return a.exec();
                                  //return trainer.exec();
                              }
                              

                              Rebuilt and it does exactly the same, crash location is in exactly the same place.

                              J.HilkJ Offline
                              J.HilkJ Offline
                              J.Hilk
                              Moderators
                              wrote on last edited by
                              #14

                              @SPlatten well, in the stack trace, what's the first entry, thats from your code ?

                              you know that you can step back, when you're in assembler code right?


                              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                              Q: What's that?
                              A: It's blue light.
                              Q: What does it do?
                              A: It turns blue.

                              SPlattenS 1 Reply Last reply
                              0
                              • SPlattenS SPlatten

                                @JonB , I modified main.cpp to:

                                #include <QApplication> //Add this
                                #include "main window.h"
                                //#include "trainer.h"
                                
                                int main(int argc, char* argv[])
                                {
                                    //Trainer trainer(argc, argv);
                                    QApplication a(argc, argv);
                                    MainWindow w;
                                    w.show();
                                    return a.exec();
                                    //return trainer.exec();
                                }
                                

                                Rebuilt and it does exactly the same, crash location is in exactly the same place.

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by JonB
                                #15

                                @SPlatten
                                Remove #include "main window.h" and replace MainWindow w; by QMainWindow w; (with presumably #include <QMainWindow>).

                                If that does not work, since it is the minimal Qt application what has changed for you since you last successfully built/ran any Qt GUI program?

                                SPlattenS 1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @SPlatten
                                  Remove #include "main window.h" and replace MainWindow w; by QMainWindow w; (with presumably #include <QMainWindow>).

                                  If that does not work, since it is the minimal Qt application what has changed for you since you last successfully built/ran any Qt GUI program?

                                  SPlattenS Offline
                                  SPlattenS Offline
                                  SPlatten
                                  wrote on last edited by
                                  #16

                                  @JonB , to be honest, it could be the build of the laptop, its an older version of Qt:

                                  Qt Creator 4.4.1
                                  Based on Qt 5.9.2 (MSVC 2015, 32 bit)
                                  

                                  I have no control over the laptop or the version of Qt being used, this is supplied by the company I am contracted to.

                                  Kind Regards,
                                  Sy

                                  1 Reply Last reply
                                  0
                                  • J.HilkJ J.Hilk

                                    @SPlatten well, in the stack trace, what's the first entry, thats from your code ?

                                    you know that you can step back, when you're in assembler code right?

                                    SPlattenS Offline
                                    SPlattenS Offline
                                    SPlatten
                                    wrote on last edited by
                                    #17

                                    @J-Hilk , I've expanded the stack trace and there is no call the traces back to my source, the first call is in Function: RtlGetAppContainerNamedObjectPath, File: ntdll

                                    Kind Regards,
                                    Sy

                                    J.HilkJ 1 Reply Last reply
                                    0
                                    • SPlattenS SPlatten

                                      @J-Hilk , I've expanded the stack trace and there is no call the traces back to my source, the first call is in Function: RtlGetAppContainerNamedObjectPath, File: ntdll

                                      J.HilkJ Offline
                                      J.HilkJ Offline
                                      J.Hilk
                                      Moderators
                                      wrote on last edited by
                                      #18

                                      @SPlatten thats unfortunate

                                      since this is a basic and small project so far, can you share, the minimal example ?

                                      that means probably only your custom MainWindow, so we can check ourselves, and check it against different Qt versions as well


                                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                      Q: What's that?
                                      A: It's blue light.
                                      Q: What does it do?
                                      A: It turns blue.

                                      JonBJ SPlattenS 2 Replies Last reply
                                      0
                                      • J.HilkJ J.Hilk

                                        @SPlatten thats unfortunate

                                        since this is a basic and small project so far, can you share, the minimal example ?

                                        that means probably only your custom MainWindow, so we can check ourselves, and check it against different Qt versions as well

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #19

                                        @J-Hilk
                                        That is why I suggested @SPlatten should use QMainWindow, not his own MainWindow, to test. If that still does not work (I'm not sure if he has answered that), then something is fundamentally with his Qt/environment. I would do that before examining anything about a custom MainWindow or header file.

                                        1 Reply Last reply
                                        0
                                        • J.HilkJ J.Hilk

                                          @SPlatten thats unfortunate

                                          since this is a basic and small project so far, can you share, the minimal example ?

                                          that means probably only your custom MainWindow, so we can check ourselves, and check it against different Qt versions as well

                                          SPlattenS Offline
                                          SPlattenS Offline
                                          SPlatten
                                          wrote on last edited by
                                          #20

                                          @J-Hilk , in doing this, I decided to go one better. I did the following in Qt Creator:

                                          1. Clicked on File top line menu
                                          2. Selected New File or Project...
                                          3. Selected Application and Qt Widgets Application
                                          4. Clicked on the Choose... button
                                          5. Entered test into Name: text box and clicked the Next button
                                          6. Checked only Desktop Qt 5.9.2 MSVC2015 32bit in Kit Selection
                                          7. Clicked Next button
                                          8. Clicked Next button
                                          9. Clicked Finish button
                                          10. Right clicked project and selected Rebuild
                                          11. Run application in debug mode and clicked the close widget in the MainWindow

                                          Same thing happens, application stops and Exception Triggered dialog is displayed.

                                          Kind Regards,
                                          Sy

                                          JoeCFDJ 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved