vcl/inc/qt5/QtMenu.hxx | 1 vcl/qt5/QtFrame.cxx | 338 +++++++++++++++++------------------ vcl/qt5/QtMenu.cxx | 471 ++++++++++++++++++++++++++----------------------- 3 files changed, 430 insertions(+), 380 deletions(-)
New commits: commit d44bab9b49b29f84b90eece51a1aba22102f30ef Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jan 30 11:47:53 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jan 30 15:55:45 2025 +0100 qt: Ensure QMenu gets destroyed in main thread This fixes this assert triggered when opening the sample doc attachment 198264 from tdf#164460 with the qt6 VCL plugin and running the macro, using a current qtbase git dev build: ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread QThread(0x7fffbc000f50). Receiver 'QWidget(0x555558de1c00)' was created in thread QThread(0x555555564ee0, name = "Qt mainThread")", file /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp, line 530 Thread 24 "DocumentEventNo" received signal SIGABRT, Aborted. [Switching to Thread 0x7fffc4f4f6c0 (LWP 626865)] __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 warning: 44 ./nptl/pthread_kill.c: No such file or directory (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff789de2f in __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:78 #2 0x00007ffff7849d02 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff78324f0 in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007fffe3302efd in qAbort () at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:46 #5 0x00007fffe3349788 in qt_message_fatal<QString&> (context=..., message=...) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:2062 #6 0x00007fffe334298d in qt_message (msgType=QtFatalMsg, context=..., msg=0x7fffe3a8edf3 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=0x7fffc4f41650) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:342 #7 0x00007fffe3344cdd in QMessageLogger::fatal (this=0x7fffc4f417f0, msg=0x7fffe3a8edf3 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:831 #8 0x00007fffe3302fb3 in qt_assert_x (where=0x7fffe3a98873 "QCoreApplication::sendEvent", what=0x7fff60309060 "Cannot send events to objects owned by a different thread. Current thread QThread(0x7fffbc000f50). Receiver 'QWidget(0x555558de1c00)' was created in thread QThread(0x555555564ee0, name = \"Qt mainThrea"..., file=0x7fffe3a9864f "/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 0x00007fffe3447d56 in QCoreApplicationPrivate::checkReceiverThread (receiver=0x555558de1c00) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:526 #10 0x00007fffe13e3f91 in QApplication::notify (this=0x555555564e20, receiver=0x555558de1c00, e=0x7fffc4f42478) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2590 #11 0x00007fffe3449dc9 in QCoreApplication::notifyInternal2 (receiver=0x555558de1c00, event=0x7fffc4f42478) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1112 #12 0x00007fffe344aa39 in QCoreApplication::sendEvent (receiver=0x555558de1c00, event=0x7fffc4f42478) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1552 #13 0x00007fffe148741a in QWidget::~QWidget (this=0x555558de1c00) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:1569 #14 0x00007fffe1780ab3 in QMenu::~QMenu (this=0x555558de1c00) at /home/michi/development/git/qt5/qtbase/src/widgets/widgets/qmenu.cpp:1798 #15 0x00007fffe1780b7d in QMenu::~QMenu (this=0x555558de1c00) at /home/michi/development/git/qt5/qtbase/src/widgets/widgets/qmenu.cpp:1782 #16 0x00007fffe443bf08 in std::default_delete<QMenu>::operator() (this=0x555558de18d8, __ptr=0x555558de1c00) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:93 #17 0x00007fffe443bd5f in std::unique_ptr<QMenu, std::default_delete<QMenu> >::~unique_ptr (this=0x555558de18d8) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:399 #18 0x00007fffe44379fc in QtMenu::~QtMenu (this=0x555558de1860) at vcl/inc/qt6/../qt5/QtMenu.hxx:40 #19 0x00007fffe4437a59 in QtMenu::~QtMenu (this=0x555558de1860) at vcl/inc/qt6/../qt5/QtMenu.hxx:40 #20 0x00007fffee3b8ce8 in std::default_delete<SalMenu>::operator() (this=0x7fff6030d320, __ptr=0x555558de1870) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:93 #21 0x00007fffee3b8c28 in std::__uniq_ptr_impl<SalMenu, std::default_delete<SalMenu> >::reset (this=0x7fff6030d320, __p=0x0) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:205 #22 0x00007fffee3b1a2d in std::unique_ptr<SalMenu, std::default_delete<SalMenu> >::reset (this=0x7fff6030d320, __p=0x0) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:504 #23 0x00007fffee3a27b8 in Menu::dispose (this=0x7fff6030d210) at /home/michi/development/git/libreoffice/vcl/source/window/menu.cxx:225 #24 0x00007fffee7122a3 in VclReferenceBase::disposeOnce (this=0x7fff6030d210) at /home/michi/development/git/libreoffice/vcl/source/outdev/vclreferencebase.cxx:38 #25 0x00007fffee283ddb in VclPtr<PopupMenu>::disposeAndClear (this=0x7fff60310ba8) at include/vcl/vclptr.hxx:207 #26 0x00007fffeebdba5c in SalInstanceMenu::~SalInstanceMenu (this=0x7fff60310b80) at /home/michi/development/git/libreoffice/vcl/source/app/salvtables.cxx:974 #27 0x00007fffeebdbab9 in SalInstanceMenu::~SalInstanceMenu (this=0x7fff60310b80) at /home/michi/development/git/libreoffice/vcl/source/app/salvtables.cxx:971 #28 0x00007ffff275023b in std::default_delete<weld::Menu>::operator() (this=0x7fffc4f42960, __ptr=0x7fff60310b80) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:93 #29 0x00007ffff273552f in std::unique_ptr<weld::Menu, std::default_delete<weld::Menu> >::~unique_ptr (this=0x7fffc4f42960) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:399 #30 0x00007ffff2a300fd in (anonymous namespace)::SelectionTypePopup::~SelectionTypePopup (this=0x7fffc4f42950) at /home/michi/development/git/libreoffice/svx/source/stbctrls/selctrl.cxx:48 #31 0x00007ffff2a2fd68 in SvxSelectionModeControl::StateChangedAtStatusBarControl (this=0x7fff602fa6b0, eState=SfxItemState::DEFAULT, pState=0x7fff6025c330) at /home/michi/development/git/libreoffice/svx/source/stbctrls/selctrl.cxx:130 #32 0x00007ffff419db7e in SfxStatusBarControl::statusChanged (this=0x7fff602fa6b0, rEvent=...) at /home/michi/development/git/libreoffice/sfx2/source/statbar/stbitem.cxx:263 #33 0x00007ffff3c9f158 in SfxDispatchController_Impl::addStatusListener (this=0x7fff601c92c0, aListener=uno::Reference to (SvxSelectionModeControl *) 0x7fff602fa6c0, aURL=...) at /home/michi/development/git/libreoffice/sfx2/source/control/unoctitm.cxx:841 #34 0x00007ffff3c9ee04 in SfxOfficeDispatch::addStatusListener (this=0x7fff6030bd90, aListener=uno::Reference to (SvxSelectionModeControl *) 0x7fff602fa6c0, aURL=...) at /home/michi/development/git/libreoffice/sfx2/source/control/unoctitm.cxx:283 #35 0x00007ffff0aa6737 in svt::StatusbarController::bindListener (this=0x7fff602fa6b0) at /home/michi/development/git/libreoffice/svtools/source/uno/statusbarcontroller.cxx:462 #36 0x00007ffff0aa60c9 in svt::StatusbarController::update (this=0x7fff602fa6b0) at /home/michi/development/git/libreoffice/svtools/source/uno/statusbarcontroller.cxx:169 #37 0x00007ffff4f4242b in framework::(anonymous namespace)::lcl_UpdateController<std::__debug::map<unsigned short, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController>, std::less<unsigned short>, std::allocator<std::pair<unsigned short const, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController> > > > >::operator() (this=0x7fffc4f43117, rElement={...}) at /home/michi/development/git/libreoffice/framework/source/uielement/statusbarmanager.cxx:69 #38 0x00007ffff4f3efaf in std::for_each<__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<unsigned short const, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController> > >, std::__debug::map<unsigned short, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController>, std::less<unsigned short>, std::allocator<std::pair<unsigned short const, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController> > > >, std::bidirectional_iterator_tag>, framework::(anonymous namespace)::lcl_UpdateController<std::__debug::map<unsigned short, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController>, std::less<unsigned short>, std::allocator<std::pair<unsigned short const, com::sun::star::uno::Reference<com::sun::star::frame::XStatusbarController> > > > > > (__first={...}, __last={...}, __f=...) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_algo.h:3786 #39 0x00007ffff4f3e365 in framework::StatusBarManager::UpdateControllers (this=0x7fff602ccc10) at /home/michi/development/git/libreoffice/framework/source/uielement/statusbarmanager.cxx:269 #40 0x00007ffff4f40c4b in framework::StatusBarManager::FillStatusBar (this=0x7fff602ccc10, rItemContainer=uno::Reference to (framework::ConstItemContainer *) 0x7fff6029b8c8) at /home/michi/development/git/libreoffice/framework/source/uielement/statusbarmanager.cxx:479 #41 0x00007ffff4f4b7f8 in framework::StatusBarWrapper::initialize (this=0x7fff602d1320, aArguments=uno::Sequence of length 4 = {...}) at /home/michi/development/git/libreoffice/framework/source/uielement/statusbarwrapper.cxx:117 #42 0x00007ffff4ff9ac4 in framework::MenuBarFactory::CreateUIElement [...] Change-Id: I787bb74644dcf29ccbd6c7a59fe5ca9fc7a50061 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180938 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 bbabb59e4ebd..09cd015463cd 100644 --- a/vcl/inc/qt5/QtMenu.hxx +++ b/vcl/inc/qt5/QtMenu.hxx @@ -72,6 +72,7 @@ private: public: QtMenu(bool bMenuBar); + ~QtMenu(); bool eventFilter(QObject* pObject, QEvent* pEvent) override; diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index ca04d8f084ba..c9c98456a921 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -984,6 +984,12 @@ int QtMenu::GetMenuBarHeight() const return mpQMenuBar->height(); } +QtMenu::~QtMenu() +{ + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { mpOwnedQMenu.reset(); }); +} + QtMenuItem::QtMenuItem(const SalItemParams* pItemData) : mpParentMenu(nullptr) , mpSubMenu(nullptr) commit 6afa3931f0aa8141ff1c5ba4bbbe6e30bef58069 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jan 30 11:38:52 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jan 30 15:55:38 2025 +0100 qt: Ensure more methods are run in main thread This fixes various asserts triggered when opening the sample doc attachment 198264 from tdf#164460 with the qt6 VCL plugin and using a current qtbase git dev build, for example: ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread QThread(0x7fffbc000f50). Receiver 'QWidgetWindow(0x555556dd9f10, name = "QtMainWindowClassWindow")' was created in thread QThread(0x555555564ee0, name = "Qt mainThread")", file /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp, line 530 Thread 24 "DocumentEventNo" received signal SIGABRT, Aborted. [Switching to Thread 0x7fffc4f4f6c0 (LWP 625101)] __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 warning: 44 ./nptl/pthread_kill.c: No such file or directory (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff789de2f in __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:78 #2 0x00007ffff7849d02 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff78324f0 in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007fffe3302efd in qAbort () at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:46 #5 0x00007fffe3349788 in qt_message_fatal<QString&> (context=..., message=...) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:2062 #6 0x00007fffe334298d in qt_message (msgType=QtFatalMsg, context=..., msg=0x7fffe3a8edf3 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=0x7fffc4f478f0) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:342 #7 0x00007fffe3344cdd in QMessageLogger::fatal (this=0x7fffc4f47a90, msg=0x7fffe3a8edf3 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:831 #8 0x00007fffe3302fb3 in qt_assert_x (where=0x7fffe3a98873 "QCoreApplication::sendEvent", what=0x7fffbc000c00 "Cannot send events to objects owned by a different thread. Current thread QThread(0x7fffbc000f50). Receiver 'QWidgetWindow(0x555556dd9f10, name = \"QtMainWindowClassWindow\")' was created in thread QThr"..., file=0x7fffe3a9864f "/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 0x00007fffe3447d56 in QCoreApplicationPrivate::checkReceiverThread (receiver=0x555556dd9f10) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:526 #10 0x00007fffe13e3f91 in QApplication::notify (this=0x555555564e20, receiver=0x555556dd9f10, e=0x7fffc4f486a0) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2590 #11 0x00007fffe3449dc9 in QCoreApplication::notifyInternal2 (receiver=0x555556dd9f10, event=0x7fffc4f486a0) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1112 #12 0x00007fffe344aa39 in QCoreApplication::sendEvent (receiver=0x555556dd9f10, event=0x7fffc4f486a0) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1552 #13 0x00007fffe235f1ff in QWindowPrivate::setCursor (this=0x5555571f48a0, newCursor=0x7fffc4f48770) at /home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindow.cpp:3269 #14 0x00007fffe235f0ce in QWindow::setCursor (this=0x555556dd9f10, cursor=...) at /home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindow.cpp:3227 #15 0x00007fffe1492921 in applyCursor (w=0x555556e5d360, c=...) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:5020 #16 0x00007fffe148e6e4 in qt_qpa_set_cursor (w=0x55555707ea30, force=false) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:5058 #17 0x00007fffe14927cc in QWidgetPrivate::setCursor_sys (this=0x555556e37f10, cursor=...) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:4995 #18 0x00007fffe149274e in QWidget::setCursor (this=0x55555707ea30, cursor=...) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:4985 #19 0x00007fffe43493b8 in QtFrame::SetPointer (this=0x555556dc14c0, ePointerStyle=PointerStyle::Wait) at vcl/qt6/../qt5/QtFrame.cxx:794 #20 0x00007fffee3db06e in vcl::Window::EnterWait (this=0x555556df3620) at /home/michi/development/git/libreoffice/vcl/source/window/mouse.cxx:614 #21 0x00007fffeebd9b16 in SalInstanceWidget::set_busy_cursor (this=0x5555575c9520, bBusy=true) at /home/michi/development/git/libreoffice/vcl/source/app/salvtables.cxx:625 #22 0x00007fffa505266a in weld::WaitObject::WaitObject (this=0x7fffc4f48a48, pWindow=0x5555575c9560) at include/vcl/weld.hxx:611 #23 0x00007fffa504c0b1 in dbaui::OApplicationController::ensureConnection (this=0x555556e115f0, _pErrorInfo=0x7fffc4f48b48) at /home/michi/development/git/libreoffice/dbaccess/source/ui/app/AppControllerDnD.cxx:310 #24 0x00007fffa505f75a in dbaui::OApplicationController::connect (this=0x555556e115f0) at /home/michi/development/git/libreoffice/dbaccess/source/ui/app/AppControllerGen.cxx:316 #25 0x00007fffe0b370ed in gcc3::callVirtualMethod (pThis=0x555556e11968, nVtableIndex=8, pRegisterReturn=0x0, pReturnTypeRef=0x555555604370, bSimpleReturn=true, pStack=0x7fffc4f48c70, nStack=0, pGPR=0x7fffc4f48f40, pFPR=0x7fffc4f48f00) at /home/michi/development/git/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:87 #26 0x00007fffe0b35e5b in cpp_call (pThis=0x7fffbc2af2e0, aVtableSlot=..., pReturnTypeRef=0x555555604370, nParams=0, pParams=0x0, pUnoReturn=0x0, pUnoArgs=0x7fffc4f490c0, ppUnoExc=0x7fffc4f49370) at /home/michi/development/git/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:229 #27 0x00007fffe0b35626 in unoInterfaceProxyDispatch (pUnoI=0x7fffbc2af2e0, pMemberDescr=0x7fffbc2b0bd0, pReturn=0x0, pArgs=0x7fffc4f490c0, ppException=0x7fffc4f49370) at /home/michi/development/git/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:409 #28 0x00007fffb6fe565a in stoc_corefl::(anonymous namespace)::IdlInterfaceMethodImpl::invoke (this=0x7fffbc2b33d0, rObj=uno::Any("com.sun.star.frame.XController": ...), rArgs=empty uno::Sequence) at /home/michi/development/git/libreoffice/stoc/source/corereflection/criface.cxx:591 #29 0x00007fffb6fe5e74 in non-virtual thunk to stoc_corefl::(anonymous namespace)::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) () at /home/michi/development/git/libreoffice/instdir/program/libreflectionlo.so #30 0x00007ffff4618bde in SbUnoObject::Notify (this=0x7fffbc29fea0, rBC=..., rHint=...) at /home/michi/development/git/libreoffice/basic/source/classes/sbunoobj.cxx:2249 #31 0x00007ffff3151a4c in SfxBroadcaster::Broadcast (this=0x7fffbc2b5480, rHint=...) at /home/michi/development/git/libreoffice/svl/source/notify/SfxBroadcaster.cxx:43 #32 0x00007ffff47c7ad4 in SbxVariable::Broadcast (this=0x7fffbc2b5990, nHintId=SfxHintId::BasicDataWanted) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxvar.cxx:154 #33 0x00007ffff47c04fd in SbxValue::SbxValue (this=0x7fffbc2808c0, vtt=0x7ffff47eb6d0 <VTT for SbxMethod+16>, r=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxvalue.cxx:68 #34 0x00007ffff47c6674 in SbxVariable::SbxVariable (this=0x7fffbc2808c0, vtt=0x7ffff47eb6c8 <VTT for SbxMethod+8>, r=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxvar.cxx:48 #35 0x00007ffff47b6f4a in SbxMethod::SbxMethod (this=0x7fffbc2808c0, r=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxobj.cxx:842 #36 0x00007ffff477782a in SbiRuntime::FindElement (this=0x7fffbc1bfb00, pObj=0x7fffbc29fea0, nOp1=75, nOp2=12, nNotFound=..., bLocal=false, bStatic=false) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:3701 #37 0x00007ffff476adc2 in SbiRuntime::StepELEM (this=0x7fffbc1bfb00, nOp1=75, nOp2=12) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:4187 #38 0x00007ffff476fa77 in SbiRuntime::Step (this=0x7fffbc1bfb00) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:808 #39 0x00007ffff46638c9 in (anonymous namespace)::RunInitGuard::run (this=0x7fffc4f4a4c0) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:1017 #40 0x00007ffff466262d in SbModule::Run (this=0x7fffbc093b00, pMeth=0x7fffbc16d040) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:1177 #41 0x00007ffff4661b41 in SbModule::Notify (this=0x7fffbc093b00, rBC=..., rHint=...) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:775 #42 0x00007ffff3151a4c in SfxBroadcaster::Broadcast (this=0x7fffbc094fb0, rHint=...) at /home/michi/development/git/libreoffice/svl/source/notify/SfxBroadcaster.cxx:43 #43 0x00007ffff466879b in SbMethod::Broadcast (this=0x7fffbc095060, nHintId=SfxHintId::BasicDataWanted) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:2115 #44 0x00007ffff47c04fd in SbxValue::SbxValue (this=0x7fffbc1b9590, vtt=0x7ffff47eb6d0 <VTT for SbxMethod+16>, r=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxvalue.cxx:68 #45 0x00007ffff47c6674 in SbxVariable::SbxVariable (this=0x7fffbc1b9590, vtt=0x7ffff47eb6c8 <VTT for SbxMethod+8>, r=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxvar.cxx:48 #46 0x00007ffff47b6f4a in SbxMethod::SbxMethod (this=0x7fffbc1b9590, r=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxobj.cxx:842 #47 0x00007ffff477782a in SbiRuntime::FindElement (this=0x7fffbc16d360, pObj=0x7fffbc093b00, nOp1=10, nOp2=0, nNotFound=..., bLocal=true, bStatic=false) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:3701 #48 0x00007ffff4778e95 in SbiRuntime::StepFIND_Impl (this=0x7fffbc16d360, pObj=0x7fffbc093b00, nOp1=10, nOp2=0, nNotFound=..., bStatic=false) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:4134 #49 0x00007ffff476ac0d in SbiRuntime::StepFIND (this=0x7fffbc16d360, nOp1=10, nOp2=0) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:4140 #50 0x00007ffff476fa77 in SbiRuntime::Step (this=0x7fffbc16d360) at /home/michi/development/git/libreoffice/basic/source/runtime/runtime.cxx:808 #51 0x00007ffff46638c9 in (anonymous namespace)::RunInitGuard::run (this=0x7fffc4f4b3c0) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:1017 #52 0x00007ffff466262d in SbModule::Run (this=0x7fffbc093b00, pMeth=0x7fffbc162760) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:1177 #53 0x00007ffff4661b41 in SbModule::Notify (this=0x7fffbc093b00, rBC=..., rHint=...) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:775 #54 0x00007ffff3151a4c in SfxBroadcaster::Broadcast (this=0x7fffbc093f10, rHint=...) at /home/michi/development/git/libreoffice/svl/source/notify/SfxBroadcaster.cxx:43 #55 0x00007ffff466879b in SbMethod::Broadcast (this=0x7fffbc0938c0, nHintId=SfxHintId::BasicDataWanted) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:2115 #56 0x00007ffff47c0ef3 in SbxValue::Get (this=0x7fffbc0938c0, rRes=...) at /home/michi/development/git/libreoffice/basic/source/sbx/sbxvalue.cxx:290 #57 0x00007ffff466848b in SbMethod::Call (this=0x7fffbc0938c0, pRet=0x7fffbc156ef0, pCaller=0x0) at /home/michi/development/git/libreoffice/basic/source/classes/sbxmod.cxx:2071 #58 0x00007fffdc9f4cfe in basprov::BasicScriptImpl::invoke (this=0x7fffbc012bd0, aParams=uno::Sequence of length 1 = {...}, aOutParamIndex=empty uno::Sequence, aOutParam=empty uno::Sequence) at /home/michi/development/git/libreoffice/scripting/source/basprov/basscript.cxx:262 #59 0x00007fffdc9f54ac in non-virtual thunk to basprov::BasicScriptImpl::invoke(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, com::sun::star::uno::Sequence<short>&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) () at /home/michi/development/git/libreoffice/instdir/program/../program/libbasprovlo.so #60 0x00007fffdffeedc7 in scripting_protocolhandler::ScriptProtocolHandler::dispatchWithNotification (this=0x7fffbc002330, aURL=..., lArgs=uno::Sequence of length 1 = {...}, xListener=empty uno::Reference) at /home/michi/development/git/libreoffice/scripting/source/protocolhandler/scripthandler.cxx:213 #61 0x00007fffdfff02ef in scripting_protocolhandler::ScriptProtocolHandler::dispatch (this=0x7fffbc002330, aURL=..., lArgs=uno::Sequence of length 1 = {...}) at /home/michi/development/git/libreoffice/scripting/source/protocolhandler/scripthandler.cxx:286 #62 0x00007fffc6f7d166 in dbaccess::(anonymous namespace)::lcl_dispatchScriptURL_throw (xWeakDocument=..., xURLTransformer=uno::Reference to ((anonymous namespace)::URLTransformer *) 0x555557223d28, _rScriptURL="vnd.sun.star.script:Standard.Backup.DatabaseStart?language=Basic&location=document", _rTrigger=...) at /home/michi/development/git/libreoffice/dbaccess/source/core/dataaccess/documenteventexecutor.cxx:100 #63 0x00007fffc6f7cbe6 in dbaccess::DocumentEventExecutor::documentEventOccured (this=0x55555721f030, Event=...) at /home/michi/development/git/libreoffice/dbaccess/source/core/dataaccess/documenteventexecutor.cxx:169 #64 0x00007fffc6f8dfb7 in comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent>::operator() (this=0x7fffc4f4d220, listener=uno::Reference to (dbaccess::DocumentEventExecutor *) 0x55555721f058) at include/comphelper/interfacecontainer3.hxx:249 #65 0x00007fffc6f8dd45 in comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::forEach<comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent> > (this=0x55555721f368, func=...) at include/comphelper/interfacecontainer3.hxx:275 #66 0x00007fffc6f7fd33 in comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::notifyEach<com::sun::star::document::DocumentEvent> (this=0x55555721f368, NotificationMethod=&virtual table offset 32, Event=...) at include/comphelper/interfacecontainer3.hxx:290 #67 0x00007fffc6f7f007 in dbaccess::DocumentEventNotifier_Impl::impl_notifyEvent_nothrow (this=0x55555721f320, _rEvent=...) at /home/michi/development/git/libreoffice/dbaccess/source/core/dataaccess/documenteventnotifier.cxx:197 #68 0x00007fffc6f7f3b9 in dbaccess::DocumentEventNotifier_Impl::processEvent (this=0x55555721f320, _rEvent=...) at /home/michi/development/git/libreoffice/dbaccess/source/core/dataaccess/documenteventnotifier.cxx:230 #69 0x00007ffff6119f47 in comphelper::AsyncEventNotifierBase::execute (this=0x5555575b4de0) at /home/michi/development/git/libreoffice/comphelper/source/misc/asyncnotification.cxx:139 #70 0x00007ffff611b074 in comphelper::AsyncEventNotifierAutoJoin::run (this=0x5555575b4de0) at /home/michi/development/git/libreoffice/comphelper/source/misc/asyncnotification.cxx:246 #71 0x00007ffff612743e in threadFunc (param=0x5555575b4df0) at include/osl/thread.hxx:189 #72 0x00007ffff7fa2ccb in osl_thread_start_Impl (pData=0x5555575a22b0) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:237 #73 0x00007ffff789c083 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447 #74 0x00007ffff791a7b8 in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78 Change-Id: I0ee7aa62893da92b886acfd3d47be0bdb10d6007 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180937 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 4d76a3154ca3..ff87fec1a642 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -787,11 +787,14 @@ void QtFrame::ToTop(SalFrameToTop nFlags) void QtFrame::SetPointer(PointerStyle ePointerStyle) { - if (ePointerStyle == m_ePointerStyle) - return; - m_ePointerStyle = ePointerStyle; + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (ePointerStyle == m_ePointerStyle) + return; + m_ePointerStyle = ePointerStyle; - m_pQWidget->setCursor(GetQtData()->getCursor(ePointerStyle)); + m_pQWidget->setCursor(GetQtData()->getCursor(ePointerStyle)); + }); } void QtFrame::CaptureMouse(bool bMouse) @@ -1062,177 +1065,182 @@ static bool toVclFont(const QFont& rQFont, const css::lang::Locale& rLocale, vcl void QtFrame::UpdateSettings(AllSettings& rSettings) { - if (QtData::noNativeControls()) - return; - QtCustomStyle::LoadCustomStyle(GetUseDarkMode()); - - StyleSettings style(rSettings.GetStyleSettings()); - const css::lang::Locale aLocale = rSettings.GetUILanguageTag().getLocale(); - - // General settings - QPalette pal = QApplication::palette(); - - style.SetToolbarIconSize(ToolbarIconSize::Large); - - Color aFore = toColor(pal.color(QPalette::Active, QPalette::WindowText)); - Color aBack = toColor(pal.color(QPalette::Active, QPalette::Window)); - Color aText = toColor(pal.color(QPalette::Active, QPalette::Text)); - Color aBase = toColor(pal.color(QPalette::Active, QPalette::Base)); - Color aButn = toColor(pal.color(QPalette::Active, QPalette::ButtonText)); - Color aMid = toColor(pal.color(QPalette::Active, QPalette::Mid)); - Color aHigh = toColor(pal.color(QPalette::Active, QPalette::Highlight)); - Color aHighText = toColor(pal.color(QPalette::Active, QPalette::HighlightedText)); - Color aLink = toColor(pal.color(QPalette::Active, QPalette::Link)); - Color aVisitedLink = toColor(pal.color(QPalette::Active, QPalette::LinkVisited)); - - style.SetSkipDisabledInMenus(true); - - // Foreground - style.SetRadioCheckTextColor(aFore); - style.SetLabelTextColor(aFore); - style.SetDialogTextColor(aFore); - style.SetGroupTextColor(aFore); - - // Text - style.SetFieldTextColor(aText); - style.SetFieldRolloverTextColor(aText); - style.SetListBoxWindowTextColor(aText); - style.SetWindowTextColor(aText); - style.SetToolTextColor(aText); - - // Base - style.SetFieldColor(aBase); - style.SetActiveTabColor(aBase); - style.SetListBoxWindowBackgroundColor(aBase); - style.SetAlternatingRowColor(toColor(pal.color(QPalette::Active, QPalette::AlternateBase))); - - // Buttons - style.SetDefaultButtonTextColor(aButn); - style.SetButtonTextColor(aButn); - style.SetDefaultActionButtonTextColor(aButn); - style.SetActionButtonTextColor(aButn); - style.SetFlatButtonTextColor(aButn); - style.SetDefaultButtonRolloverTextColor(aButn); - style.SetButtonRolloverTextColor(aButn); - style.SetDefaultActionButtonRolloverTextColor(aButn); - style.SetActionButtonRolloverTextColor(aButn); - style.SetFlatButtonRolloverTextColor(aButn); - style.SetDefaultButtonPressedRolloverTextColor(aButn); - style.SetButtonPressedRolloverTextColor(aButn); - style.SetDefaultActionButtonPressedRolloverTextColor(aButn); - style.SetActionButtonPressedRolloverTextColor(aButn); - style.SetFlatButtonPressedRolloverTextColor(aButn); - - // Tabs - style.SetTabTextColor(aButn); - style.SetTabRolloverTextColor(aButn); - style.SetTabHighlightTextColor(aButn); - - // Disable color - style.SetDisableColor(toColor(pal.color(QPalette::Disabled, QPalette::WindowText))); - - // Background - style.BatchSetBackgrounds(aBack); - style.SetInactiveTabColor(aBack); - style.SetWindowColor(aBack); - - // Workspace - style.SetWorkspaceColor(aMid); - - // Selection - // https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/305 - style.SetAccentColor(aHigh); - style.SetHighlightColor(aHigh); - style.SetHighlightTextColor(aHighText); - style.SetListBoxWindowHighlightColor(aHigh); - style.SetListBoxWindowHighlightTextColor(aHighText); - style.SetActiveColor(aHigh); - style.SetActiveTextColor(aHighText); - - // Links - style.SetLinkColor(aLink); - style.SetVisitedLinkColor(aVisitedLink); - - // Tooltip - style.SetHelpColor(toColor(QToolTip::palette().color(QPalette::Active, QPalette::ToolTipBase))); - style.SetHelpTextColor( - toColor(QToolTip::palette().color(QPalette::Active, QPalette::ToolTipText))); - - // Menu - std::unique_ptr<QMenuBar> pMenuBar = std::make_unique<QMenuBar>(); - QPalette qMenuCG = pMenuBar->palette(); - - // Menu text and background color, theme specific - Color aMenuFore = toColor(qMenuCG.color(QPalette::WindowText)); - Color aMenuBack = toColor(qMenuCG.color(QPalette::Window)); - - style.SetMenuTextColor(aMenuFore); - style.SetMenuBarTextColor(aMenuFore); - style.SetMenuColor(aMenuBack); - style.SetMenuBarColor(aMenuBack); - style.SetMenuHighlightColor(toColor(qMenuCG.color(QPalette::Highlight))); - style.SetMenuHighlightTextColor(toColor(qMenuCG.color(QPalette::HighlightedText))); - - // set special menubar highlight text color - if (QApplication::style()->inherits("HighContrastStyle")) - ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor - = toColor(qMenuCG.color(QPalette::HighlightedText)); - else - ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (QtData::noNativeControls()) + return; + QtCustomStyle::LoadCustomStyle(GetUseDarkMode()); + + StyleSettings style(rSettings.GetStyleSettings()); + const css::lang::Locale aLocale = rSettings.GetUILanguageTag().getLocale(); + + // General settings + QPalette pal = QApplication::palette(); + + style.SetToolbarIconSize(ToolbarIconSize::Large); + + Color aFore = toColor(pal.color(QPalette::Active, QPalette::WindowText)); + Color aBack = toColor(pal.color(QPalette::Active, QPalette::Window)); + Color aText = toColor(pal.color(QPalette::Active, QPalette::Text)); + Color aBase = toColor(pal.color(QPalette::Active, QPalette::Base)); + Color aButn = toColor(pal.color(QPalette::Active, QPalette::ButtonText)); + Color aMid = toColor(pal.color(QPalette::Active, QPalette::Mid)); + Color aHigh = toColor(pal.color(QPalette::Active, QPalette::Highlight)); + Color aHighText = toColor(pal.color(QPalette::Active, QPalette::HighlightedText)); + Color aLink = toColor(pal.color(QPalette::Active, QPalette::Link)); + Color aVisitedLink = toColor(pal.color(QPalette::Active, QPalette::LinkVisited)); + + style.SetSkipDisabledInMenus(true); + + // Foreground + style.SetRadioCheckTextColor(aFore); + style.SetLabelTextColor(aFore); + style.SetDialogTextColor(aFore); + style.SetGroupTextColor(aFore); + + // Text + style.SetFieldTextColor(aText); + style.SetFieldRolloverTextColor(aText); + style.SetListBoxWindowTextColor(aText); + style.SetWindowTextColor(aText); + style.SetToolTextColor(aText); + + // Base + style.SetFieldColor(aBase); + style.SetActiveTabColor(aBase); + style.SetListBoxWindowBackgroundColor(aBase); + style.SetAlternatingRowColor(toColor(pal.color(QPalette::Active, QPalette::AlternateBase))); + + // Buttons + style.SetDefaultButtonTextColor(aButn); + style.SetButtonTextColor(aButn); + style.SetDefaultActionButtonTextColor(aButn); + style.SetActionButtonTextColor(aButn); + style.SetFlatButtonTextColor(aButn); + style.SetDefaultButtonRolloverTextColor(aButn); + style.SetButtonRolloverTextColor(aButn); + style.SetDefaultActionButtonRolloverTextColor(aButn); + style.SetActionButtonRolloverTextColor(aButn); + style.SetFlatButtonRolloverTextColor(aButn); + style.SetDefaultButtonPressedRolloverTextColor(aButn); + style.SetButtonPressedRolloverTextColor(aButn); + style.SetDefaultActionButtonPressedRolloverTextColor(aButn); + style.SetActionButtonPressedRolloverTextColor(aButn); + style.SetFlatButtonPressedRolloverTextColor(aButn); + + // Tabs + style.SetTabTextColor(aButn); + style.SetTabRolloverTextColor(aButn); + style.SetTabHighlightTextColor(aButn); + + // Disable color + style.SetDisableColor(toColor(pal.color(QPalette::Disabled, QPalette::WindowText))); + + // Background + style.BatchSetBackgrounds(aBack); + style.SetInactiveTabColor(aBack); + style.SetWindowColor(aBack); + + // Workspace + style.SetWorkspaceColor(aMid); + + // Selection + // https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/305 + style.SetAccentColor(aHigh); + style.SetHighlightColor(aHigh); + style.SetHighlightTextColor(aHighText); + style.SetListBoxWindowHighlightColor(aHigh); + style.SetListBoxWindowHighlightTextColor(aHighText); + style.SetActiveColor(aHigh); + style.SetActiveTextColor(aHighText); + + // Links + style.SetLinkColor(aLink); + style.SetVisitedLinkColor(aVisitedLink); + + // Tooltip + style.SetHelpColor( + toColor(QToolTip::palette().color(QPalette::Active, QPalette::ToolTipBase))); + style.SetHelpTextColor( + toColor(QToolTip::palette().color(QPalette::Active, QPalette::ToolTipText))); + + // Menu + std::unique_ptr<QMenuBar> pMenuBar = std::make_unique<QMenuBar>(); + QPalette qMenuCG = pMenuBar->palette(); + + // Menu text and background color, theme specific + Color aMenuFore = toColor(qMenuCG.color(QPalette::WindowText)); + Color aMenuBack = toColor(qMenuCG.color(QPalette::Window)); + + style.SetMenuTextColor(aMenuFore); + style.SetMenuBarTextColor(aMenuFore); + style.SetMenuColor(aMenuBack); + style.SetMenuBarColor(aMenuBack); + style.SetMenuHighlightColor(toColor(qMenuCG.color(QPalette::Highlight))); + style.SetMenuHighlightTextColor(toColor(qMenuCG.color(QPalette::HighlightedText))); + + // set special menubar highlight text color + if (QApplication::style()->inherits("HighContrastStyle")) + ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor + = toColor(qMenuCG.color(QPalette::HighlightedText)); + else + ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; - // set menubar rollover color - if (pMenuBar->style()->styleHint(QStyle::SH_MenuBar_MouseTracking)) - { - style.SetMenuBarRolloverColor(toColor(qMenuCG.color(QPalette::Highlight))); - style.SetMenuBarRolloverTextColor(ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor); - } - else - { - style.SetMenuBarRolloverColor(aMenuBack); - style.SetMenuBarRolloverTextColor(aMenuFore); - } - style.SetMenuBarHighlightTextColor(style.GetMenuHighlightTextColor()); + // set menubar rollover color + if (pMenuBar->style()->styleHint(QStyle::SH_MenuBar_MouseTracking)) + { + style.SetMenuBarRolloverColor(toColor(qMenuCG.color(QPalette::Highlight))); + style.SetMenuBarRolloverTextColor( + ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor); + } + else + { + style.SetMenuBarRolloverColor(aMenuBack); + style.SetMenuBarRolloverTextColor(aMenuFore); + } + style.SetMenuBarHighlightTextColor(style.GetMenuHighlightTextColor()); - // Default fonts - vcl::Font aFont; - if (toVclFont(QApplication::font(), aLocale, aFont)) - { - style.BatchSetFonts(aFont, aFont); - aFont.SetWeight(WEIGHT_BOLD); - style.SetTitleFont(aFont); - style.SetFloatTitleFont(aFont); - } + // Default fonts + vcl::Font aFont; + if (toVclFont(QApplication::font(), aLocale, aFont)) + { + style.BatchSetFonts(aFont, aFont); + aFont.SetWeight(WEIGHT_BOLD); + style.SetTitleFont(aFont); + style.SetFloatTitleFont(aFont); + } - // Tooltip font - if (toVclFont(QToolTip::font(), aLocale, aFont)) - style.SetHelpFont(aFont); + // Tooltip font + if (toVclFont(QToolTip::font(), aLocale, aFont)) + style.SetHelpFont(aFont); - // Menu bar font - if (toVclFont(pMenuBar->font(), aLocale, aFont)) - style.SetMenuFont(aFont); + // Menu bar font + if (toVclFont(pMenuBar->font(), aLocale, aFont)) + style.SetMenuFont(aFont); - // Icon theme - const bool bPreferDarkTheme = GetUseDarkMode(); - style.SetPreferredIconTheme(toOUString(QIcon::themeName()), bPreferDarkTheme); + // Icon theme + const bool bPreferDarkTheme = GetUseDarkMode(); + style.SetPreferredIconTheme(toOUString(QIcon::themeName()), bPreferDarkTheme); - // Scroll bar size - style.SetScrollBarSize(QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent)); - style.SetMinThumbSize(QApplication::style()->pixelMetric(QStyle::PM_ScrollBarSliderMin)); + // Scroll bar size + style.SetScrollBarSize(QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent)); + style.SetMinThumbSize(QApplication::style()->pixelMetric(QStyle::PM_ScrollBarSliderMin)); - // These colors are used for the ruler text and marks - style.SetShadowColor(toColor(pal.color(QPalette::Disabled, QPalette::WindowText))); - style.SetDarkShadowColor(toColor(pal.color(QPalette::Inactive, QPalette::WindowText))); + // These colors are used for the ruler text and marks + style.SetShadowColor(toColor(pal.color(QPalette::Disabled, QPalette::WindowText))); + style.SetDarkShadowColor(toColor(pal.color(QPalette::Inactive, QPalette::WindowText))); - // match native QComboBox behavior of putting text cursor to end of text - // without text selection when combobox entry is selected - style.SetComboBoxTextSelectionMode(ComboBoxTextSelectionMode::CursorToEnd); + // match native QComboBox behavior of putting text cursor to end of text + // without text selection when combobox entry is selected + style.SetComboBoxTextSelectionMode(ComboBoxTextSelectionMode::CursorToEnd); - // Cursor blink interval - int nFlashTime = QApplication::cursorFlashTime(); - style.SetCursorBlinkTime(nFlashTime != 0 ? nFlashTime / 2 : STYLE_CURSOR_NOBLINKTIME); - style.SetSystemColorsLoaded(true); + // Cursor blink interval + int nFlashTime = QApplication::cursorFlashTime(); + style.SetCursorBlinkTime(nFlashTime != 0 ? nFlashTime / 2 : STYLE_CURSOR_NOBLINKTIME); + style.SetSystemColorsLoaded(true); - rSettings.SetStyleSettings(style); + rSettings.SetStyleSettings(style); + }); } void QtFrame::Beep() { QApplication::beep(); } diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index 845d1940b185..ca04d8f084ba 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -105,141 +105,147 @@ bool QtMenu::VisibleMenuBar() { return true; } void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, unsigned nPos) { - sal_uInt16 nId = pSalMenuItem->mnId; - const QString aText = vclToQtStringWithAccelerator(mpVCLMenu->GetItemText(nId)); - vcl::KeyCode nAccelKey = mpVCLMenu->GetAccelKey(nId); + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + sal_uInt16 nId = pSalMenuItem->mnId; + const QString aText = vclToQtStringWithAccelerator(mpVCLMenu->GetItemText(nId)); + vcl::KeyCode nAccelKey = mpVCLMenu->GetAccelKey(nId); - pSalMenuItem->mpAction.reset(); - pSalMenuItem->mpMenu.reset(); + pSalMenuItem->mpAction.reset(); + pSalMenuItem->mpMenu.reset(); - if (mbMenuBar) - { - // top-level menu - if (validateQMenuBar()) + if (mbMenuBar) { - QMenu* pQMenu = new QMenu(aText, nullptr); - connectHelpSignalSlots(pQMenu, pSalMenuItem); - pSalMenuItem->mpMenu.reset(pQMenu); - - if ((nPos != MENU_APPEND) - && (static_cast<size_t>(nPos) < o3tl::make_unsigned(mpQMenuBar->actions().size()))) - { - mpQMenuBar->insertMenu(mpQMenuBar->actions()[nPos], pQMenu); - } - else - { - mpQMenuBar->addMenu(pQMenu); - } - - // correct parent menu for generated menu - if (pSalMenuItem->mpSubMenu) + // top-level menu + if (validateQMenuBar()) { - pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; - } + QMenu* pQMenu = new QMenu(aText, nullptr); + connectHelpSignalSlots(pQMenu, pSalMenuItem); + pSalMenuItem->mpMenu.reset(pQMenu); - connect(pQMenu, &QMenu::aboutToShow, this, - [pSalMenuItem] { slotMenuAboutToShow(pSalMenuItem); }); - connect(pQMenu, &QMenu::aboutToHide, this, - [pSalMenuItem] { slotMenuAboutToHide(pSalMenuItem); }); - } - } - else - { - if (!mpQMenu) - { - // no QMenu set, instantiate own one - mpOwnedQMenu.reset(new QMenu); - mpQMenu = mpOwnedQMenu.get(); - connectHelpSignalSlots(mpQMenu, pSalMenuItem); - } + if ((nPos != MENU_APPEND) + && (static_cast<size_t>(nPos) + < o3tl::make_unsigned(mpQMenuBar->actions().size()))) + { + mpQMenuBar->insertMenu(mpQMenuBar->actions()[nPos], pQMenu); + } + else + { + mpQMenuBar->addMenu(pQMenu); + } - if (pSalMenuItem->mpSubMenu) - { - // submenu - QMenu* pQMenu = new QMenu(aText, nullptr); - connectHelpSignalSlots(pQMenu, pSalMenuItem); - pSalMenuItem->mpMenu.reset(pQMenu); + // correct parent menu for generated menu + if (pSalMenuItem->mpSubMenu) + { + pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; + } - if ((nPos != MENU_APPEND) - && (static_cast<size_t>(nPos) < o3tl::make_unsigned(mpQMenu->actions().size()))) - { - mpQMenu->insertMenu(mpQMenu->actions()[nPos], pQMenu); + connect(pQMenu, &QMenu::aboutToShow, this, + [pSalMenuItem] { slotMenuAboutToShow(pSalMenuItem); }); + connect(pQMenu, &QMenu::aboutToHide, this, + [pSalMenuItem] { slotMenuAboutToHide(pSalMenuItem); }); } - else - { - mpQMenu->addMenu(pQMenu); - } - - // correct parent menu for generated menu - pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; - - ReinitializeActionGroup(nPos); - - // clear all action groups since menu is recreated - pSalMenuItem->mpSubMenu->ResetAllActionGroups(); - - connect(pQMenu, &QMenu::aboutToShow, this, - [pSalMenuItem] { slotMenuAboutToShow(pSalMenuItem); }); - connect(pQMenu, &QMenu::aboutToHide, this, - [pSalMenuItem] { slotMenuAboutToHide(pSalMenuItem); }); } else { - if (pSalMenuItem->mnType == MenuItemType::SEPARATOR) + if (!mpQMenu) { - QAction* pAction = new QAction(nullptr); - pSalMenuItem->mpAction.reset(pAction); - pAction->setSeparator(true); + // no QMenu set, instantiate own one + mpOwnedQMenu.reset(new QMenu); + mpQMenu = mpOwnedQMenu.get(); + connectHelpSignalSlots(mpQMenu, pSalMenuItem); + } + + if (pSalMenuItem->mpSubMenu) + { + // submenu + QMenu* pQMenu = new QMenu(aText, nullptr); + connectHelpSignalSlots(pQMenu, pSalMenuItem); + pSalMenuItem->mpMenu.reset(pQMenu); if ((nPos != MENU_APPEND) && (static_cast<size_t>(nPos) < o3tl::make_unsigned(mpQMenu->actions().size()))) { - mpQMenu->insertAction(mpQMenu->actions()[nPos], pAction); + mpQMenu->insertMenu(mpQMenu->actions()[nPos], pQMenu); } else { - mpQMenu->addAction(pAction); + mpQMenu->addMenu(pQMenu); } + // correct parent menu for generated menu + pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; + ReinitializeActionGroup(nPos); + + // clear all action groups since menu is recreated + pSalMenuItem->mpSubMenu->ResetAllActionGroups(); + + connect(pQMenu, &QMenu::aboutToShow, this, + [pSalMenuItem] { slotMenuAboutToShow(pSalMenuItem); }); + connect(pQMenu, &QMenu::aboutToHide, this, + [pSalMenuItem] { slotMenuAboutToHide(pSalMenuItem); }); } else { - // leaf menu - QAction* pAction = new QAction(aText, nullptr); - pAction->setToolTip(toQString(mpVCLMenu->GetTipHelpText(nId))); - pSalMenuItem->mpAction.reset(pAction); - - if ((nPos != MENU_APPEND) - && (static_cast<size_t>(nPos) < o3tl::make_unsigned(mpQMenu->actions().size()))) + if (pSalMenuItem->mnType == MenuItemType::SEPARATOR) { - mpQMenu->insertAction(mpQMenu->actions()[nPos], pAction); + QAction* pAction = new QAction(nullptr); + pSalMenuItem->mpAction.reset(pAction); + pAction->setSeparator(true); + + if ((nPos != MENU_APPEND) + && (static_cast<size_t>(nPos) + < o3tl::make_unsigned(mpQMenu->actions().size()))) + { + mpQMenu->insertAction(mpQMenu->actions()[nPos], pAction); + } + else + { + mpQMenu->addAction(pAction); + } + + ReinitializeActionGroup(nPos); } else { - mpQMenu->addAction(pAction); + // leaf menu + QAction* pAction = new QAction(aText, nullptr); + pAction->setToolTip(toQString(mpVCLMenu->GetTipHelpText(nId))); + pSalMenuItem->mpAction.reset(pAction); + + if ((nPos != MENU_APPEND) + && (static_cast<size_t>(nPos) + < o3tl::make_unsigned(mpQMenu->actions().size()))) + { + mpQMenu->insertAction(mpQMenu->actions()[nPos], pAction); + } + else + { + mpQMenu->addAction(pAction); + } + + ReinitializeActionGroup(nPos); + + UpdateActionGroupItem(pSalMenuItem); + + pAction->setShortcut(toQString(nAccelKey.GetName())); + + connect(pAction, &QAction::triggered, this, + [pSalMenuItem] { slotMenuTriggered(pSalMenuItem); }); + connect(pAction, &QAction::hovered, this, + [pSalMenuItem] { slotMenuHovered(pSalMenuItem); }); } - - ReinitializeActionGroup(nPos); - - UpdateActionGroupItem(pSalMenuItem); - - pAction->setShortcut(toQString(nAccelKey.GetName())); - - connect(pAction, &QAction::triggered, this, - [pSalMenuItem] { slotMenuTriggered(pSalMenuItem); }); - connect(pAction, &QAction::hovered, this, - [pSalMenuItem] { slotMenuHovered(pSalMenuItem); }); } } - } - QAction* pAction = pSalMenuItem->getAction(); - if (pAction) - { - pAction->setEnabled(pSalMenuItem->mbEnabled); - pAction->setVisible(pSalMenuItem->mbVisible); - } + QAction* pAction = pSalMenuItem->getAction(); + if (pAction) + { + pAction->setEnabled(pSalMenuItem->mbEnabled); + pAction->setVisible(pSalMenuItem->mbVisible); + } + }); } void QtMenu::ReinitializeActionGroup(unsigned nPos) @@ -368,39 +374,42 @@ void QtMenu::ResetAllActionGroups() void QtMenu::UpdateActionGroupItem(const QtMenuItem* pSalMenuItem) { - QAction* pAction = pSalMenuItem->getAction(); - if (!pAction) - return; + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + QAction* pAction = pSalMenuItem->getAction(); + if (!pAction) + return; - bool bChecked = mpVCLMenu->IsItemChecked(pSalMenuItem->mnId); - MenuItemBits itemBits = mpVCLMenu->GetItemBits(pSalMenuItem->mnId); + bool bChecked = mpVCLMenu->IsItemChecked(pSalMenuItem->mnId); + MenuItemBits itemBits = mpVCLMenu->GetItemBits(pSalMenuItem->mnId); - if (itemBits & MenuItemBits::RADIOCHECK) - { - pAction->setCheckable(true); - - if (pSalMenuItem->mpActionGroup) + if (itemBits & MenuItemBits::RADIOCHECK) { - pSalMenuItem->mpActionGroup->addAction(pAction); - } + pAction->setCheckable(true); - pAction->setChecked(bChecked); - } - else - { - pAction->setActionGroup(nullptr); + if (pSalMenuItem->mpActionGroup) + { + pSalMenuItem->mpActionGroup->addAction(pAction); + } - if (itemBits & MenuItemBits::CHECKABLE) - { - pAction->setCheckable(true); pAction->setChecked(bChecked); } else { - pAction->setChecked(false); - pAction->setCheckable(false); + pAction->setActionGroup(nullptr); + + if (itemBits & MenuItemBits::CHECKABLE) + { + pAction->setCheckable(true); + pAction->setChecked(bChecked); + } + else + { + pAction->setChecked(false); + pAction->setCheckable(false); + } } - } + }); } void QtMenu::InsertItem(SalMenuItem* pSalMenuItem, unsigned nPos) @@ -420,24 +429,25 @@ void QtMenu::InsertItem(SalMenuItem* pSalMenuItem, unsigned nPos) void QtMenu::RemoveItem(unsigned nPos) { - SolarMutexGuard aGuard; - - if (nPos >= maItems.size()) - return; + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (nPos >= maItems.size()) + return; - QtMenuItem* pItem = maItems[nPos]; - pItem->mpAction.reset(); - pItem->mpMenu.reset(); + QtMenuItem* pItem = maItems[nPos]; + pItem->mpAction.reset(); + pItem->mpMenu.reset(); - maItems.erase(maItems.begin() + nPos); + maItems.erase(maItems.begin() + nPos); - // Recalculate action groups if necessary: - // if separator between two QActionGroups was removed, - // it may be needed to merge them - if (nPos > 0) - { - ReinitializeActionGroup(nPos - 1); - } + // Recalculate action groups if necessary: + // if separator between two QActionGroups was removed, + // it may be needed to merge them + if (nPos > 0) + { + ReinitializeActionGroup(nPos - 1); + } + }); } void QtMenu::SetSubMenu(SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos) @@ -551,14 +561,17 @@ void QtMenu::DoFullMenuUpdate(Menu* pMenuBar) void QtMenu::ShowItem(unsigned nPos, bool bShow) { - if (nPos < maItems.size()) - { - QtMenuItem* pSalMenuItem = GetItemAtPos(nPos); - QAction* pAction = pSalMenuItem->getAction(); - if (pAction) - pAction->setVisible(bShow); - pSalMenuItem->mbVisible = bShow; - } + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (nPos < maItems.size()) + { + QtMenuItem* pSalMenuItem = GetItemAtPos(nPos); + QAction* pAction = pSalMenuItem->getAction(); + if (pAction) + pAction->setVisible(bShow); + pSalMenuItem->mbVisible = bShow; + } + }); } void QtMenu::SetItemBits(unsigned nPos, MenuItemBits) @@ -572,69 +585,85 @@ void QtMenu::SetItemBits(unsigned nPos, MenuItemBits) void QtMenu::CheckItem(unsigned nPos, bool bChecked) { - if (nPos < maItems.size()) - { - QtMenuItem* pSalMenuItem = GetItemAtPos(nPos); - QAction* pAction = pSalMenuItem->getAction(); - if (pAction) + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (nPos < maItems.size()) { - pAction->setCheckable(true); - pAction->setChecked(bChecked); + QtMenuItem* pSalMenuItem = GetItemAtPos(nPos); + QAction* pAction = pSalMenuItem->getAction(); + if (pAction) + { + pAction->setCheckable(true); + pAction->setChecked(bChecked); + } } - } + }); } void QtMenu::EnableItem(unsigned nPos, bool bEnable) { - if (nPos < maItems.size()) - { - QtMenuItem* pSalMenuItem = GetItemAtPos(nPos); - QAction* pAction = pSalMenuItem->getAction(); - if (pAction) - pAction->setEnabled(bEnable); - pSalMenuItem->mbEnabled = bEnable; - } + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (nPos < maItems.size()) + { + QtMenuItem* pSalMenuItem = GetItemAtPos(nPos); + QAction* pAction = pSalMenuItem->getAction(); + if (pAction) + pAction->setEnabled(bEnable); + pSalMenuItem->mbEnabled = bEnable; + } + }); } void QtMenu::SetItemText(unsigned, SalMenuItem* pItem, const OUString& rText) { - QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); - QAction* pAction = pSalMenuItem->getAction(); - if (pAction) - { - pAction->setText(vclToQtStringWithAccelerator(rText)); - } + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); + QAction* pAction = pSalMenuItem->getAction(); + if (pAction) + pAction->setText(vclToQtStringWithAccelerator(rText)); + }); } void QtMenu::SetItemImage(unsigned, SalMenuItem* pItem, const Image& rImage) { - QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); - // Save new image to use it in DoFullMenuUpdate - pSalMenuItem->maImage = rImage; + // Save new image to use it in DoFullMenuUpdate + pSalMenuItem->maImage = rImage; - QAction* pAction = pSalMenuItem->getAction(); - if (!pAction) - return; + QAction* pAction = pSalMenuItem->getAction(); + if (!pAction) + return; - pAction->setIcon(QPixmap::fromImage(toQImage(rImage))); + pAction->setIcon(QPixmap::fromImage(toQImage(rImage))); + }); } void QtMenu::SetItemTooltip(SalMenuItem* pItem, const OUString& rTooltip) { - QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); - if (QAction* pAction = pSalMenuItem->getAction()) - pAction->setToolTip(toQString(rTooltip)); + if (QAction* pAction = pSalMenuItem->getAction()) + pAction->setToolTip(toQString(rTooltip)); + }); } void QtMenu::SetAccelerator(unsigned, SalMenuItem* pItem, const vcl::KeyCode&, const OUString& rText) { - QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); - QAction* pAction = pSalMenuItem->getAction(); - if (pAction) - pAction->setShortcut(QKeySequence(toQString(rText), QKeySequence::PortableText)); + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + QtMenuItem* pSalMenuItem = static_cast<QtMenuItem*>(pItem); + QAction* pAction = pSalMenuItem->getAction(); + if (pAction) + pAction->setShortcut(QKeySequence(toQString(rText), QKeySequence::PortableText)); + }); } QtMenu* QtMenu::GetTopLevel() @@ -663,12 +692,15 @@ bool QtMenu::validateQMenuBar() const void QtMenu::ShowMenuBar(bool bVisible) { - if (!validateQMenuBar()) - return; + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (!validateQMenuBar()) + return; - mpQMenuBar->setVisible(bVisible); - if (bVisible) - lcl_force_menubar_layout_update(*mpQMenuBar); + mpQMenuBar->setVisible(bVisible); + if (bVisible) + lcl_force_menubar_layout_update(*mpQMenuBar); + }); } void QtMenu::slotMenuHovered(QtMenuItem* pItem) @@ -889,37 +921,40 @@ tools::Rectangle QtMenu::GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame* pFr void QtMenu::ShowCloseButton(bool bShow) { - if (!validateQMenuBar()) - return; + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (!validateQMenuBar()) + return; - if (!bShow && !m_pButtonGroup) - return; + if (!bShow && !m_pButtonGroup) + return; - QPushButton* pButton = nullptr; - if (m_pButtonGroup) - pButton = static_cast<QPushButton*>(m_pButtonGroup->button(CLOSE_BUTTON_ID)); - if (!bShow && !pButton) - return; + QPushButton* pButton = nullptr; + if (m_pButtonGroup) + pButton = static_cast<QPushButton*>(m_pButtonGroup->button(CLOSE_BUTTON_ID)); + if (!bShow && !pButton) + return; - if (!pButton) - { - QIcon aIcon; - if (QIcon::hasThemeIcon("window-close-symbolic")) - aIcon = QIcon::fromTheme("window-close-symbolic"); - else - aIcon = QIcon( - QPixmap::fromImage(toQImage(Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC)))); - pButton = ImplAddMenuBarButton(aIcon, toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)), - CLOSE_BUTTON_ID); - connect(pButton, &QPushButton::clicked, this, &QtMenu::slotCloseDocument); - } + if (!pButton) + { + QIcon aIcon; + if (QIcon::hasThemeIcon("window-close-symbolic")) + aIcon = QIcon::fromTheme("window-close-symbolic"); + else + aIcon = QIcon( + QPixmap::fromImage(toQImage(Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC)))); + pButton = ImplAddMenuBarButton(aIcon, toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)), + CLOSE_BUTTON_ID); + connect(pButton, &QPushButton::clicked, this, &QtMenu::slotCloseDocument); + } - if (bShow) - pButton->show(); - else - pButton->hide(); + if (bShow) + pButton->show(); + else + pButton->hide(); - lcl_force_menubar_layout_update(*mpQMenuBar); + lcl_force_menubar_layout_update(*mpQMenuBar); + }); } bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangle& rRect,