sfx2/source/sidebar/TabBar.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 879bcc88759d7dd033e0ee667daee0d2a743cf06
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jun 26 09:12:55 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Jun 26 17:59:37 2024 +0200

    tdf#159835 sfx2: Skip sidebar menu update for gtk4 to work around crash
    
    After
    
        commit daed96f0818b1baae5de8b74b866009d7d89f853
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Wed Jun 19 13:08:34 2024 +0200
    
            tdf#159835 sfx2: Keep sidebar menu up to date
    
    , starting LO Writer with the gtk4 VCL plugin resulted
    in a crash (backtrace below) due to the current menu
    implementation for the gtk4 VCL plugin being
    incomplete/broken.
    
    For now, until the underlying issue has been fixed,
    at least avoid crashing by skipping the menu update
    when using gtk4.
    
    This effectively reverts back to the old behavior
    for gtk4, where before the above commit,
    `mxMenuButton->get_active()` in `TabBar::OnToolboxClicked`
    would always return false when clicking the menu button
    in the sidebar, so the code path triggering the crash
    wouldn't be hit, thus not triggering the
    pre-existing underlying issue.
    
    Backtrace of the crash:
    
        Thread 1 "soffice.bin" received signal SIGSEGV, Segmentation fault.
        0x00007fffe9d25afe in g_atomic_ref_count_inc () from 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #0  0x00007fffe9d25afe in g_atomic_ref_count_inc () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #1  0x00007fffe9cfb3b6 in g_hash_table_ref () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #2  0x00007fffe90ff92e in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #3  0x00007fffe90feaf4 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #4  0x00007fffe90fef2c in g_menu_model_get_item_attribute () at 
/lib/x86_64-linux-gnu/libgio-2.0.so.0
        #5  0x00007fffe44fd500 in (anonymous 
namespace)::MenuHelper::get_item_id(int) const (this=0x55555c78dbf0, pos=0) at 
vcl/unx/gtk4/../gtk3/gtkinst.cxx:5748
        #6  0x00007fffe44fc976 in (anonymous 
namespace)::GtkInstanceMenu::get_id(int) const (this=0x55555c78dbf0, pos=0) at 
vcl/unx/gtk4/../gtk3/gtkinst.cxx:11711
        #7  0x00007fffe44fcd40 in virtual thunk to (anonymous 
namespace)::GtkInstanceMenu::get_id(int) const () at 
vcl/unx/gtk4/../gtk3/gtkinst.cxx:11745
        #8  0x00007ffff3fae52b in sfx2::sidebar::TabBar::UpdateMenus() 
(this=0x55555c7ce530) at .../libreoffice/sfx2/source/sidebar/TabBar.cxx:342
        #9  0x00007ffff3faf86a in sfx2::sidebar::TabBar::TabBar(vcl::Window*, 
com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, 
std::function<void (rtl::OUString const&)>, std::function<void (weld::Menu&, 
weld::Menu&)>, sfx2::sidebar::SidebarController&) (this=0x55555c7ce530, 
pParentWindow=0x55555c62cea0, rxFrame=..., aDeckActivationFunctor=..., 
aPopupMenuSignalConnectFunction=..., rParentSidebarController=...) at 
.../libreoffice/sfx2/source/sidebar/TabBar.cxx:76
        #10 0x00007ffff3f1c84d in 
VclPtr<sfx2::sidebar::TabBar>::Create<VclPtr<sfx2::sidebar::SidebarDockingWindow>&,
 com::sun::star::uno::Reference<com::sun::star::frame::XFrame>&, 
sfx2::sidebar::SidebarController::SidebarController(sfx2::sidebar::SidebarDockingWindow*,
 SfxViewFrame const*)::$_3, 
sfx2::sidebar::SidebarController::$_3(sfx2::sidebar::SidebarDockingWindow*, 
SfxViewFrame const*)::$_4, 
sfx2::sidebar::SidebarController&>(VclPtr<sfx2::sidebar::SidebarDockingWindow>&,
 com::sun::star::uno::Reference<com::sun::star::frame::XFrame>&, 
sfx2::sidebar::SidebarController::SidebarController(sfx2::sidebar::SidebarDockingWindow*,
 SfxViewFrame const*)::$_3&&, 
sfx2::sidebar::SidebarController::$_3(sfx2::sidebar::SidebarDockingWindow*, 
SfxViewFrame const*)::$_4&&, sfx2::sidebar::SidebarController&) (arg=..., 
arg=..., arg=..., arg=..., arg=...) at include/vcl/vclptr.hxx:129
        #11 0x00007ffff3f1cc86 in 
sfx2::sidebar::SidebarController::SidebarController(sfx2::sidebar::SidebarDockingWindow*,
 SfxViewFrame const*) (this=0x55555c6f1fc0, pParentWindow=0x55555c62cea0, 
pViewFrame=0x55555abb87a0) at 
.../libreoffice/sfx2/source/sidebar/SidebarController.cxx:119
        #12 0x00007ffff3f1d59f in 
sfx2::sidebar::SidebarController::create(sfx2::sidebar::SidebarDockingWindow*, 
SfxViewFrame const*) (pParentWindow=0x55555c62cea0, pViewFrame=0x55555abb87a0) 
at .../libreoffice/sfx2/source/sidebar/SidebarController.cxx:147
        #13 0x00007ffff3f1a997 in 
sfx2::sidebar::SidebarDockingWindow::GetOrCreateSidebarController() 
(this=0x55555c62cea0) at 
.../libreoffice/sfx2/source/sidebar/SidebarDockingWindow.cxx:64
        #14 0x00007ffff3f1ac24 in 
sfx2::sidebar::SidebarDockingWindow::SidebarDockingWindow(SfxBindings*, 
sfx2::sidebar::SidebarChildWindow&, vcl::Window*, long) (this=0x55555c62cea0, 
pSfxBindings=0x55555abdafe0, rChildWindow=..., pParentWindow=0x55555abdb6a0, 
nBits=137975825761) at 
.../libreoffice/sfx2/source/sidebar/SidebarDockingWindow.cxx:55
        #15 0x00007ffff3f19e79 in 
VclPtr<sfx2::sidebar::SidebarDockingWindow>::Create<SfxBindings*&, 
sfx2::sidebar::SidebarChildWindow&, vcl::Window*&, long>(SfxBindings*&, 
sfx2::sidebar::SidebarChildWindow&, vcl::Window*&, long&&) 
(arg=@0x7fffffff45f8: 0x55555abdafe0, arg=..., arg=@0x7fffffff4600: 
0x55555abdb6a0, arg=@0x7fffffff45e8: 137975825761) at include/vcl/vclptr.hxx:129
        #16 0x00007ffff3f1960e in 
sfx2::sidebar::SidebarChildWindow::SidebarChildWindow(vcl::Window*, unsigned 
short, SfxBindings*, SfxChildWinInfo*) (this=0x55555c7d3130, 
pParentWindow=0x55555abdb6a0, nId=10336, pBindings=0x55555abdafe0, 
pInfo=0x7fffffff4878) at 
.../libreoffice/sfx2/source/sidebar/SidebarChildWindow.cxx:36
        #17 0x00007ffff3f19d0c in 
std::make_unique<sfx2::sidebar::SidebarChildWindow, vcl::Window*&, unsigned 
short&, SfxBindings*&, SfxChildWinInfo*&>(vcl::Window*&, unsigned short&, 
SfxBindings*&, SfxChildWinInfo*&) (__args=@0x7fffffff46c0: 0x55555abdb6a0, 
__args=@0x7fffffff46be: 10336, __args=@0x7fffffff46b0: 0x55555abdafe0, 
__args=@0x7fffffff46a8: 0x7fffffff4878) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:1070
        #18 0x00007ffff3f19344 in 
sfx2::sidebar::SidebarChildWindow::CreateImpl(vcl::Window*, unsigned short, 
SfxBindings*, SfxChildWinInfo*) (pParent=0x55555abdb6a0, nId=10336, 
pBindings=0x55555abdafe0, pInfo=0x7fffffff4878) at 
.../libreoffice/sfx2/source/sidebar/SidebarChildWindow.cxx:30
        #19 0x00007ffff38b2b4b in SfxChildWindow::CreateChildWindow(unsigned 
short, vcl::Window*, SfxBindings*, SfxChildWinInfo&) (nId=10336, 
pParent=0x55555abdb6a0, pBindings=0x55555abdafe0, rInfo=...) at 
.../libreoffice/sfx2/source/appl/childwin.cxx:241
        #20 0x00007ffff39592dd in 
SfxWorkWindow::CreateChildWin_Impl(SfxChildWin_Impl*, bool) 
(this=0x555556828e50, pCW=0x55555c4e3a00, bSetFocus=false) at 
.../libreoffice/sfx2/source/appl/workwin.cxx:1351
        #21 0x00007ffff3958fdc in SfxWorkWindow::UpdateChildWindows_Impl() 
(this=0x555556828e50) at .../libreoffice/sfx2/source/appl/workwin.cxx:1300
        #22 0x00007ffff39584da in SfxWorkWindow::UpdateObjectBars_Impl2() 
(this=0x555556828e50) at .../libreoffice/sfx2/source/appl/workwin.cxx:1248
        #23 0x00007ffff3957a0b in SfxWorkWindow::UpdateObjectBars_Impl() 
(this=0x555556828e50) at .../libreoffice/sfx2/source/appl/workwin.cxx:1096
        #24 0x00007ffff39cbeb5 in SfxDispatcher::Update_Impl(bool) 
(this=0x55555abd9fc0, bForce=false) at 
.../libreoffice/sfx2/source/control/dispatch.cxx:1122
        #25 0x00007ffff4059a69 in 
SfxBaseController::ConnectSfxFrame_Impl(SfxBaseController::ConnectSfxFrame) 
(this=0x55555ac3f8b0, i_eConnect=SfxBaseController::E_CONNECT) at 
.../libreoffice/sfx2/source/view/sfxbasecontroller.cxx:1206
        #26 0x00007ffff4058aac in 
SfxBaseController::attachFrame(com::sun::star::uno::Reference<com::sun::star::frame::XFrame>
 const&) (this=0x55555ac3f8b0, xFrame=...) at 
.../libreoffice/sfx2/source/view/sfxbasecontroller.cxx:530
    
    Change-Id: I9c04b4faff4da084bfa8f932d9f95a233bc1f528
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169534
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index 76669adc5798..184f42877667 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -337,6 +337,12 @@ void TabBar::UpdateFocusManager(FocusManager& 
rFocusManager)
 
 void TabBar::UpdateMenus()
 {
+    if (Application::GetToolkitName() == u"gtk4"_ustr)
+    {
+        SAL_WARN("sfx", "Skipping update of sidebar menus to avoid crash due 
to gtk4 menu brokenness.");
+        return;
+    }
+
     for (int i = mxMainMenu->n_children() - 1; i >= 0; --i)
     {
         OUString sIdent = mxMainMenu->get_id(i);

Reply via email to