vcl/unx/gtk4/a11y.cxx |   29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

New commits:
commit f6ca163d3f6383d3a48dbdacc5410e630d678ea1
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Apr 26 12:43:24 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 26 20:18:30 2024 +0200

    gtk4 a11y: Don't create second AT context for OOoFixed
    
    Similar to how the previous
    
        Change-Id: I35196ca686e9d56f97bbf884da8b6492358e41fc
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Fri Apr 26 09:45:39 2024 +0200
    
            gtk4 a11y: Don't create multiple AT contexts for same accessible
    
    avoids creating multiple AT contexts for the same
    accessible when the role changes, this commit addresses
    another case in which 2 GtkATContexts could be created
    for the OOoFixed which could result in segfault crashes:
    
    The OOoFixed is a GtkWidget, and GTK's `gtk_widget_init`
    already creates an AT context for widgets.
    Then, a second AT context would be created because
    `ooo_fixed_accessible_init` set an own implementation
    for GtkAccessibleInterface::get_at_context that would
    create a second AT context when it got called, resulting
    in breaking the apparent assumption that there's a 1:1 mapping
    between GtkAccessible and GtkATConetxt.
    
    No longer override `GtkAccessibleInterface::get_at_context`
    but live with the GtkATContext created for the GtkWidget,
    even if that means an a11y role cannot explicitly be set
    for these for now.
    From a first quick look at the tree in Accerciser,
    I only see one item changed its a11y role from panel to filler.
    
    The main class used. e.g. for the document content is
    LOAccessible, not OOoFixed, and setting the proper role
    for instances of that class is unaffected, see
    `lo_accessible_get_at_context`.
    
    If setting the a11y role is relevant, this could be
    done when initializing the OOoFixed instead by setting
    the "accessible-role" property [1], tested with this demo
    local change to set a dummy table-cell a11y role and
    verifying in Accerciser that it was actually set:
    
        --- a/vcl/unx/gtk3/gtkframe.cxx
        +++ b/vcl/unx/gtk3/gtkframe.cxx
        @@ -993,7 +993,10 @@ void GtkSalFrame::InitCommon()
         #else
             m_pOverlay = GTK_OVERLAY(gtk_overlay_new());
         #if GTK_CHECK_VERSION(4,9,0)
        -    m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), 
nullptr ));
        +    GValue aValue = G_VALUE_INIT;
        +    g_value_init (&aValue, GTK_TYPE_ACCESSIBLE_ROLE);
        +    g_value_set_enum(&aValue, GTK_ACCESSIBLE_ROLE_CELL);
        +    m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), 
"accessible-role", aValue,  nullptr ));
         #else
             m_pFixedContainer = GTK_FIXED(gtk_fixed_new());
         #endif
    
    Similar to how the dropped code did, this could use the
    a11y role from the corresponding `vcl::Window`, which is
    currently not passed, but that could be adjusted, e.g.
    by either passing the window or its accessible info
    to `SalInstance::CreateFrame`/`SalInstance::CreateChildFrame`.
    See `Window::ImplInit`, where the `vcl::Window` is currently
    only set via `SalFrame::SetCallback` after the call to
    `SalInstance::CreateFrame`/`SalInstance::CreateChildFrame`.
    
    Without this commit, for me, this crash happened about 10-30 %
    of the time when starting LO Writer with the gtk4 VCL plugin in rr,
    when Accerciser was running already.
    
    Backtrace for first AT context creation (from `gtk_widget_init`):
    
        1 gtk_at_context_create gtkatcontext.c 671 0x7f677daf129e
        2 create_at_context gtkwidget.c 8574 0x7f677dd6bcd9
        3 gtk_widget_init gtkwidget.c 2392 0x7f677dd5edbc
        4 g_type_create_instance 0x7f678ed8f2a3
        5 ?? 0x7f678ed72500
        6 g_object_new_with_properties 0x7f678ed73b96
        7 g_object_new 0x7f678ed74a41
        8 GtkSalFrame::InitCommon gtkframe.cxx 996 0x7f677edb9243
        9 GtkSalFrame::Init gtkframe.cxx 1785 0x7f677edb7bca
        10 GtkSalFrame::GtkSalFrame gtkframe.cxx 510 0x7f677edb726d
        11 GtkInstance::CreateFrame gtkinst.cxx 273 0x7f677ec7cebc
        12 vcl::Window::ImplInit window.cxx 1057 0x7f6788cf7f49
        13 ImplBorderWindow::ImplInit brdwin.cxx 1555 0x7f6788a6d45b
        14 ImplBorderWindow::ImplBorderWindow brdwin.cxx 1584 0x7f6788a6da21
        15 VclPtrInstance<ImplBorderWindow>::VclPtrInstance<vcl::Window *&, 
