Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
None
-
6.6
-
None
-
my machine is macOS soname 14.2.1, and according to [various other people's reports|https://github.com/xiaoyifang/goldendict-ng/issues/1377], this happens on both X86 & M1 mac.
Description
This only happens on macOS.
If a QCombobox is already shown, clear() then additem() will lead to a crash.
Weirdly, the stack traces appear to reach `QCocoaAccessibility::notifyAccessibilityUpdate`. Maybe this is an A11y problem.
Mini reproduction code:
Click the button, and it will crash.
#include <QApplication> #include <QComboBox> #include <QVBoxLayout> #include <QPushButton> int main(int argc, char* argv[]) { QApplication a(argc, argv); auto* widget = new QWidget(nullptr); auto* combobox = new QComboBox(nullptr); combobox->addItem(combobox->style()->standardIcon(QStyle::SP_DesktopIcon), "init item", "crash"); widget->setLayout(new QVBoxLayout()); widget->layout()->addWidget(combobox); auto* btn = new QPushButton("Clear then add item.", widget); QObject::connect(btn, &QPushButton::clicked, [&combobox] { combobox->clear(); combobox->addItem(combobox->style()->standardIcon(QStyle::SP_DesktopIcon), "crash", "crash"); }); widget->layout()->addWidget(btn); widget->show(); return QApplication::exec(); }
Backtraces:
__pthread_kill 0x000000018bec20dc pthread_kill 0x000000018bef9cc0 abort 0x000000018be05a40 abort_message 0x000000018beb1070 demangling_terminate_handler() 0x000000018bea112c _objc_terminate() 0x000000018bb4798c std::__terminate(void (*)()) 0x000000018beb0434 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception *) 0x000000018beb3520 __cxa_throw 0x000000018beb3464 objc_exception_throw 0x000000018bb3e01c -[__NSArrayM objectAtIndexedSubscript:] 0x000000018bfc2d10 -[QMacAccessibilityElement initWithId:role:] 0x0000000104b5256c +[QMacAccessibilityElement elementWithId:] 0x0000000104b525ec QCocoaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *) 0x0000000104b50b88 QListView::selectionChanged(const QItemSelection &, const QItemSelection &) 0x000000010565e888 doActivate<…>(QObject *, int, void **) 0x0000000105b14b00 QItemSelectionModel::emitSelectionChanged(const QItemSelection &, const QItemSelection &) 0x0000000105c76a74 QItemSelectionModel::select(const QItemSelection &, QFlags<…>) 0x0000000105c765f8 QItemSelectionModel::select(const QModelIndex &, QFlags<…>) 0x0000000105c7645c QItemSelectionModel::setCurrentIndex(const QModelIndex &, QFlags<…>) 0x0000000105c76e60 QComboBoxPrivate::setCurrentIndex(const QModelIndex &) 0x00000001054f02e8 QComboBox::setCurrentIndex(int) 0x00000001054efb5c QComboBoxPrivate::rowsInserted(const QModelIndex &, int, int) 0x00000001054f3038 doActivate<…>(QObject *, int, void **) 0x0000000105b148f8 QAbstractItemModel::endInsertRows() 0x0000000105c63ec4 QStandardItemPrivate::insertRows(int, int, const QList<…> &) 0x0000000106369218 QComboBox::insertItem(int, const QIcon &, const QString &, const QVariant &) 0x00000001054f58a8 QComboBox::addItem(const QIcon &, const QString &, const QVariant &) qcombobox.h:213 main::$_0::operator()() const main.cpp:28 QtPrivate::FunctorCall::call(main::$_0 &, void **) qobjectdefs_impl.h:137 QtPrivate::Functor::call<…>(main::$_0 &, void *, void **) qobjectdefs_impl.h:339 QtPrivate::QCallableObject::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) qobjectdefs_impl.h:522 doActivate<…>(QObject *, int, void **) 0x0000000105b148f8 QAbstractButtonPrivate::emitClicked() 0x00000001054dc930 QAbstractButtonPrivate::click() 0x00000001054dc7a8 QAbstractButton::mouseReleaseEvent(QMouseEvent *) 0x00000001054dd470 QWidget::event(QEvent *) 0x0000000105445808 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x0000000105407118 QApplication::notify(QObject *, QEvent *) 0x00000001054091c0 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x0000000105ad94c0 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget **, QPointer<…> &, bool, bool) 0x00000001054076b8 QWidgetWindow::handleMouseEvent(QMouseEvent *) 0x0000000105457d3c QWidgetWindow::event(QEvent *) 0x0000000105456fd4 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x0000000105407118 QApplication::notify(QObject *, QEvent *) 0x0000000105407f80 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x0000000105ad94c0 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *) 0x0000000106167120 QWindowSystemInterface::sendWindowSystemEvents(QFlags<…>) 0x00000001061b4118 QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *) 0x0000000104afa534 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 0x000000018bfd7a4c __CFRunLoopDoSource0 0x000000018bfd79e0 __CFRunLoopDoSources0 0x000000018bfd7750 __CFRunLoopRun 0x000000018bfd6340 CFRunLoopRunSpecific 0x000000018bfd59ac RunCurrentEventLoopInMode 0x0000000196584448 ReceiveNextEventCommon 0x00000001965840d8 _BlockUntilNextEventMatchingListInModeWithFilter 0x0000000196583fdc _DPSNextEvent 0x000000018f7b28a4 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] 0x000000018ff8c980 -[NSApplication run] 0x000000018f7a5d50 QCocoaEventDispatcher::processEvents(QFlags<…>) 0x0000000104af898c QEventLoop::exec(QFlags<…>) 0x0000000105ae0c74 QCoreApplication::exec() 0x0000000105ad99c0 main main.cpp:35 start 0x000000018bb790e0