Files
libreoffice/vcl/qt5/QtInstanceMessageDialog.cxx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

275 lines
8.0 KiB
C++
Raw Normal View History

/* -*- 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 <QtInstanceMessageDialog.hxx>
#include <QtInstanceMessageDialog.moc>
#include <QtWidgets/QPushButton>
/**
* Name of the property to set on a QPushButton that holds the
* VCL response code of that button.
*/
const char* const PROPERTY_VCL_RESPONSE_CODE = "response-code";
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
QtInstanceMessageDialog::QtInstanceMessageDialog(QMessageBox* pMessageDialog)
: QtInstanceDialog(pMessageDialog)
, m_pMessageDialog(pMessageDialog)
, m_aRunAsyncFunc(nullptr)
{
assert(m_pMessageDialog);
}
void QtInstanceMessageDialog::set_primary_text(const rtl::OUString& rText)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { set_primary_text(rText); });
return;
}
m_pMessageDialog->setText(toQString(rText));
}
void QtInstanceMessageDialog::set_secondary_text(const rtl::OUString& rText)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { set_secondary_text(rText); });
return;
}
m_pMessageDialog->setInformativeText(toQString(rText));
}
weld::Container* QtInstanceMessageDialog::weld_message_area() { return nullptr; }
OUString QtInstanceMessageDialog::get_primary_text() const
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
OUString sText;
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { sText = get_primary_text(); });
return sText;
}
assert(m_pMessageDialog);
return toOUString(m_pMessageDialog->text());
}
OUString QtInstanceMessageDialog::get_secondary_text() const
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
OUString sText;
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { sText = get_secondary_text(); });
return sText;
}
assert(m_pMessageDialog);
return toOUString(m_pMessageDialog->informativeText());
}
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
void QtInstanceMessageDialog::add_button(const OUString& rText, int nResponse, const OUString&)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { add_button(rText, nResponse); });
return;
}
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
assert(m_pMessageDialog);
QPushButton* pButton = m_pMessageDialog->addButton(vclToQtStringWithAccelerator(rText),
QMessageBox::ButtonRole::ActionRole);
pButton->setProperty(PROPERTY_VCL_RESPONSE_CODE, QVariant::fromValue(nResponse));
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
}
void QtInstanceMessageDialog::set_default_response(int nResponse)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { set_default_response(nResponse); });
return;
}
assert(m_pMessageDialog);
QPushButton* pButton = buttonForResponseCode(nResponse);
if (pButton)
m_pMessageDialog->setDefaultButton(pButton);
}
QtInstanceButton* QtInstanceMessageDialog::weld_widget_for_response(int nResponse)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
QtInstanceButton* pButton;
pQtInstance->RunInMainThread([&] { pButton = weld_widget_for_response(nResponse); });
return pButton;
}
if (QPushButton* pButton = buttonForResponseCode(nResponse))
return new QtInstanceButton(pButton);
return nullptr;
}
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
int QtInstanceMessageDialog::run()
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
int nRet = 0;
pQtInstance->RunInMainThread([&] { nRet = run(); });
return nRet;
}
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
m_pMessageDialog->exec();
QAbstractButton* pClickedButton = m_pMessageDialog->clickedButton();
if (!pClickedButton)
return RET_CLOSE;
return pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
tdf#154381 qt weld: Add button handling for message box Override the `QtInstanceDialog` methods `add_button` and `run` in `QtInstanceMessageDialog`, and implement handling for these buttons with the native `QMessageBox` that is used internally: Implement `QtInstanceMessageDialog::add_button` to make adding buttons to the welded message dialog work. Map the VCL response type to a corresponding `QMessageBox::ButtonRole`. Some mappings are straightforward, others are a bit more arbitrary, but the only essential thing is that the mapping back to the VCL response code is consistent. `QMessageBox::exec` [1] overrides `QDialog::exec` [2], and while the int returned by the latter corresponds to a `QDialog::DialogCode` code, the int returned by the former corresponds to a `QMessageBox::StandardButton` value. Since the current `QtInstanceDialog::run` implementation relies on the `QDialog` behaviour, override it for the message dialog case. Since the `QMessageBox::ButtonRole` is set in `QtInstanceMessageDialog::add_button`, retrieve the corresponding role from the clicked button instead of using the return value of the `QMessageBox::exec` to be able to get the correct VCL return code again. With this in place, the qt6 welded message dialog that shows up when opening a file that's already open in another instance of LibreOffice (s. `AlreadyOpenQueryBox::AlreadyOpenQueryBox`) shows buttons and clicking any of them behaves as expected, just as is the case for the non-welded one (whose use can be forced by setting env var `SAL_VCL_QT_NO_WELDED_WIDGETS=1`). [1] https://doc.qt.io/qt-6/qmessagebox.html#exec` [2] https://doc.qt.io/qt-6/qdialog.html#exec Change-Id: Ie37573951302f13eab758f889d478dc9351e9c07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162440 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-23 13:47:21 +01:00
}
bool QtInstanceMessageDialog::runAsync(const std::shared_ptr<weld::DialogController>& rxOwner,
const std::function<void(sal_Int32)>& func)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
bool bRet = false;
pQtInstance->RunInMainThread([&] { bRet = runAsync(rxOwner, func); });
return bRet;
}
assert(m_pMessageDialog);
m_xRunAsyncDialogController = rxOwner;
m_aRunAsyncFunc = func;
connect(m_pMessageDialog, &QDialog::finished, this, &QtInstanceMessageDialog::dialogFinished);
m_pMessageDialog->open();
return true;
}
bool QtInstanceMessageDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
const std::function<void(sal_Int32)>& func)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
bool bRet;
pQtInstance->RunInMainThread([&] { bRet = runAsync(rxSelf, func); });
return bRet;
}
assert(m_pMessageDialog);
assert(rxSelf.get() == this);
m_xRunAsyncDialog = rxSelf;
m_aRunAsyncFunc = func;
connect(m_pMessageDialog, &QDialog::finished, this, &QtInstanceMessageDialog::dialogFinished);
m_pMessageDialog->open();
return true;
}
void QtInstanceMessageDialog::response(int nResponse)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { response(nResponse); });
return;
}
assert(m_pMessageDialog);
m_pMessageDialog->done(nResponse);
}
void QtInstanceMessageDialog::dialogFinished(int nResult)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
pQtInstance->RunInMainThread([&] { dialogFinished(nResult); });
return;
}
assert(m_aRunAsyncFunc);
disconnect(m_pMessageDialog, &QDialog::finished, this,
&QtInstanceMessageDialog::dialogFinished);
// use local variables for these, as members might have got de-allocated by the time they're reset
std::shared_ptr<weld::Dialog> xRunAsyncDialog = m_xRunAsyncDialog;
std::shared_ptr<weld::DialogController> xRunAsyncDialogController = m_xRunAsyncDialogController;
std::function<void(sal_Int32)> aFunc = m_aRunAsyncFunc;
m_aRunAsyncFunc = nullptr;
m_xRunAsyncDialogController.reset();
m_xRunAsyncDialog.reset();
// if a button was clicked, use its response code, otherwise the passed one
int nRet = nResult;
if (QAbstractButton* pClickedButton = m_pMessageDialog->clickedButton())
nRet = pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
aFunc(nRet);
xRunAsyncDialogController.reset();
xRunAsyncDialog.reset();
}
QPushButton* QtInstanceMessageDialog::buttonForResponseCode(int nResponse)
{
tdf#162696 qt weld: Do GUI things in main thread Creating or modifying native Qt UI elements needs to happen in the main thread. This commit takes care of the obvious cases where such interaction happens. Otherwise, the tdf#162696 scenario triggers asserts like the following with a Qt debug build: ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp, line 958 terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' Fatal exception: Signal 6 Stack: #0 sal::backtrace_get(unsigned int) at /home/michi/development/git/libreoffice/sal/osl/unx/backtraceapi.cxx:42 #1 (anonymous namespace)::printStack(int) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:289 #2 (anonymous namespace)::callSystemHandler(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:330 #3 (anonymous namespace)::signalHandlerFunction(int, siginfo_t*, void*) at /home/michi/development/git/libreoffice/sal/osl/unx/signal.cxx:427 #4 /lib/x86_64-linux-gnu/libc.so.6(+0x3f590) [0x7fdb05455590] #5 __pthread_kill_implementation at ./nptl/pthread_kill.c:44 (discriminator 1) #6 raise at ./signal/../sysdeps/posix/raise.c:27 #7 abort at ./stdlib/abort.c:81 #8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa1a3d) [0x7fdb050a1a3d] #9 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xb306a) [0x7fdb050b306a] #10 std::unexpected() in /lib/x86_64-linux-gnu/libstdc++.so.6 #11 /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so.6(+0xed562) [0x7fdaf0eed562] #12 QMessageLogger::fatal() const at /home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:901 #13 qt_assert_x(char const*, char const*, char const*, int) at /home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:0 #14 QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:959 #15 QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:878 #16 QDialog::QDialog(QDialogPrivate&, QWidget*, QFlags<Qt::WindowType>) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qdialog.cpp:377 #17 QMessageBox::QMessageBox(QWidget*) at /home/michi/development/git/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp:838 #18 QtInstance::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&) at /home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtInstance.cxx:825 #19 Application::CreateMessageDialog(weld::Widget*, VclMessageType, VclButtonsType, rtl::OUString const&, vcl::ILibreOfficeKitNotifier const*) at /home/michi/development/git/libreoffice/vcl/source/window/builder.cxx:224 #20 dp_gui::DialogHelper::installExtensionWarn(std::basic_string_view<char16_t, std::char_traits<char16_t>>) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_dialog2.cxx:371 #21 dp_gui::(anonymous namespace)::ProgressCmdEnv::handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:477 #22 dp_misc::interactContinuation(com::sun::star::uno::Any const&, com::sun::star::uno::Type const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, bool*, bool*) at /home/michi/development/git/libreoffice/desktop/source/deployment/misc/dp_interact.cxx:114 #23 dp_manager::ExtensionManager::checkInstall(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:1315 #24 dp_manager::ExtensionManager::doChecksForAddExtension(com::sun::star::uno::Reference<com::sun::star::deployment::XPackageManager> const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage> const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&, com::sun::star::uno::Reference<com::sun::star::deployment::XPackage>&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:565 #25 dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:655 #26 non-virtual thunk to dp_manager::ExtensionManager::addExtension(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::task::XAbortChannel> const&, com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> const&) at /home/michi/development/git/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.cxx:0 #27 dp_gui::ExtensionCmdQueue::Thread::_addExtension(rtl::Reference<dp_gui::(anonymous namespace)::ProgressCmdEnv> const&, rtl::OUString const&, rtl::OUString const&, bool) at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:864 #28 dp_gui::ExtensionCmdQueue::Thread::execute() at /home/michi/development/git/libreoffice/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx:738 #29 salhelper::Thread::run() at /home/michi/development/git/libreoffice/salhelper/source/thread.cxx:39 #30 threadFunc at /home/michi/development/git/libreoffice/include/osl/thread.hxx:190 #31 osl_thread_start_Impl(void*) at /home/michi/development/git/libreoffice/sal/osl/unx/thread.cxx:245 #32 start_thread at ./nptl/pthread_create.c:447 #33 clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80 Change-Id: Ifa84a038fc56f34958cd732caeb9c436b48b3c75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172642 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 10:12:21 +02:00
SolarMutexGuard g;
QtInstance* pQtInstance = GetQtInstance();
if (!pQtInstance->IsMainThread())
{
QPushButton* pButton;
pQtInstance->RunInMainThread([&] { pButton = buttonForResponseCode(nResponse); });
return pButton;
}
assert(m_pMessageDialog);
const QList<QAbstractButton*> aButtons = m_pMessageDialog->buttons();
for (QAbstractButton* pAbstractButton : aButtons)
{
if (pAbstractButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt() == nResponse)
{
QPushButton* pButton = dynamic_cast<QPushButton*>(pAbstractButton);
assert(pButton);
return pButton;
}
}
return nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */