Important: Please read the Qt Code of Conduct -

Crash (SIGSEV) when calling QMainWindow->menuBar()

  • The last day or two, my application has started behaving very strangely. I update pixmaps and button texts with simple stuff, but the window does not update properly until I resize it manually.

    For example, in the debugger I can step through the following procedure (public slot) which is called whenever the user opens or closes an SQLite database file:

    void WelcomeWidget::syncGui2Db()
      const QString no_db     = tr("No database");
      const QString demo_mode = tr("The demo database is open");
      const QString db_open   = tr("Database is open:\n%1");
      if (DEMO) {
      } else if (workflow_status.isEmpty()) {
      } else {
      QString gd = getDescr(workflow_status);
      QString gn = getNext(workflow_status);
      QString gcm = getCmdText(workflow_status);
      QString gcd = getCmdDescr(workflow_status);

    However, the window does not repaint itself. Adding update() at the end of the procedure does not do anything; wrapping everything in setUpdatesEnabled(false/true) also has no effect.

    My main window sets different central widgets, some of which hide the menu bar. When switching back to the main central widget, it should show the menu bar again. This is another slot which handles this; however, it crashes when I try to get the QMenuBar * (look at the yellow arrow on the left of the code):

    Has anyone seen anything like this? I have tried making a clean build, running the app outside of QtCreator, but it happens all the same (not consistently, however).

    I assume that these two issues must be somehow related, but cannot find the reason. The code has worked fine for months, now suddenly I get this "Christmas present"...

  • Lifetime Qt Champion

    You're calling this slot in the dtor of your class so I would guess the menuBar() is already destroyed.

  • @Christian-Ehrlicher Thank you ... that helped solve one of my problems!

    The window updates not happening were due to my overloaded event() function where I made the mistake of returning false instead of:

        return QMainWindow::event(event);

    I mentioned this recently in this thread: Once again, non-modal dialogs and main windows problem.

    Apparently, this is now SOLVED.

Log in to reply