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. Crash (SIGSEV) when calling QMainWindow->menuBar()
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 240 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by Robert Hairgrove
    #1

    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) {
        ui->lblDbPicture->setPixmap(QPixmap(":/icons/database_demo.png"));
        ui->lblDbOffen->setText(demo_mode);
      } else if (workflow_status.isEmpty()) {
        ui->lblDbPicture->setPixmap(QPixmap(":/icons/database_red.png"));
        ui->lblDbOffen->setText(no_db);
      } else {
        ui->lblDbPicture->setPixmap(QPixmap(":/icons/database_green.png"));
        ui->lblDbOffen->setText(db_open.arg(dbfile));
      }
    
      QString gd = getDescr(workflow_status);
      QString gn = getNext(workflow_status);
      QString gcm = getCmdText(workflow_status);
      QString gcd = getCmdDescr(workflow_status);
    
      ui->lblCurrentStatus->setText(gd);
      ui->lblPossibleSteps->setText(gn);
      ui->cmdNextStep->setText(gcm);
      ui->lblCmdNextStepDescr->setText(gcd);
    }
    

    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):

    hideMenuBar_bug.png
    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"...

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • R Offline
        R Offline
        Robert Hairgrove
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        2

        • Login

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