SystemParentData *&, long&, BorderWindowStyle&> vclptr.hxx 280 0x7f6788d31049
        16 WorkWindow::ImplInit wrkwin.cxx 51 0x7f6788d2f809
        17 IntroWindow::IntroWindow introwin.cxx 35 0x7f6788bb7ee0
        18 (anonymous namespace)::SplashScreenWindow::SplashScreenWindow 
splash.cxx 122 0x7f677c1cee61
        19 VclPtr<(anonymous namespace)::SplashScreenWindow>::Create<(anonymous 
namespace)::SplashScreen *> vclptr.hxx 129 0x7f677c1cc86b
        20 (anonymous namespace)::SplashScreen::SplashScreen splash.cxx 145 
0x7f677c1cc5f8
        21 desktop_SplashScreen_get_implementation splash.cxx 616 0x7f677c1cc4f9
        22 std::__invoke_impl<com::sun::star::uno::XInterface *, 
com::sun::star::uno::XInterface * ( *&)(com::sun::star::uno::XComponentContext 
*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), 
com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&> invoke.h 61 
0x7f67907ef7a8
        23 std::__invoke_r<com::sun::star::uno::XInterface *, 
com::sun::star::uno::XInterface * ( *&)(com::sun::star::uno::XComponentContext 
*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), 
com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&> invoke.h 114 
0x7f67907ef745
        24 std::_Function_handler<com::sun::star::uno::XInterface * 
(com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), 
com::sun::star::uno::XInterface * ( *)(com::sun::star::uno::XComponentContext 
*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> 
const&)>::_M_invoke(std::_Any_data const&, 
com::sun::star::uno::XComponentContext *&&, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) std_function.h 
290 0x7f67907ef63d
        25 std::function<com::sun::star::uno::XInterface * 
(com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> 
const&)>::operator()(com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) const 
std_function.h 591 0x7f67907b6848
        26 
cppuhelper::ServiceManager::Data::Implementation::doCreateInstanceWithArguments 
servicemanager.cxx 725 0x7f679079f26f
        27 
cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments 
servicemanager.cxx 696 0x7f679079f143
        28 cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext 
servicemanager.cxx 1021 0x7f67907a56c5
        29 non-virtual thunk to 
cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext(rtl::OUString 
const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, 
com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) 
servicemanager.cxx 1022 0x7f67907a577c
        30 desktop::Desktop::OpenSplashScreen app.cxx 2449 0x7f6792723b2c
        31 desktop::Desktop::Main app.cxx 1299 0x7f6792721362
        32 ImplSVMain svmain.cxx 229 0x7f67895bcfbe
        33 SVMain svmain.cxx 261 0x7f67895bf009
        34 soffice_main sofficemain.cxx 93 0x7f67927a5a73
        35 sal_main main.c 51 0x55fa1fbf7a5d
        36 main main.c 49 0x55fa1fbf7a37
    
    Backtrace for second AT context creation:
    
        1 gtk_at_context_create gtkatcontext.c 671 0x7f677daf129e
        2 get_at_context a11y.cxx 806 0x7f677ec389b6
        3 gtk_accessible_get_at_context gtkaccessible.c 105 0x7f677dae2d4b
        4 gtk_accessible_platform_changed gtkaccessible.c 1081 0x7f677dae427d
        5 gtk_widget_set_focusable gtkwidget.c 5255 0x7f677dd65086
        6 GtkSalFrame::InitCommon gtkframe.cxx 1157 0x7f677edb9d15
        7 GtkSalFrame::Init gtkframe.cxx 1785 0x7f677edb7bca
        8 GtkSalFrame::GtkSalFrame gtkframe.cxx 510 0x7f677edb726d
        9 GtkInstance::CreateFrame gtkinst.cxx 273 0x7f677ec7cebc
        10 vcl::Window::ImplInit window.cxx 1057 0x7f6788cf7f49
        11 ImplBorderWindow::ImplInit brdwin.cxx 1555 0x7f6788a6d45b
        12 ImplBorderWindow::ImplBorderWindow brdwin.cxx 1584 0x7f6788a6da21
        13 VclPtrInstance<ImplBorderWindow>::VclPtrInstance<vcl::Window *&, 
