office-gobmx/vcl/qt5/QtInstanceLinkButton.cxx
Michael Weghorn 226980d063 tdf#130857 qt weld: Take SolarMutex in QtInstanceLinkButton::linkActivated
Apparently the expectation is that the SolarMutex
is held when calling weld::signal_activate_link.
At least, not doing so would trigger an assert when
clicking a hyperlink in the "Help" -> "Show Tip of the Day"
dialog when using the qt6 VCL plugin started with
SAL_VCL_QT_USE_WELDED_WIDGETS=1 set:

    1 __pthread_kill_implementation pthread_kill.c 44 0x7f083869de5c
    2 __pthread_kill_internal pthread_kill.c 78 0x7f083869debf
    3 __GI_raise raise.c 26 0x7f0838649c82
    4 __GI_abort abort.c 79 0x7f08386324f0
    5 __assert_fail_base assert.c 94 0x7f0838632418
    6 __assert_fail assert.c 103 0x7f0838642592
    7 ImplDbgTestSolarMutex dbggui.cxx 35 0x7f082fa2dd3e
    8 DbgTestSolarMutex debug.cxx 54 0x7f0837b2bec0
    9 vcl::WindowOutputDevice::AcquireGraphics window.cxx 822 0x7f082f306276
    10 OutputDevice::IsNativeControlSupported nativecontrols.cxx 139 0x7f082f584492
    11 vcl::Window::IsNativeControlSupported window3.cxx 77 0x7f082f2fd8b9
    12 Dialog::ImplInitSettings dialog.cxx 524 0x7f082f167189
    13 Dialog::ImplInitDialog dialog.cxx 495 0x7f082f167086
    14 Dialog::Dialog dialog.cxx 586 0x7f082f167d92
    15 MessageDialog::MessageDialog layout.cxx 2521 0x7f082f1df4a6
    16 VclPtr<MessageDialog>::Create<vcl::Window *&, long&> vclptr.hxx 129 0x7f082f0e8fa6
    17 VclBuilder::makeObject builder.cxx 1605 0x7f082f0c5326
    18 VclBuilder::insertObject builder.cxx 2454 0x7f082f0d09eb
    19 WidgetBuilder<vcl::Window, VclPtr<vcl::Window>>::handleObject widgetbuilder.hxx 213 0x7f082f145937
    20 WidgetBuilder<vcl::Window, VclPtr<vcl::Window>>::handleChild widgetbuilder.hxx 107 0x7f082f0f13ce
    21 WidgetBuilder<vcl::Window, VclPtr<vcl::Window>>::processUIFile widgetbuilder.hxx 49 0x7f082f0e1b78
    22 VclBuilder::VclBuilder builder.cxx 520 0x7f082f0ba596
    23 SalInstanceBuilder::SalInstanceBuilder salvtables.cxx 7088 0x7f082fa7b318
    24 std::make_unique<SalInstanceBuilder, vcl::Window *&, rtl::OUString const&, rtl::OUString const&> unique_ptr.h 1077 0x7f082fa99ef9
    25 SalInstance::CreateBuilder salvtables.cxx 7470 0x7f082fa7f468
    26 QtInstance::CreateBuilder QtInstance.cxx 843 0x7f08254e89e5
    27 non-virtual thunk to QtInstance::CreateBuilder(weld::Widget *, rtl::OUString const&, rtl::OUString const&) 0x7f08254e8a4c
    28 Application::CreateBuilder builder.cxx 198 0x7f082f0b7f02
    29 weld::MessageDialogController::MessageDialogController weldutils.cxx 65 0x7f082fb52635
    30 (anonymous namespace)::HelpManualMessage::HelpManualMessage sfxhelp.cxx 958 0x7f0834939fb0
    31 SfxHelp::Start_Impl sfxhelp.cxx 1283 0x7f08349369ec
    32 SfxHelp::Start sfxhelp.cxx 642 0x7f08349389fe
    33 TipOfTheDayDialog::OnLinkClick tipofthedaydlg.cxx 261 0x7f07b37ebb64
    34 TipOfTheDayDialog::LinkStubOnLinkClick tipofthedaydlg.cxx 251 0x7f07b37eb99d
    35 Link<weld::LinkButton&, bool>::Call link.hxx 111 0x7f082552dc26
    36 weld::LinkButton::signal_activate_link weld.hxx 1688 0x7f082552d95c
    37 QtInstanceLinkButton::linkActivated QtInstanceLinkButton.cxx 58 0x7f082552ba6d
    38 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QtInstanceLinkButton:: *)(QString const&)>::call(void (QtInstanceLinkButton:: *)(QString const&), QtInstanceLinkButton *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 127 0x7f082552e074
    39 QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QtInstanceLinkButton:: *)(QString const&)>::call(void (QtInstanceLinkButton:: *)(QString const&), QtInstanceLinkButton *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QtInstanceLinkButton:: *)(QString const&)>::call(void (QtInstanceLinkButton:: *)(QString const&), QtInstanceLinkButton *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 65 0x7f082552df99
    40 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QtInstanceLinkButton:: *)(QString const&)>::call qobjectdefs_impl.h 126 0x7f082552ded3
    41 QtPrivate::FunctionPointer<void (QtInstanceLinkButton:: *)(QString const&)>::call<QtPrivate::List<QString const&>, void> qobjectdefs_impl.h 174 0x7f082552de4d
    42 QtPrivate::QCallableObject<void (QtInstanceLinkButton:: *)(QString const&), QtPrivate::List<QString const&>, void>::impl qobjectdefs_impl.h 545 0x7f082552dd76
    43 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 461 0x7f082465ab72
    44 doActivate<false> qobject.cpp 4127 0x7f0824718ee4
    45 QMetaObject::activate qobject.cpp 4187 0x7f082470eb83
    46 QLabel::linkActivated moc_qlabel.cpp 386 0x7f08228ddb72
    47 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLabel:: *)(QString const&)>::call(void (QLabel:: *)(QString const&), QLabel *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 127 0x7f08228e29a8
    48 QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLabel:: *)(QString const&)>::call(void (QLabel:: *)(QString const&), QLabel *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLabel:: *)(QString const&)>::call(void (QLabel:: *)(QString const&), QLabel *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 65 0x7f08228e291d
    49 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLabel:: *)(QString const&)>::call qobjectdefs_impl.h 126 0x7f08228e28d7
    50 QtPrivate::FunctionPointer<void (QLabel:: *)(QString const&)>::call<QtPrivate::List<QString const&>, void> qobjectdefs_impl.h 174 0x7f08228e2841
    51 QtPrivate::QCallableObject<void (QLabel:: *)(QString const&), QtPrivate::List<QString const&>, void>::impl qobjectdefs_impl.h 545 0x7f08228e276b
    52 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 461 0x7f082465ab72
    53 doActivate<false> qobject.cpp 4127 0x7f0824718ee4
    54 QMetaObject::activate qobject.cpp 4187 0x7f082470eb83
    55 QWidgetTextControl::linkActivated moc_qwidgettextcontrol_p.cpp 806 0x7f0822a5a415
    56 QWidgetTextControlPrivate::activateLinkUnderCursor qwidgettextcontrol.cpp 2962 0x7f0822a544c1
    57 QWidgetTextControlPrivate::keyPressEvent qwidgettextcontrol.cpp 1242 0x7f0822a50454
    58 QWidgetTextControl::processEvent qwidgettextcontrol.cpp 1024 0x7f0822a4f23b
    59 QWidgetTextControl::processEvent qwidgettextcontrol.cpp 984 0x7f0822a4f0c1
    60 QLabelPrivate::sendControlEvent qlabel.cpp 1557 0x7f08228db3c4
    61 QLabel::keyPressEvent qlabel.cpp 912 0x7f08228db7fe
    [...]

