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. MainWindow destructor not called

MainWindow destructor not called

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 859 Views 3 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
    addebito
    wrote on last edited by
    #1

    Hi all,

    sometimes I see that the destructor of the MainWindow of my application is not called, last logged call by qDebug() is the MainWindow::closeEvent and the program does not close.

    How to investigate the problem?
    How to understand the origin of the problem?

    Windows 10
    Qt 5.14.2

    Thank you.

    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #2

      A good first start is to run the program in a debugger, and then break when it does not close. How does the stack trace look like?

      Director R&D, The Qt Company

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

        Hi
        It's hard to guess with no info on what the app is doing.

        Q1:
        In your override of the MainWindow::closeEvent
        you do call the base closeEvent ?

        Q2:
        Do you have any huge for loops or anything that would
        starve the event loop ?

        Q3:
        Do you use more than one mainwindow ?
        Im asking as
        https://doc-snapshots.qt.io/qt5-5.14/qguiapplication.html#quitOnLastWindowClosed-prop
        this is set on default so if all top level windows are closed then exec() esits and the
        the app is terminated.

        Q4:
        You tested with a default GUI app, to see that that always closes?

        1 Reply Last reply
        2
        • A Offline
          A Offline
          addebito
          wrote on last edited by
          #4

          Hi @kkoehne , hi @mrjj ,

          @mrjj, yes you are right when you said

          It's hard to guess with no info on what the app is doing.

          but it is also difficult to give you informations when you can't reproduce the problem at every run on a big project...

          Anyway, thank you for your suggestions and for your time.
          I've isolated, found and correct the problem, it was a class that show a popup message.

          mrjjM 1 Reply Last reply
          1
          • A addebito

            Hi @kkoehne , hi @mrjj ,

            @mrjj, yes you are right when you said

            It's hard to guess with no info on what the app is doing.

            but it is also difficult to give you informations when you can't reproduce the problem at every run on a big project...

            Anyway, thank you for your suggestions and for your time.
            I've isolated, found and correct the problem, it was a class that show a popup message.

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

            @addebito
            Hi
            Ok good news :)
            So some other class would popup something and the app was not truly closed and hence the dtor was not called?
            Something like that?

            1 Reply Last reply
            1
            • A Offline
              A Offline
              addebito
              wrote on last edited by
              #6

              Yes @mrjj

              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