SystemParentData *&, long&, BorderWindowStyle&> vclptr.hxx 280 0x7f6788d31049
        14 WorkWindow::ImplInit wrkwin.cxx 51 0x7f6788d2f809
        15 IntroWindow::IntroWindow introwin.cxx 35 0x7f6788bb7ee0
        16 (anonymous namespace)::SplashScreenWindow::SplashScreenWindow 
splash.cxx 122 0x7f677c1cee61
        17 VclPtr<(anonymous namespace)::SplashScreenWindow>::Create<(anonymous 
namespace)::SplashScreen *> vclptr.hxx 129 0x7f677c1cc86b
        18 (anonymous namespace)::SplashScreen::SplashScreen splash.cxx 145 
0x7f677c1cc5f8
        19 desktop_SplashScreen_get_implementation splash.cxx 616 0x7f677c1cc4f9
        20 std::__invoke_impl<com::sun::star::uno::XInterface *, 
com::sun::star::uno::XInterface * ( *&)(com::sun::star::uno::XComponentContext 
*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), 
com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&> invoke.h 61 
0x7f67907ef7a8
        21 std::__invoke_r<com::sun::star::uno::XInterface *, 
com::sun::star::uno::XInterface * ( *&)(com::sun::star::uno::XComponentContext 
*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), 
com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&> invoke.h 114 
0x7f67907ef745
        22 std::_Function_handler<com::sun::star::uno::XInterface * 
(com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), 
com::sun::star::uno::XInterface * ( *)(com::sun::star::uno::XComponentContext 
*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> 
const&)>::_M_invoke(std::_Any_data const&, 
com::sun::star::uno::XComponentContext *&&, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) std_function.h 
290 0x7f67907ef63d
        23 std::function<com::sun::star::uno::XInterface * 
(com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> 
const&)>::operator()(com::sun::star::uno::XComponentContext *, 
com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) const 
std_function.h 591 0x7f67907b6848
        24 
cppuhelper::ServiceManager::Data::Implementation::doCreateInstanceWithArguments 
servicemanager.cxx 725 0x7f679079f26f
        25 
cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments 
servicemanager.cxx 696 0x7f679079f143
        26 cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext 
servicemanager.cxx 1021 0x7f67907a56c5
        27 non-virtual thunk to 
cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext(rtl::OUString 
const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, 
com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) 
servicemanager.cxx 1022 0x7f67907a577c
        28 desktop::Desktop::OpenSplashScreen app.cxx 2449 0x7f6792723b2c
        29 desktop::Desktop::Main app.cxx 1299 0x7f6792721362
        30 ImplSVMain svmain.cxx 229 0x7f67895bcfbe
        31 SVMain svmain.cxx 261 0x7f67895bf009
        32 soffice_main sofficemain.cxx 93 0x7f67927a5a73
        33 sal_main main.c 51 0x55fa1fbf7a5d
        34 main main.c 49 0x55fa1fbf7a37
    
    Backtrace of the segfault:
    
        Thread 1 received signal SIGSEGV, Segmentation fault.
        0x00007f677deaec8e in GTK_IS_ACCESSIBLE_TEXT (ptr=0x55fa21196bb0) at 
../gtk/gtkaccessibletext.h:35
        35      G_DECLARE_INTERFACE (GtkAccessibleText, gtk_accessible_text, 
GTK, ACCESSIBLE_TEXT, GtkAccessible)
        (rr) bt
        #0  0x00007f677deaec8e in GTK_IS_ACCESSIBLE_TEXT (ptr=0x55fa21196bb0) 
at ../gtk/gtkaccessibletext.h:35
        #1  0x00007f677deb1d88 in gtk_atspi_connect_text_signals 
(accessible=0x55fa21196bb0, text_changed=0x7f677dea1365 <emit_text_changed>, 
selection_changed=0x7f677dea140b <emit_text_selection_changed>, 
data=0x55fa2119d860)
            at ../gtk/a11y/gtkatspitext.c:1037
        #2  0x00007f677dea2fea in register_object (root=0x55fa2119e210, 
