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
Qt 6.11 is out! See what's new in the release blog

MainWindow destructor

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.8k 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
    bareil76
    wrote on last edited by
    #1

    Hi,

    I have the following destructor

    @MainWindow::~MainWindow()
    {
    disconnect(plugNPlay, SIGNAL(hid_comm_update(bool, int)), this, SLOT(update_gui(bool, int)));
    delete plugNPlay;
    delete ui;
    delete m_undoStack;
    }@

    where in the constructor, I have the following

    @plugNPlay = new HID_PnP();
    m_undoStack = new QUndoStack(this);@

    Now I get an error when exiting the destructor above "...write access error at 0x8..."

    Any idea?
    HID_PnP() is running a thread where its personnal destructor is

    @HID_PnP::~HID_PnP() {
    closeDevice();
    disconnect(timer, SIGNAL(timeout()), this, SLOT(PollUSB()));
    this->quit();
    this->wait();
    delete timer;
    }@

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bodzio131
      wrote on last edited by
      #2

      I'm not sure you should directly delete m_undoStack. It's because you set parent for it, so its parent is going to delete it itself. And any other qt-objects with qt-parent set too.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bareil76
        wrote on last edited by
        #3

        yes you are right... but even if I remove it, I still get the same error.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          msue
          wrote on last edited by
          #4

          You can continue debugging at the end of the destructor; you will end up in the destructors of the MainWindow member variables and maybe see the exact position of the crash.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bareil76
            wrote on last edited by
            #5

            I get the error when I reach the end of MainWindow... so its difficult to see what is next.

            If I look at the Windows task manager of the release version, the .exe will stay for ~5 seconds then disapear.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bodzio131
              wrote on last edited by
              #6

              Set in debugger to catch errors/exceptions in the place of throw. This way you will get callstack of modules and the topmost is the place of throw. If you don't see module details then make sure you have symbols/pdb. Have you tried 'debug' version? it could give you more clues about the problems in your program.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bareil76
                wrote on last edited by
                #7

                ok... will try that

                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