Skip to content

Commit 74a1f82

Browse files
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 '\000')) 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 <[email protected]>
1 parent 35d1c42 commit 74a1f82

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

vcl/inc/qt5/QtMenu.hxx

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private:
6565
void UpdateActionGroupItem(const QtMenuItem* pSalMenuItem);
6666
bool validateQMenuBar() const;
6767
QPushButton* ImplAddMenuBarButton(const QIcon& rIcon, const QString& rToolTip, int nId);
68-
void ImplRemoveMenuBarButton(int nId);
6968
void connectHelpShortcut(QMenu* pMenu);
7069
// set slots that handle signals relevant for help menu
7170
void connectHelpSignalSlots(QMenu* pMenu, QtMenuItem* pSalMenuItem);

vcl/qt5/QtMenu.cxx

+21-20
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ QPushButton* QtMenu::ImplAddMenuBarButton(const QIcon& rIcon, const QString& rTo
790790

791791
QPushButton* pButton = static_cast<QPushButton*>(m_pButtonGroup->button(nId));
792792
if (pButton)
793-
ImplRemoveMenuBarButton(nId);
793+
RemoveMenuBarButton(nId);
794794

795795
pButton = new QPushButton();
796796
// 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)
824824
toQString(rItem.maToolTipText), rItem.mnId);
825825
}
826826

827-
void QtMenu::ImplRemoveMenuBarButton(int nId)
828-
{
829-
if (!validateQMenuBar())
830-
return;
831-
832-
assert(m_pButtonGroup);
833-
auto* pButton = m_pButtonGroup->button(nId);
834-
assert(pButton);
835-
QWidget* pWidget = mpQMenuBar->cornerWidget(Qt::TopRightCorner);
836-
assert(pWidget);
837-
QLayout* pLayout = pWidget->layout();
838-
m_pButtonGroup->removeButton(pButton);
839-
pLayout->removeWidget(pButton);
840-
delete pButton;
841-
842-
lcl_force_menubar_layout_update(*mpQMenuBar);
843-
}
844-
845827
void QtMenu::connectHelpShortcut(QMenu* pMenu)
846828
{
847829
assert(pMenu);
@@ -865,7 +847,26 @@ void QtMenu::connectHelpSignalSlots(QMenu* pMenu, QtMenuItem* pSalMenuItem)
865847
pMenu->setToolTipsVisible(true);
866848
}
867849

868-
void QtMenu::RemoveMenuBarButton(sal_uInt16 nId) { ImplRemoveMenuBarButton(nId); }
850+
void QtMenu::RemoveMenuBarButton(sal_uInt16 nId)
851+
{
852+
SolarMutexGuard g;
853+
GetQtInstance().RunInMainThread([&] {
854+
if (!validateQMenuBar())
855+
return;
856+
857+
assert(m_pButtonGroup);
858+
auto* pButton = m_pButtonGroup->button(nId);
859+
assert(pButton);
860+
QWidget* pWidget = mpQMenuBar->cornerWidget(Qt::TopRightCorner);
861+
assert(pWidget);
862+
QLayout* pLayout = pWidget->layout();
863+
m_pButtonGroup->removeButton(pButton);
864+
pLayout->removeWidget(pButton);
865+
delete pButton;
866+
867+
lcl_force_menubar_layout_update(*mpQMenuBar);
868+
});
869+
}
869870

870871
tools::Rectangle QtMenu::GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame* pFrame)
871872
{

0 commit comments

Comments
 (0)