context=0x55fa2119d860) at ../gtk/a11y/gtkatspicontext.c:1442
        #3  0x00007f677dea8138 in on_registration_reply 
(gobject=0x55fa21179030, result=0x55fa39240d80, user_data=0x55fa2117a4a0) at 
../gtk/a11y/gtkatspiroot.c:531
        #4  0x00007f6783cc8ee3 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #5  0x00007f6783cc9b83 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #6  0x00007f6783d269da in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #7  0x00007f6783cc8ee3 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #8  0x00007f6783cc8f1d in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #9  0x00007f6785b110d9 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
        #10 0x00007f6785b14317 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
        #11 0x00007f6785b14930 in g_main_context_iteration () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #12 0x00007f677ec77d0f in GtkSalData::Yield(bool, bool) 
(this=0x55fa1fe8e000, bWait=true, bHandleAllCurrentEvents=false) at 
vcl/unx/gtk4/../gtk3/gtkdata.cxx:405
        #13 0x00007f677ec7dbd3 in GtkInstance::DoYield(bool, bool) 
(this=0x55fa1fe8deb0, bWait=true, bHandleAllCurrentEvents=false) at 
vcl/unx/gtk4/../gtk3/gtkinst.cxx:435
        #14 0x00007f678959a64c in ImplYield(bool, bool) (i_bWait=true, 
i_bAllEvents=false) at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:394
        #15 0x00007f6789599f5b in Application::Yield() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:482
        #16 0x00007f6789599cf2 in Application::Execute() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:369
        #17 0x00007f679272304c in desktop::Desktop::Main() 
(this=0x7ffdf3dcc768) at 
/home/michi/development/git/libreoffice/desktop/source/app/app.cxx:1615
        #18 0x00007f67895bcfbe in ImplSVMain() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:229
        #19 0x00007f67895bf009 in SVMain() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:261
        #20 0x00007f67927a5a73 in soffice_main() () at 
/home/michi/development/git/libreoffice/desktop/source/app/sofficemain.cxx:93
        #21 0x000055fa1fbf7a5d in sal_main () at 
/home/michi/development/git/libreoffice/desktop/source/app/main.c:51
        #22 0x000055fa1fbf7a37 in main (argc=2, argv=0x7ffdf3dcc978) at 
/home/michi/development/git/libreoffice/desktop/source/app/main.c:49
    
    [1] https://docs.gtk.org/gtk4/property.Accessible.accessible-role.html
    
    Change-Id: If4fdcd249aaada846934c3e967d654e3266ad73d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166709
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx
index 7574e67f5758..4b9447c19ae4 100644
--- a/vcl/unx/gtk4/a11y.cxx
+++ b/vcl/unx/gtk4/a11y.cxx
@@ -789,28 +789,6 @@ static gboolean 
lo_accessible_range_set_current_value(GtkAccessibleRange* self,
 
 static void lo_accessible_init(LoAccessible* /*iface*/) {}
 
-static GtkATContext* get_at_context(GtkAccessible* self)
-{
-    OOoFixed* pFixed = OOO_FIXED(self);
-
-    css::uno::Reference<css::accessibility::XAccessible> xAccessible(
-        get_uno_accessible(GTK_WIDGET(pFixed)));
-
-    if (!pFixed->at_context)
-    {
-        //        if (pFixed->at_context)
-        //            g_clear_object(&pFixed->at_context);
-
-        GtkAccessibleRole eRole = map_accessible_role(xAccessible);
-        pFixed->at_context
-            = gtk_at_context_create(eRole, self, 
gtk_widget_get_display(GTK_WIDGET(pFixed)));
-        if (!pFixed->at_context)
-            return nullptr;
-    }
-
-    return g_object_ref(pFixed->at_context);
-}
-
 #if 0
 gboolean get_platform_state(GtkAccessible* self, GtkAccessiblePlatformState 
state)
 {
@@ -858,7 +836,6 @@ static void 
ooo_fixed_accessible_init(GtkAccessibleInterface* iface)
 {
     GtkAccessibleInterface* parent_iface
         = 
static_cast<GtkAccessibleInterface*>(g_type_interface_peek_parent(iface));
-    iface->get_at_context = get_at_context;
     iface->get_bounds = get_bounds;
     iface->get_first_accessible_child = get_first_accessible_child;
     iface->get_platform_state = parent_iface->get_platform_state;
commit 707e4f12f11efa3ef575adf549cafb8ecdbfa045
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Apr 26 09:45:39 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 26 20:18:15 2024 +0200

    gtk4 a11y: Don't create multiple AT contexts for same accessible
    
    In the `GtkAccessibleInterface::get_at_context` implementations,
    do not create a new `GtkATContext` if the accessible role has
    changed.
    
    This broke the apparent assumption that there's a 1:1 mapping
    between `GtkAccessible` and `GtkATContext` and resulted in
    segfaults seen quite often when starting LO Writer
    with the gtk4 VCL plugin while Accerciser was also running.
    
    For me, this was even more reproducible when running in rr
    (crashed reliably on start).
    
    LO has the `AccessibleEventId::ROLE_CHANGED` event type
    to indicate role changes, but GTK 4 doesn't support
    changing the initial role any more.
    
    Quoting the
    GtkAccessible doc [1]:
    
    > The role cannot be changed after instantiating a
    > GtkAccessible implementation.
    
    And the accessibility section in the GTK 4 doc [2] says:
    
    > Each role is part of the widget’s instance, and cannot be changed over
    > time or as the result of a user action. Roles allows assistive
    > technology applications to identify a UI control and decide how to
    > present it to a user; if a part of the application’s UI changes role,
    > the control needs to be removed and replaced with another one
    > with the appropriate role.
    
    Sample backtrace:
    
        Thread 1 received signal SIGSEGV, Segmentation fault.
        0x00007f0399aa0636 in get_parent_context_ref 
(accessible=0x55a141b5a9b0) at ../gtk/a11y/gtkatspicontext.c:462
        462           res = gtk_at_spi_root_to_ref (self->root);
        (rr) bt
        #0  0x00007f0399aa0636 in get_parent_context_ref 
(accessible=0x55a141b5a9b0) at ../gtk/a11y/gtkatspicontext.c:462
        #1  0x00007f0399aa43ba in gtk_at_spi_context_get_parent_ref 
(self=0x55a141b615c0) at ../gtk/a11y/gtkatspicontext.c:1956
        #2  0x00007f0399a9dc75 in collect_object (self=0x55a1469113a0, 
builder=0x7fff90e1a220, context=0x55a141b615c0) at 
../gtk/a11y/gtkatspicache.c:131
        #3  0x00007f0399a9e2f2 in emit_add_accessible (self=0x55a1469113a0, 
context=0x55a141b615c0) at ../gtk/a11y/gtkatspicache.c:235
        #4  0x00007f0399a9eac1 in gtk_at_spi_cache_add_context 
(self=0x55a1469113a0, context=0x55a141b615c0) at ../gtk/a11y/gtkatspicache.c:436
        #5  0x00007f0399aa8152 in on_registration_reply 
(gobject=0x55a141b62060, result=0x55a14e28a890, user_data=0x55a141b64770) at 
../gtk/a11y/gtkatspiroot.c:533
        #6  0x00007f039fac8ee3 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #7  0x00007f039fac9b83 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #8  0x00007f039fb269da in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #9  0x00007f039fac8ee3 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #10 0x00007f039fac8f1d in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
        #11 0x00007f03a0b110d9 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
        #12 0x00007f03a0b14317 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
        #13 0x00007f03a0b14930 in g_main_context_iteration () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #14 0x00007f039a877d9f in GtkSalData::Yield(bool, bool) 
(this=0x55a140869000, bWait=true, bHandleAllCurrentEvents=false) at 
vcl/unx/gtk4/../gtk3/gtkdata.cxx:405
        #15 0x00007f039a87dc63 in GtkInstance::DoYield(bool, bool) 
(this=0x55a140868eb0, bWait=true, bHandleAllCurrentEvents=false) at 
vcl/unx/gtk4/../gtk3/gtkinst.cxx:435
        #16 0x00007f03a539a64c in ImplYield(bool, bool) (i_bWait=true, 
i_bAllEvents=false) at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:394
        #17 0x00007f03a5399f5b in Application::Yield() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:482
        #18 0x00007f03a5399cf2 in Application::Execute() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:369
        #19 0x00007f03ae52304c in desktop::Desktop::Main() 
(this=0x7fff90e1c288) at 
/home/michi/development/git/libreoffice/desktop/source/app/app.cxx:1615
        #20 0x00007f03a53bcfbe in ImplSVMain() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:229
        #21 0x00007f03a53bf009 in SVMain() () at 
/home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:261
        #22 0x00007f03ae5a5a73 in soffice_main() () at 
/home/michi/development/git/libreoffice/desktop/source/app/sofficemain.cxx:93
        #23 0x000055a13fefca5d in sal_main () at 
/home/michi/development/git/libreoffice/desktop/source/app/main.c:51
        #24 0x000055a13fefca37 in main (argc=2, argv=0x7fff90e1c498) at 
/home/michi/development/git/libreoffice/desktop/source/app/main.c:49
    
    From valgrind output:
    
        (soffice:972353): Gtk-CRITICAL **: 09:28:48.066: 
gtk_accessible_get_accessible_parent: assertion 'GTK_IS_ACCESSIBLE (self)' 
failed
    
        (soffice:972353): Gtk-CRITICAL **: 09:28:48.067: 
gtk_accessible_get_at_context: assertion 'GTK_IS_ACCESSIBLE (self)' failed
        ==972353== Thread 1:
        ==972353== Invalid read of size 8
        ==972353==    at 0x19077636: get_parent_context_ref 
(gtkatspicontext.c:462)
        ==972353==    by 0x1907B3B9: gtk_at_spi_context_get_parent_ref 
(gtkatspicontext.c:1956)
        ==972353==    by 0x19074C74: collect_object (gtkatspicache.c:131)
        ==972353==    by 0x190752F1: emit_add_accessible (gtkatspicache.c:235)
        ==972353==    by 0x19075AC0: gtk_at_spi_cache_add_context 
(gtkatspicache.c:436)
        ==972353==    by 0x1907F151: on_registration_reply (gtkatspiroot.c:533)
        ==972353==    by 0x12E72EE2: ??? (in 
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.7800.4)
        ==972353==    by 0x12E73B82: ??? (in 
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.7800.4)
        ==972353==    by 0x12ED09D9: ??? (in 
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.7800.4)
        ==972353==    by 0x12E72EE2: ??? (in 
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.7800.4)
        ==972353==    by 0x12E72F1C: ??? (in 
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.7800.4)
        ==972353==    by 0x130620D8: ??? (in 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.4)
        ==972353==  Address 0x70 is not stack'd, malloc'd or (recently) free'd
        ==972353==
    
    [1] https://docs.gtk.org/gtk4/iface.Accessible.html
    [2] https://docs.gtk.org/gtk4/section-accessibility.html
    
    Change-Id: I35196ca686e9d56f97bbf884da8b6492358e41fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166708
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx
index 184f6f3be95a..7574e67f5758 100644
--- a/vcl/unx/gtk4/a11y.cxx
+++ b/vcl/unx/gtk4/a11y.cxx
@@ -528,11 +528,9 @@ static GtkATContext* 
lo_accessible_get_at_context(GtkAccessible* self)
 {
     LoAccessible* pAccessible = LO_ACCESSIBLE(self);
 
-    GtkAccessibleRole eRole = map_accessible_role(pAccessible->uno_accessible);
-
-    if (!pAccessible->at_context
-        || gtk_at_context_get_accessible_role(pAccessible->at_context) != 
eRole)
+    if (!pAccessible->at_context)
     {
+        GtkAccessibleRole eRole = 
map_accessible_role(pAccessible->uno_accessible);
         pAccessible->at_context = gtk_at_context_create(eRole, self, 
pAccessible->display);
         if (!pAccessible->at_context)
             return nullptr;
@@ -797,13 +795,13 @@ static GtkATContext* get_at_context(GtkAccessible* self)
 
     css::uno::Reference<css::accessibility::XAccessible> xAccessible(
         get_uno_accessible(GTK_WIDGET(pFixed)));
-    GtkAccessibleRole eRole = map_accessible_role(xAccessible);
 
-    if (!pFixed->at_context || 
gtk_at_context_get_accessible_role(pFixed->at_context) != eRole)
+    if (!pFixed->at_context)
     {
         //        if (pFixed->at_context)
         //            g_clear_object(&pFixed->at_context);
 
+        GtkAccessibleRole eRole = map_accessible_role(xAccessible);
         pFixed->at_context
             = gtk_at_context_create(eRole, self, 
gtk_widget_get_display(GTK_WIDGET(pFixed)));
         if (!pFixed->at_context)

Reply via email to