QMenu Crashed in MacOS11/beta

  c++, qt

Two days ago, I Upgraded the MacOS11(beta), then in my program, the asynchronous menu causes program crash. Here is the crashed report:
enter image description here

this is my code :

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QUuid>
#include <QThread>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    m_btn = new QPushButton(this);
    m_btn->setFixedWidth(100);
    m_btn->setText("test");

    m_Menu = new QMenu(this);
    m_Menu ->addAction("out1");
    m_Menu ->addAction("out2");
    m_Menu ->addAction("out3");

    //m_ChildMenu = new QMenu(this);
    connect(m_btn, &QPushButton::clicked, this, &MainWindow::slot_ShowMenu);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::slot_ShowMenu()
{

    m_ChildMenu = m_Menu->addMenu("m_ChildMenu");

    m_ChildMenu ->addAction("test 1");

/*
    for(int i = 0; i < acts.size(); i++) {
       removeAction(acts[i]);

           delete acts[i];

    }
*/
    QThread *mThread = new QThread();
    QObject::connect(mThread, &QThread::started, [mThread](){
        mThread->msleep(2000);
        mThread->quit();
    });
    
    connect(mThread, &QThread::finished, m_ChildMenu,[this](){
        m_ChildMenu->clear(); // here, will be crashed
        m_ChildMenu ->addAction("out");
    });
    mThread->start();

    m_Menu->exec();

}

this code has run well in windows or other MacOS , So, Why it crashed in this bate MacOS

Source: Windows Questions C++

LEAVE A COMMENT