vcl/inc/qt5/QtMenu.hxx | 1 - vcl/qt5/QtMenu.cxx | 41 +++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-)
New commits: commit 74a1f82aebdd9cc05244f7313ff4d06261f3087a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Feb 7 22:52:42 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Feb 8 13:17:46 2025 +0100 qt: Run QtMenu::RemoveMenuBarButton in main thread ... and merge it with QtMenu::ImplRemoveMenuBarButton that it was previously calling. This fixes the below assert that gets triggered when extension updates are available. (In my case, a fake update notification was triggered by forcing it with the changes from demo Gerrit change [1].) #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007fb5a6e9de2f in __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:78 #2 0x00007fb5a6e49d02 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007fb5a6e324f0 in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007fb592902f8d in qAbort () at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:46 #5 0x00007fb592949948 in qt_message_fatal<QString&> (context=..., message=...) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:2062 #6 0x00007fb592942b4d in qt_message (msgType=QtFatalMsg, context=..., msg=0x7fb593090df3 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=0x7fb55fffb4b0) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:342 #7 0x00007fb592944e9d in QMessageLogger::fatal (this=0x7fb55fffb650, msg=0x7fb593090df3 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:831 #8 0x00007fb592903043 in qt_assert_x (where=0x7fb59309a8b9 "QCoreApplication::sendEvent", what=0x5628d475e9f0 "Cannot send events to objects owned by a different thread. Current thread QThread(0x5628d4691800). Receiver 'QWidget(0x5628d4472f70)' was created in thread QThread(0x5628cb7b0e20, name = \"Qt mainThrea"..., file=0x7fb59309a695 "/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp", line=530) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:115 #9 0x00007fb592a490b6 in QCoreApplicationPrivate::checkReceiverThread (receiver=0x5628d4472f70) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:526 #10 0x00007fb5909e4011 in QApplication::notify (this=0x5628cb7b0d60, receiver=0x5628d4472f70, e=0x7fb55fffc2d8) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2590 #11 0x00007fb592a4a8d9 in QCoreApplication::notifyInternal2 (receiver=0x5628d4472f70, event=0x7fb55fffc2d8) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1098 #12 0x00007fb592a4b549 in QCoreApplication::sendEvent (receiver=0x5628d4472f70, event=0x7fb55fffc2d8) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1538 #13 0x00007fb590a8816a in QWidget::~QWidget (this=0x5628d4472f70) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:1569 #14 0x00007fb590c285db in QAbstractButton::~QAbstractButton (this=0x5628d4472f70) at /home/michi/development/git/qt5/qtbase/src/widgets/widgets/qabstractbutton.cpp:453 #15 0x00007fb590da0b89 in QPushButton::~QPushButton (this=0x5628d4472f70) at /home/michi/development/git/qt5/qtbase/src/widgets/widgets/qpushbutton.cpp:250 #16 0x00007fb590da0bcd in QPushButton::~QPushButton (this=0x5628d4472f70) at /home/michi/development/git/qt5/qtbase/src/widgets/widgets/qpushbutton.cpp:249 #17 0x00007fb593a30f8a in QtMenu::ImplRemoveMenuBarButton (this=0x5628d06d8840, nId=2) at vcl/qt6/../qt5/QtMenu.cxx:872 #18 0x00007fb593a315a0 in QtMenu::RemoveMenuBarButton (this=0x5628d06d8840, nId=2) at vcl/qt6/../qt5/QtMenu.cxx:900 #19 0x00007fb59d9af55e in MenuBarWindow::RemoveMenuBarButton (this=0x5628d08cd990, nId=2) at /home/michi/development/git/libreoffice/vcl/source/window/menubarwindow.cxx:1191 #20 0x00007fb59d99b766 in MenuBar::RemoveMenuBarButton (this=0x5628d06e8140, nId=2) at /home/michi/development/git/libreoffice/vcl/source/window/menu.cxx:2720 #21 0x00007fb59d7e6ad0 in MenuBarUpdateIconManager::RemoveMenuBarIcon (this=0x5628d48922e8, pMenuBar=0x5628d06e8140) at /home/michi/development/git/libreoffice/vcl/source/window/bubblewindow.cxx:574 #22 0x00007fb59d7e71d2 in MenuBarUpdateIconManager::RemoveMenuBarIcons (this=0x5628d48922e8) at /home/michi/development/git/libreoffice/vcl/source/window/bubblewindow.cxx:422 #23 0x00007fb59d7e7284 in MenuBarUpdateIconManager::SetShowMenuIcon (this=0x5628d48922e8, bShowMenuIcon=false) at /home/michi/development/git/libreoffice/vcl/source/window/bubblewindow.cxx:435 #24 0x00007fb58e5effc7 in (anonymous namespace)::UpdateCheckUI::setPropertyValue (this=0x5628d4892290, rPropertyName="MenuIconVisible", rValue=uno::Any("boolean": 0 ' at /home/michi/development/git/libreoffice/extensions/source/update/ui/updatecheckui.cxx:215 #25 0x00007fb57cafd80e in UpdateCheck::handleMenuBarUI (this=0x7fb560025d40, rUpdateHandler=rtl::Reference to 0x7fb5600279f0, eState=@0x7fb55fffcc44: UPDATESTATE_NO_UPDATE_AVAIL, suppressBubble=true) at /home/michi/development/git/libreoffice/extensions/source/update/check/updatecheck.cxx:1287 #26 0x00007fb57cafa135 in UpdateCheck::setUIState (this=0x7fb560025d40, eState=UPDATESTATE_NO_UPDATE_AVAIL, suppressBubble=true) at /home/michi/development/git/libreoffice/extensions/source/update/check/updatecheck.cxx:1332 #27 0x00007fb57cafd368 in UpdateCheck::setUpdateInfo (this=0x7fb560025d40, aInfo=...) at /home/michi/development/git/libreoffice/extensions/source/update/check/updatecheck.cxx:1253 #28 0x00007fb57caff7c3 in (anonymous namespace)::UpdateCheckThread::runCheck (this=0x7fb5600269e0, rbExtensionsChecked=@0x7fb55fffd1a7: false) at /home/michi/development/git/libreoffice/extensions/source/update/check/updatecheck.cxx:389 #29 0x00007fb57cafefd3 in (anonymous namespace)::UpdateCheckThread::run (this=0x7fb5600269e0) at /home/michi/development/git/libreoffice/extensions/source/update/check/updatecheck.cxx:508 #30 0x00007fb57cb08a4e in threadFunc (param=0x7fb5600269e0) at include/osl/thread.hxx:189 #31 0x00007fb5a7502ccb in osl_thread_start_Impl (pData=0x7fb5600271b0) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:237 #32 0x00007fb5a6e9c083 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447 #33 0x00007fb5a6f1a5f0 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100 [1] https://gerrit.libreoffice.org/c/core/+/106922 Change-Id: I571ec792bf4f83d61f0bc327199559fc47159dca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181281 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx index 3114bd969442..4eb0fbb4a9e3 100644 --- a/vcl/inc/qt5/QtMenu.hxx +++ b/vcl/inc/qt5/QtMenu.hxx @@ -65,7 +65,6 @@ private: void UpdateActionGroupItem(const QtMenuItem* pSalMenuItem); bool validateQMenuBar() const; QPushButton* ImplAddMenuBarButton(const QIcon& rIcon, const QString& rToolTip, int nId); - void ImplRemoveMenuBarButton(int nId); void connectHelpShortcut(QMenu* pMenu); // set slots that handle signals relevant for help menu void connectHelpSignalSlots(QMenu* pMenu, QtMenuItem* pSalMenuItem); diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index 2992baac9d70..9b45106338cb 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -790,7 +790,7 @@ QPushButton* QtMenu::ImplAddMenuBarButton(const QIcon& rIcon, const QString& rTo QPushButton* pButton = static_cast<QPushButton*>(m_pButtonGroup->button(nId)); if (pButton) - ImplRemoveMenuBarButton(nId); + RemoveMenuBarButton(nId); pButton = new QPushButton(); // we don't want the button to increase the QMenuBar height, so a fixed size square it is @@ -824,24 +824,6 @@ bool QtMenu::AddMenuBarButton(const SalMenuButtonItem& rItem) toQString(rItem.maToolTipText), rItem.mnId); } -void QtMenu::ImplRemoveMenuBarButton(int nId) -{ - if (!validateQMenuBar()) - return; - - assert(m_pButtonGroup); - auto* pButton = m_pButtonGroup->button(nId); - assert(pButton); - QWidget* pWidget = mpQMenuBar->cornerWidget(Qt::TopRightCorner); - assert(pWidget); - QLayout* pLayout = pWidget->layout(); - m_pButtonGroup->removeButton(pButton); - pLayout->removeWidget(pButton); - delete pButton; - - lcl_force_menubar_layout_update(*mpQMenuBar); -} - void QtMenu::connectHelpShortcut(QMenu* pMenu) { assert(pMenu); @@ -865,7 +847,26 @@ void QtMenu::connectHelpSignalSlots(QMenu* pMenu, QtMenuItem* pSalMenuItem) pMenu->setToolTipsVisible(true); } -void QtMenu::RemoveMenuBarButton(sal_uInt16 nId) { ImplRemoveMenuBarButton(nId); } +void QtMenu::RemoveMenuBarButton(sal_uInt16 nId) +{ + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (!validateQMenuBar()) + return; + + assert(m_pButtonGroup); + auto* pButton = m_pButtonGroup->button(nId); + assert(pButton); + QWidget* pWidget = mpQMenuBar->cornerWidget(Qt::TopRightCorner); + assert(pWidget); + QLayout* pLayout = pWidget->layout(); + m_pButtonGroup->removeButton(pButton); + pLayout->removeWidget(pButton); + delete pButton; + + lcl_force_menubar_layout_update(*mpQMenuBar); + }); +} tools::Rectangle QtMenu::GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame* pFrame) {