Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-102107

[REG 5.15.2 => 6.2.3] QMenuBar can crash on Mac

    XMLWordPrintable

Details

    • macOS
    • 5a9fbae0b (dev), 80eba4bb9 (6.4), 35e7c8497 (6.5), 5695f1d8c (tqtc/lts-6.2)

    Description

      We had the issue with a real program on some machines, but not on others. I however suspect this timing issue is not reflected in the attached example (that I suspect will crash always). The problem is that actionsRects are not set in native mode, and when the native mode is turned off the items dirty flag is not marked dirty (which it should)

      Alternatively caclActionRects could (maybe?) check if actionRects were identically sized to actions before bailing out. (However if native window is in use it may be acceptable they are not similar sized?)

      I am a bit busy and there is an easy workaround by setting nativeMenu as false first, but I will still be happy to review/approve a change (with a unit test).

      QSize QMenuBar::minimumSizeHint() const
      {
          Q_D(const QMenuBar);
          const bool as_gui_menubar = !isNativeMenuBar();
      
          ensurePolished();
          QSize ret(0, 0);
          const_cast<QMenuBarPrivate*>(d)->updateGeometries();
          const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this);
          const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
          int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
          int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
          if (as_gui_menubar) {
              int w = parentWidget() ? parentWidget()->width() : QGuiApplication::primaryScreen()->virtualGeometry().width();
              d->calcActionRects(w - (2 * fw), 0);
              for (int i = 0; ret.isNull() && i < d->actions.count(); ++i)
                  ret = d->actionRects.at(i).size(); // *BOOM :( - index out of range*
      
      
      
      

      Attachments

        1. main.cpp
          0.4 kB
        2. mainWindowFailure.pro
          0.1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vestbo Tor Arne Vestbø
            tmartsum Thorbjørn Lund Martsum
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: