vcl/inc/qt5/QtMenu.hxx     |    1 +
 vcl/qt5/QtMenu.cxx         |   14 ++++++++++++++
 vcl/unx/generic/app/sm.cxx |    4 +++-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 542e590f6a35a350cb6bc53645462a273017258d
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Jun 13 10:08:25 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Jun 13 15:30:04 2024 +0200

    gen: Handle null client ID when SmcOpenConnection fails
    
    Trying to start LO with the gen/x11 VCL plugin in my KDE Plasma 5
    Wayland session triggered this assert:
    
        soffice.bin: .../libreoffice/sal/rtl/strtmpl.hxx:148: sal_Int32 
rtl::str::getLength(const T *) [T = char]: Assertion `pStr' failed.
    
        Thread 1 "soffice.bin" received signal SIGABRT, Aborted.
        __pthread_kill_implementation (threadid=<optimized out>, 
signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
        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  0x00007ffff78a6b6f in __pthread_kill_internal (signo=6, 
threadid=<optimized out>) at ./nptl/pthread_kill.c:78
        #2  0x00007ffff78584e2 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/posix/raise.c:26
        #3  0x00007ffff78414ed in __GI_abort () at ./stdlib/abort.c:79
        #4  0x00007ffff7841415 in __assert_fail_base
            (fmt=0x7ffff79b7ba8 "%s%s%s:%u: %s%sAssertion `%s' failed.
%n", assertion=assertion@entry=0x7ffff7ea47e1 "pStr", 
file=file@entry=0x7ffff7e9fa78 ".../libreoffice/sal/rtl/strtmpl.hxx", 
line=line@entry=148, function=function@entry=0x7ffff7ea58ba "sal_Int32 
rtl::str::getLength(const T *) [T = char]") at ./assert/assert.c:92
        #5  0x00007ffff7851002 in __assert_fail
            (assertion=0x7ffff7ea47e1 "pStr", file=0x7ffff7e9fa78 
".../libreoffice/sal/rtl/strtmpl.hxx", line=148, function=0x7ffff7ea58ba 
"sal_Int32 rtl::str::getLength(const T *) [T = char]") at ./assert/assert.c:101
        #6  0x00007ffff7f33e2b in rtl::str::getLength<char>(char const*) 
(pStr=0x0) at sal/rtl/strtmpl.hxx:148
        #7  0x00007ffff7f36ac9 in 
rtl::str::newFromStr<_rtl_String>(_rtl_String**, std::remove_extent<decltype 
(_rtl_String::buffer)>::type const*) (ppThis=0x7fffffff7970, pCharStr=0x0) at 
sal/rtl/strtmpl.hxx:862
        #8  0x00007ffff7f32e9d in rtl_string_newFromStr(rtl_String**, char 
const*) (ppThis=0x7fffffff7970, pCharStr=0x0) at 
.../libreoffice/sal/rtl/string.cxx:567
        #9  0x00007fffe46efea7 in rtl::OString::OString<char*>(char* const&, 
rtl::libreoffice_internal::CharPtrDetector<char*, 
rtl::libreoffice_internal::Dummy>::Type) (this=0x7fffffff7970, 
value=@0x7fffffff7978: 0x0)
            at include/rtl/string.hxx:315
        #10 0x00007fffe4711954 in SessionManagerClient::open(SalSession*) 
(pSession=0x5555567f1bf0) at .../libreoffice/vcl/unx/generic/app/sm.cxx:514
        #11 0x00007fffe4710f94 in X11SalInstance::CreateSalSession() 
(this=0x5555555ee3d0) at .../libreoffice/vcl/unx/generic/app/sm.cxx:73
        #12 0x00007fffee985cfc in (anonymous 
namespace)::VCLSession::VCLSession() (this=0x555556903480) at 
.../libreoffice/vcl/source/app/session.cxx:115
        #13 0x00007fffee985ba9 in 
com_sun_star_frame_VCLSessionManagerClient_get_implementation(com::sun::star::uno::XComponentContext*,
 com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) ()
            at .../libreoffice/vcl/source/app/session.cxx:411
        #14 0x00007ffff5bed248 in 
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&>(std::__invoke_other, 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&)
            (__f=@0x5555557170f8: 0x7fffee985b80 
<com_sun_star_frame_VCLSessionManagerClient_get_implementation(com::sun::star::uno::XComponentContext*,
 com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&)>, 
__args=@0x7fffffff8600: 0x5555555e7f08, __args=empty uno::Sequence) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61
        #15 0x00007ffff5bed1e5 in 
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&>(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&)
            (__fn=@0x5555557170f8: 0x7fffee985b80 
<com_sun_star_frame_VCLSessionManagerClient_get_implementation(com::sun::star::uno::XComponentContext*,
 com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&)>, 
__args=@0x7fffffff8600: 0x5555555e7f08, __args=empty uno::Sequence) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:114
        #16 0x00007ffff5bed0dd in 
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&) (__functor=..., 
__args=@0x7fffffff8600: 0x5555555e7f08, __args=empty uno::Sequence) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:290
        #17 0x00007ffff5bb8d98 in 
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 
(this=0x5555557170f8, __args=0x5555555e7f08, __args=empty uno::Sequence) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591
        #18 0x00007ffff5ba1599 in 
cppuhelper::ServiceManager::Data::Implementation::doCreateInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>
 const&)
            (this=0x555555717040, context=uno::Reference to (cppu::(anonymous 
namespace)::ComponentContext *) 0x5555555e7f08) at 
.../libreoffice/cppuhelper/source/servicemanager.cxx:701
        #19 0x00007ffff5ba1461 in 
cppuhelper::ServiceManager::Data::Implementation::createInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>
 const&, bool)
            (this=0x555555717040, context=uno::Reference to (cppu::(anonymous 
namespace)::ComponentContext *) 0x5555555e7f08, singletonRequest=false) at 
.../libreoffice/cppuhelper/source/servicemanager.cxx:670
        #20 0x00007ffff5ba73ad in 
cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, 
com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&)
            (this=0x555555618b60, 
aServiceSpecifier="com.sun.star.frame.SessionManagerClient", 
Context=uno::Reference to (cppu::(anonymous namespace)::ComponentContext *) 
0x5555555e7f08)
            at .../libreoffice/cppuhelper/source/servicemanager.cxx:1002
        #21 0x00007ffff5ba7d94 in non-virtual thunk to 
cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, 
com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) 
()
            at .../libreoffice/instdir/program/libuno_cppuhelpergcc3.so.3
        #22 0x00007ffff4e6a528 in (anonymous 
namespace)::SessionListener::initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any>
 const&) (this=0x555556935c80, args=uno::Sequence of length 1 = {...})
            at .../libreoffice/framework/source/services/sessionlistener.cxx:254
        #23 0x00007ffff5ba1b79 in 
cppuhelper::ServiceManager::Data::Implementation::doCreateInstanceWithArguments(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>
 const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) 
(this=0x555555684900, context=uno::Reference to (cppu::(anonymous 
namespace)::ComponentContext *) 0x5555555e7f08, arguments=uno::Sequence of 
length 1 = {...})
            at .../libreoffice/cppuhelper/source/servicemanager.cxx:727
        #24 0x00007ffff5ba19e3 in 
cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>
 const&, bool, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) 
(this=0x555555684900, context=uno::Reference to (cppu::(anonymous 
namespace)::ComponentContext *) 0x5555555e7f08, singletonRequest=false, 
arguments=uno::Sequence of length 1 = {...})
            at .../libreoffice/cppuhelper/source/servicemanager.cxx:689
        #25 0x00007ffff5ba7e35 in 
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&) 
(this=0x555555618b60, ServiceSpecifier="com.sun.star.frame.SessionListener", 
Arguments=uno::Sequence of length 1 = {...}, Context=uno::Reference to 
(cppu::(anonymous namespace)::ComponentContext *) 0x5555555e7f08)
            at .../libreoffice/cppuhelper/source/servicemanager.cxx:1014
        #26 0x00007ffff5ba7eec in 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&) 
() at .../libreoffice/cppuhelper/source/servicemanager.cxx:1015
        #27 0x00007ffff7b3787f in 
com::sun::star::frame::SessionListener::createWithOnQuitFlag(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>
 const&, unsigned char)
            (the_context=uno::Reference to (cppu::(anonymous 
namespace)::ComponentContext *) 0x5555555e7f08, AllowUserInteractionOnQuit=0 '
        #28 0x00007ffff7b2c353 in desktop::Desktop::OpenClients() () at 
.../libreoffice/desktop/source/app/app.cxx:2094
        #29 0x00007ffff7b2b0a3 in desktop::Desktop::OpenClients_Impl(void*) 
(this=0x7fffffffd708) at .../libreoffice/desktop/source/app/app.cxx:1952
        #30 0x00007ffff7b2939d in 
desktop::Desktop::LinkStubOpenClients_Impl(void*, void*) 
(instance=0x7fffffffd708, data=0x0) at 
.../libreoffice/desktop/source/app/app.cxx:1936
        --Type <RET> for more, q to quit, c to continue without paging--
        #31 0x00007fffee140c78 in Link<void*, void>::Call(void*) const 
(this=0x555556f67218, data=0x0) at include/tools/link.hxx:111
        #32 0x00007fffee13c959 in ImplHandleUserEvent(ImplSVEvent*) 
(pSVEvent=0x555556f67210) at .../libreoffice/vcl/source/window/winproc.cxx:2287
        #33 0x00007fffee139310 in ImplWindowFrameProc(vcl::Window*, SalEvent, 
void const*) (_pWindow=0x555556dcc250, nEvent=SalEvent::UserEvent, 
pEvent=0x555556f67210)
            at .../libreoffice/vcl/source/window/winproc.cxx:2851
        #34 0x00007fffeedb53e0 in SalFrame::CallCallback(SalEvent, void const*) 
const (this=0x5555568f41f0, nEvent=SalEvent::UserEvent, pEvent=0x555556f67210) 
at vcl/inc/salframe.hxx:312
        #35 0x00007fffeeddff6f in 
SalGenericDisplay::ProcessEvent(SalUserEventList::SalUserEvent) 
(this=0x5555567e8960, aEvent=...) at 
.../libreoffice/vcl/unx/generic/app/gendisp.cxx:66
        #36 0x00007fffee8d856d in 
SalUserEventList::DispatchUserEvents(bool)::$_0::operator()() const 
(this=0x7fffffffb240) at .../libreoffice/vcl/source/app/salusereventlist.cxx:119
        #37 0x00007fffee8d8414 in SalUserEventList::DispatchUserEvents(bool) 
(this=0x5555567e8960, bHandleAllCurrentEvents=false) at 
.../libreoffice/vcl/source/app/salusereventlist.cxx:120
        #38 0x00007fffeeddfec5 in 
SalGenericDisplay::DispatchInternalEvent(bool) (this=0x5555567e8960, 
bHandleAllCurrentEvent=false) at 
.../libreoffice/vcl/unx/generic/app/gendisp.cxx:51
        #39 0x00007fffe46feb44 in SalX11Display::Yield() (this=0x5555567e8960) 
at .../libreoffice/vcl/unx/generic/app/saldisp.cxx:1860
        #40 0x00007fffe46f2e97 in DisplayYield(int, void*) (fd=5, 
data=0x5555567e8960) at .../libreoffice/vcl/unx/generic/app/saldisp.cxx:321
        #41 0x00007fffe46ee64c in (anonymous 
namespace)::YieldEntry::HandleNextEvent() const (this=0x7fffe47fe078 
<yieldTable+200>) at .../libreoffice/vcl/unx/generic/app/saldata.cxx:559
        #42 0x00007fffe46ede15 in SalXLib::Yield(bool, bool) 
(this=0x5555555ee6e0, bWait=true, bHandleAllCurrentEvents=false) at 
.../libreoffice/vcl/unx/generic/app/saldata.cxx:655
        #43 0x00007fffe470ce8d in X11SalInstance::DoYield(bool, bool) 
(this=0x5555555ee3d0, bWait=true, bHandleAllCurrentEvents=false) at 
.../libreoffice/vcl/unx/generic/app/salinst.cxx:192
        #44 0x00007fffee9b8e6c in ImplYield(bool, bool) (i_bWait=true, 
i_bAllEvents=false) at .../libreoffice/vcl/source/app/svapp.cxx:384
        #45 0x00007fffee9b877b in Application::Yield() () at 
.../libreoffice/vcl/source/app/svapp.cxx:472
        #46 0x00007fffee9b8512 in Application::Execute() () at 
.../libreoffice/vcl/source/app/svapp.cxx:359
        #47 0x00007ffff7b26f10 in desktop::Desktop::Main() 
(this=0x7fffffffd708) at .../libreoffice/desktop/source/app/app.cxx:1652
        #48 0x00007fffee9dba7e in ImplSVMain() () at 
.../libreoffice/vcl/source/app/svmain.cxx:229
        #49 0x00007fffee9ddaa9 in SVMain() () at 
.../libreoffice/vcl/source/app/svmain.cxx:261
        #50 0x00007ffff7baaa7c in soffice_main() () at 
.../libreoffice/desktop/source/app/sofficemain.cxx:99
        #51 0x0000555555555a5d in sal_main () at 
.../libreoffice/desktop/source/app/main.c:51
        #52 0x0000555555555a37 in main (argc=2, argv=0x7fffffffd918) at 
.../libreoffice/desktop/source/app/main.c:49
    
    `SmcOpenConnection` in frame 10 above failed, `pClientID` is null:
    
        (gdb) frame 10
        #10 0x00007fffe4711954 in SessionManagerClient::open 
(pSession=0x5555567f1bf0) at .../libreoffice/vcl/unx/generic/app/sm.cxx:514
        514                 m_aClientID = OString(pClientID);
        (gdb) p pClientID
        $1 = 0x0
        (gdb) l
        509                                                       aErrBuf );
        510                 if( !m_pSmcConnection )
        511                     SAL_INFO("vcl.sm.debug", "  SmcOpenConnection 
failed: " << aErrBuf);
        512                 else
        513                     SAL_INFO("vcl.sm.debug", "  SmcOpenConnection 
succeeded, client ID is " << pClientID );
        514                 m_aClientID = OString(pClientID);
        515                 free( pClientID );
        516                 pClientID = nullptr;
        517             }
        518
        (gdb) p aErrBuf
        $2 = "None of the authentication protocols specified are supported", '
    
    Add a null check.
    
    Quoting from [1]:
    
    > If SmcOpenConnection succeeds, it returns an opaque connection pointer of 
type SmcConn and
    > the client_id_ret argument contains the client ID to be used for this 
session.
    
    [1] https://www.x.org/releases/X11R7.6/doc/libSM/SMlib.html
    
    Change-Id: I412b5a68e88548718231354b0410c56bc0f0bb90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168771
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx
index 071ac32fdbe1..b38ea0184d82 100644
--- a/vcl/unx/generic/app/sm.cxx
+++ b/vcl/unx/generic/app/sm.cxx
@@ -511,7 +511,9 @@ void SessionManagerClient::open(SalSession * pSession)
                 SAL_INFO("vcl.sm.debug", "  SmcOpenConnection failed: " << 
aErrBuf);
             else
                 SAL_INFO("vcl.sm.debug", "  SmcOpenConnection succeeded, 
client ID is " << pClientID );
-            m_aClientID = OString(pClientID);
+
+            if (pClientID)
+                m_aClientID = OString(pClientID);
             free( pClientID );
             pClientID = nullptr;
         }
commit f281b70282bcead3fca9c5a783e4584144d92a51
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Jun 13 09:05:52 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Jun 13 15:29:49 2024 +0200

    tdf#160462 qt a11y: Open menu bar on F10
    
    F10 is used as a shortcut to open the menu bar (or main menu)
    on various platforms and toolkits, and KDE adapted that
    for KF 6 as well, see [1].
    
    Do the same for the Qt-based VCL plugins: Connect a slot
    to the F10 shortcut that opens the first menu item.
    
    [1] https://wordsmith.social/felix-ernst/f10-for-accessibility-in-kf6
    
    Change-Id: I27e34f87a115b89e047b08aed334207c64b0b9e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168765
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 28e5ac57146b..24d56333a067 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -113,6 +113,7 @@ private slots:
     static void slotMenuAboutToHide(QtMenuItem* pQItem);
     void slotCloseDocument();
     void slotMenuBarButtonClicked(QAbstractButton*);
+    void slotShortcutF10();
 };
 
 class QtMenuItem : public SalMenuItem
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index e3494356fc8b..5b76706f22b3 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -457,6 +457,11 @@ void QtMenu::SetFrame(const SalFrame* pFrame)
     mpQMenuBar = new QMenuBar();
     pMainWindow->setMenuBar(mpQMenuBar);
 
+    // open menu bar on F10, as is common in KF 6 and other toolkits:
+    // https://wordsmith.social/felix-ernst/f10-for-accessibility-in-kf6
+    QShortcut* pQShortcut = new QShortcut(QKeySequence(Qt::Key_F10), 
mpQMenuBar->window());
+    connect(pQShortcut, &QShortcut::activated, this, &QtMenu::slotShortcutF10);
+
     QWidget* pWidget = mpQMenuBar->cornerWidget(Qt::TopRightCorner);
     if (pWidget)
     {
@@ -697,6 +702,15 @@ void QtMenu::slotMenuBarButtonClicked(QAbstractButton* 
pButton)
     }
 }
 
+void QtMenu::slotShortcutF10()
+{
+    SolarMutexGuard aGuard;
+
+    // focus menu bar and select first item
+    if (mpQMenuBar && !mpQMenuBar->actions().empty())
+        mpQMenuBar->setActiveAction(mpQMenuBar->actions().at(0));
+}
+
 QPushButton* QtMenu::ImplAddMenuBarButton(const QIcon& rIcon, const QString& 
rToolTip, int nId)
 {
     if (!validateQMenuBar())

Reply via email to