Change-Id: I20f11ff2e7c00e65098bd7fb39afefdc4a622138
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176175
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-11-07 09:54:11 +01:00

65 lines
1.8 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <QtInstanceLinkButton.hxx>
#include <QtInstanceLinkButton.moc>
#include <vcl/qt/QtUtils.hxx>
#include <QtGui/QDesktopServices>
QtInstanceLinkButton::QtInstanceLinkButton(QtHyperlinkLabel* pLabel)
: QtInstanceWidget(pLabel)
, m_pLabel(pLabel)
{
assert(m_pLabel);
connect(m_pLabel, &QtHyperlinkLabel::linkActivated, this, &QtInstanceLinkButton::linkActivated);
}
void QtInstanceLinkButton::set_label(const OUString& rText)
{
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] { m_pLabel->setDisplayText(toQString(rText)); });
}
OUString QtInstanceLinkButton::get_label() const
{
SolarMutexGuard g;
OUString sLabel;
GetQtInstance().RunInMainThread([&] { sLabel = toOUString(m_pLabel->displayText()); });
return sLabel;
}
void QtInstanceLinkButton::set_label_wrap(bool) { assert(false && "Not implemented yet"); }
void QtInstanceLinkButton::set_uri(const OUString& rUri)
{
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] { m_pLabel->setUri(toQString(rUri)); });
}
OUString QtInstanceLinkButton::get_uri() const
{
SolarMutexGuard g;
OUString sUri;
GetQtInstance().RunInMainThread([&] { sUri = toOUString(m_pLabel->uri()); });
return sUri;
}
void QtInstanceLinkButton::linkActivated(const QString& rUrl)
{
SolarMutexGuard g;
if (signal_activate_link())
return;
QDesktopServices::openUrl(rUrl);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */