vcl/qt5/QtFrame.cxx |   28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 2f4103da5625a9b90eb41d5c767a248a8d0b4255
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 17 17:02:49 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat May 18 06:55:31 2024 +0200

    tdf#160565 tdf#145735 qt: Avoid native window handles for Qt 6
    
    Similar to the tdf#122293 scenario with Qt 5 on Wayland,
    using native windows causes unresponsive UI even with
    the xcb Qt QPA plugin when using Qt 6.
    
    Therefore, don't call `QWidget::winId()` at all when
    using Qt 6, but just refuse to resolve a native window
    handle, the same way that is already done here for the
    wayland Qt QPA plugin with qt5.
    
    Add a comment based on the one originally added with
    
        commit 0e3c3b842e14b9646d3697cf1266be21359e0f13
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Sat May 11 21:31:33 2019 +0200
    
            tdf#122293 qt5: Use "alien widgets" by default on Wayland
    
    that was later dropped during a refactoring.
    
    This code path is triggered when trying to resolve the
    parent window for a file picker (s. `QtFilePicker::initialize`).
    In a quick test in a KDE Plasma 5 Wayland session on Debian testing,
    the modality behavior was unchanged with or without this change in
    place:
    
    * With qt6 xcb, the main window nicely gets grayed out and is
      unresponsive while the file dialog gets shown  when using
      e.g. "File" -> "Open" in Writer.
    
    * With qt6 wayland, the main window is not grayed out and looks
      more "active" still, but doesn't actually accept keyboard
      or mouse input.
    
    This is basically the same in other Qt/KDE applications, e.g.
    a self-compiled Kate from git master, so not LO-specific.
    
    If resolving the parent for the file picker turns out to be necessary,
    maybe something similar to what commit
    
        commit 3ff4800fe400de916c97f587322104af06cc0879
        Author: Caolán McNamara <caol...@redhat.com>
        Date:   Wed Apr 4 10:22:34 2018 +0100
    
            weld SvInsertOleDlg
    
            and
    
            weld SfxInsertFloatingFrameDialog
    
            and smuggle in the parent widget for the Gtk File dialog via
            an XWindow interface
    
    did for gtk3 might be worth looking into.
    
    However, I can at least not reproduce issues like the one described
    for gtk3 in
    
        commit 203d96787969f707c78101be18d51b44ace98f93
        Author: Caolán McNamara <caol...@redhat.com>
        Date:   Mon Jun 21 13:01:52 2021 +0100
    
            give folderpicker an optional parent
    
            so, like a file picker, it can make its parent modal while its
            operating. Otherwise its possible to interact with the parent 
dialog in
            undesirable ways, e.g. file, export as, export as epub, the folder
            picker of 'media directory'
    
    with the qt6 VCL plugin even with this commit in place.
    
    Another scenario relying on a native window handle is video
    playback with GStreamer's x11 video sink.
    
    That still works for qt5 with the xcb plugin as the handle is
    still returned for that one.
    
    For qt6 with the xcb plugin, that didn't work properly
    without this commit either (at least not in my tests with
    current qtbase dev as of commit
    70a2e7f32b9f9ce19d1538f14fbde7b0d1e77ffd), s.
    tdf#145735 comment 7.
    It's now broken a different way than before
    (extra windows show up instead of no video being shown).
    This will be further tracked together with a solution for
    Wayland in tdf#125219.
    
    As a side note, forcing native windows for everything
    using `QT_USE_NATIVE_WINDOWS=1` as described at [1]
    causes more sever brokenness with the qt6 xcb plugin
    (mostly black window in Writer instead of showing the
    actual content).
    
    [1] https://doc.qt.io/qt-6/qwidget.html#native-widgets-vs-alien-widgets
    
    Change-Id: I9718c680bd8bc4ff0574f171403d965c1beac781
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167783
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 0ff940408769..0950b520cb77 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -35,6 +35,7 @@
 #include <QtX11Support.hxx>
 #endif
 
+#include <QtCore/QLibraryInfo>
 #include <QtCore/QMimeData>
 #include <QtCore/QPoint>
 #include <QtCore/QSize>
@@ -1355,8 +1356,17 @@ void QtFrame::ResolveWindowHandle(SystemEnvData& rData) 
const
     if (!rData.pWidget)
         return;
     assert(rData.platform != SystemEnvData::Platform::Invalid);
-    if (rData.platform != SystemEnvData::Platform::Wayland)
+    // Calling QWidget::winId() implicitly enables native windows to be used 
instead
+    // of "alien widgets" that don't have a native widget asscoiated with them,
+    // s. https://doc.qt.io/qt-6/qwidget.html#native-widgets-vs-alien-widgets
+    // Avoid native widgets with Qt 5 on Wayland and with Qt 6 altogether as 
they
+    // cause unsresponsive UI, s. tdf#122293/QTBUG-75766 and tdf#160565
+    // (for qt5 xcb, they're needed for video playback)
+    if (rData.platform != SystemEnvData::Platform::Wayland
+        && QLibraryInfo::version().majorVersion() < 6)
+    {
         rData.SetWindowHandle(static_cast<QWidget*>(rData.pWidget)->winId());
+    }
 }
 
 bool QtFrame::GetUseReducedAnimation() const { return 
GetQtInstance()->GetUseReducedAnimation(); }
commit 12f51f079a7ef3a0f2cc7a9942835de810d4e943
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 17 14:32:32 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat May 18 06:55:24 2024 +0200

    qt: Run QtFrame::SetWindowState in main thread
    
    Fixes this crash/assertion seen when starting Writer with
    the qt6 VCL plugin with a fresh user profile with qtbase debug
    build (as of commit 70a2e7f32b9f9ce19d1538f14fbde7b0d1e77ffd):
    
        ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to 
objects owned by a different thread. Current thread 0x0x7fff9c454020. Receiver 
'QtMainWindowClassWindow' (of type 'QWidgetWindow') was created in thread 
0x0x55555560dc50", file 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp, 
line 547
    
        Thread 19 "soffice.bin" received signal SIGABRT, Aborted.
        [Switching to Thread 0x7fffada006c0 (LWP 10947)]
        __pthread_kill_implementation (threadid=<optimized out>, 
signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
        44      ./nptl/pthread_kill.c: No such file or directory.
        (gdb) bt
        #0  __pthread_kill_implementation (threadid=<optimized out>, 
signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
        #1  0x00007ffff78a6b7f in __pthread_kill_internal (signo=6, 
threadid=<optimized out>) at ./nptl/pthread_kill.c:78
        #2  0x00007ffff78584e2 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/posix/raise.c:26
        #3  0x00007ffff78414ed in __GI_abort () at ./stdlib/abort.c:79
        #4  0x00007fffe34f95c9 in qAbort() () at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:49
        #5  0x00007fffe350d459 in qt_message_fatal<QString&>(QtMsgType, 
QMessageLogContext const&, QString&) (context=..., message=...) at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:2112
        #6  0x00007fffe35063e6 in qt_message(QtMsgType, const 
QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *)
            (msgType=QtFatalMsg, context=..., msg=0x7fffe3b8afa8 "ASSERT 
failure in %s: \"%s\", file %s, line %d", ap=0x7fffad9fb108) at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:380
        #7  0x00007fffe35084b1 in QMessageLogger::fatal(char const*, ...) const 
(this=0x7fffad9fb350, msg=0x7fffe3b8afa8 "ASSERT failure in %s: \"%s\", file 
%s, line %d")
            at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:880
        #8  0x00007fffe34f969c in qt_assert_x(char const*, char const*, char 
const*, int)
            (where=0x7fffe3bae469 "QCoreApplication::sendEvent", 
what=0x7fff9cd289a0 "Cannot send events to objects owned by a different thread. 
Current thread 0x0x7fff9c454020. Receiver 'QtMainWindowClassWindow' (of type 
'QWidgetWindow') was created in thread 0x0x55555560dc50", file=0x7fffe3bae098 
"/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp",
 line=547) at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:114
        #9  0x00007fffe35f54e6 in 
QCoreApplicationPrivate::checkReceiverThread(QObject*) 
(receiver=0x55555bb8b4a0) at 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:547
        #10 0x00007fffe15a786e in QApplication::notify(QObject*, QEvent*) 
(this=0x55555560d9d0, receiver=0x55555bb8b4a0, e=0x7fffad9fb7f0) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2580
        #11 0x00007fffe35f68be in QCoreApplication::notifyInternal2(QObject*, 
QEvent*) (receiver=0x55555bb8b4a0, event=0x7fffad9fb7f0) at 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1154
        #12 0x00007fffe35f7677 in QCoreApplication::sendEvent(QObject*, 
QEvent*) (receiver=0x55555bb8b4a0, event=0x7fffad9fb7f0) at 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1598
        #13 0x00007fffe24f6299 in QWindowPrivate::create(bool) 
(this=0x5555569bd9a0, recursive=false) at 
/home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindow.cpp:589
        #14 0x00007fffe24f6759 in QWindow::create() (this=0x55555bb8b4a0) at 
/home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindow.cpp:720
        #15 0x00007fffe1643f45 in QWidgetPrivate::create() 
(this=0x55555b24c140) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:1341
        #16 0x00007fffe16433c3 in QWidget::create(unsigned long long, bool, 
bool) (this=0x5555572554a0, window=0, initializeWindow=true, 
destroyOldWindow=true) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:1206
        #17 0x00007fffe1649dd5 in 
QWidget::setWindowState(QFlags<Qt::WindowState>) (this=0x5555572554a0, 
newstate=...) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:2946
        #18 0x00007fffe4235db6 in 
QtFrame::SetWindowStateImpl(QFlags<Qt::WindowState>) (this=0x55555bba8cf0, 
eState=...) at vcl/qt6/../qt5/QtFrame.cxx:340
        #19 0x00007fffe4237fc0 in QtFrame::SetWindowState(vcl::WindowData 
const*) (this=0x55555bba8cf0, pState=0x7fffad9fbdc0) at 
vcl/qt6/../qt5/QtFrame.cxx:677
        #20 0x00007fffee0a4c63 in SystemWindow::SetWindowState(vcl::WindowData 
const&) (this=0x7fff9d689d50, rData=...) at 
/home/michi/development/git/libreoffice/vcl/source/window/syswin.cxx:708
        #21 0x00007fffee0a5802 in 
SystemWindow::SetWindowState(std::basic_string_view<char16_t, 
std::char_traits<char16_t> >) (this=0x7fff9d689d50, rStr=u",,,;4;") at 
/home/michi/development/git/libreoffice/vcl/source/window/syswin.cxx:840
        #22 0x00007ffff4ddc4c4 in 
framework::LoadEnv::impl_applyPersistentWindowState(com::sun::star::uno::Reference<com::sun::star::awt::XWindow>
 const&) (this=0x7fffad9fcbb8, xWindow=uno::Reference to (VCLXTopWindow *) 
0x7fff9c003810)
            at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:1809
        #23 0x00007ffff4dd6f5b in framework::LoadEnv::impl_loadContent() 
(this=0x7fffad9fcbb8) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:1081
        #24 0x00007ffff4dd48e4 in framework::LoadEnv::start() 
(this=0x7fffad9fcbb8) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:412
        #25 0x00007ffff4dd21b2 in 
framework::LoadEnv::startLoading(rtl::OUString const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, 
com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, 
rtl::OUString const&, int, LoadEnvFeatures)
            (this=0x7fffad9fcbb8, 
sURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods",
 lMediaDescriptor=uno::Sequence of length 1 = {...}, xBaseFrame=uno::Reference 
to (framework::Desktop *) 0x5555569d5c68, sTarget="_blank", nSearchFlags=0, 
eFeature=LoadEnvFeatures::NONE) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:308
        #26 0x00007ffff4dd0998 in 
framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader>
 const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> 
const&, rtl::OUString const&, rtl::OUString const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
            (xLoader=uno::Reference to (framework::Desktop *) 0x5555569d5c78, 
xContext=uno::Reference to (cppu::(anonymous namespace)::ComponentContext *) 
0x555555623d38, 
sURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods",
 sTarget="_blank", nSearchFlags=0, lArgs=uno::Sequence of length 1 = {...}) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:168
        #27 0x00007ffff4e06a3f in 
framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString 
const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
            (this=0x5555569d5c00, 
sURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods",
 sTargetFrameName="_blank", nSearchFlags=0, lArguments=uno::Sequence of length 
1 = {...})
            at 
/home/michi/development/git/libreoffice/framework/source/services/desktop.cxx:592
        #28 0x00007ffff4e06b34 in non-virtual thunk to 
framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString 
const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) ()
            at 
/home/michi/development/git/libreoffice/instdir/program/libfwklo.so
        #29 0x00007ffff7ba9147 in 
desktop::testOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&, rtl::OUString const&)
            (xDesktop=uno::Reference to (framework::Desktop *) 0x5555569d5c58, 
rURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods")
            at 
/home/michi/development/git/libreoffice/desktop/source/app/opencl.cxx:132
        #30 0x00007ffff7ba7f54 in 
desktop::Desktop::CheckOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&) (xDesktop=uno::Reference to (framework::Desktop *) 0x5555569d5c58)
            at 
/home/michi/development/git/libreoffice/desktop/source/app/opencl.cxx:241
        #31 0x00007ffff7b5719d in std::__invoke_impl<void, void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> 
>(std::__invoke_other, void 
(*&&)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>&&)
            (__f=@0x555556fbe460: 0x7ffff7ba7760 
<desktop::Desktop::CheckOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&)>, __args=...)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61
        #32 0x00007ffff7b5712d in std::__invoke<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> >(void 
(*&&)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>&&)
            (__fn=@0x555556fbe460: 0x7ffff7ba7760 
<desktop::Desktop::CheckOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&)>, __args=...)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:96
        #33 0x00007ffff7b57102 in std::thread::_Invoker<std::tuple<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> > 
>::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (this=0x555556fbe458) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:292
        #34 0x00007ffff7b570c5 in std::thread::_Invoker<std::tuple<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> > 
>::operator()()
            (this=0x555556fbe458) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:299
        #35 0x00007ffff7b56e69 in 
std::thread::_State_impl<std::thread::_Invoker<std::tuple<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> > > 
>::_M_run() (this=0x555556fbe450) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:244
        #36 0x00007ffff74dee24 in  () at /lib/x86_64-linux-gnu/libstdc++.so.6
        #37 0x00007ffff78a4dbb in start_thread (arg=<optimized out>) at 
./nptl/pthread_create.c:444
        #38 0x00007ffff79269f8 in clone3 () at 
../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
    
    Change-Id: I35024670cf4e4a6c00762be71fa051cc9417ef75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167779
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 7c1ff38cb8cd..0ff940408769 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -640,6 +640,14 @@ bool QtFrame::GetModal() const { return isWindow() && 
windowHandle()->isModal();
 
 void QtFrame::SetWindowState(const vcl::WindowData* pState)
 {
+    QtInstance* pSalInst(GetQtInstance());
+    assert(pSalInst);
+    if (!pSalInst->IsMainThread())
+    {
+        pSalInst->RunInMainThread([this, pState]() { SetWindowState(pState); 
});
+        return;
+    }
+
     if (!isWindow() || !pState || isChild(true, false))
         return;
 
commit 9a4f7a093bcf252edac458ed6b5411a73264fdc0
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 17 15:04:26 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat May 18 06:55:18 2024 +0200

    qt: Run QtFrame::SetIcon in main thread
    
    Fixes this crash/assertion seen when starting Writer with
    the qt6 VCL plugin with a fresh user profile with qtbase debug
    build (as of commit 70a2e7f32b9f9ce19d1538f14fbde7b0d1e77ffd):
    
        Thread 19 "soffice.bin" received signal SIGABRT, Aborted.
        [Switching to Thread 0x7fffada006c0 (LWP 150142)]
        __pthread_kill_implementation (threadid=<optimized out>, 
signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
        44      ./nptl/pthread_kill.c: No such file or directory.
        (gdb) bt
        #0  __pthread_kill_implementation (threadid=<optimized out>, 
signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
        #1  0x00007ffff78a6b7f in __pthread_kill_internal (signo=6, 
threadid=<optimized out>) at ./nptl/pthread_kill.c:78
        #2  0x00007ffff78584e2 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/posix/raise.c:26
        #3  0x00007ffff78414ed in __GI_abort () at ./stdlib/abort.c:79
        #4  0x00007fffe34f95c9 in qAbort() () at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:49
        #5  0x00007fffe350d459 in qt_message_fatal<QString&>(QtMsgType, 
QMessageLogContext const&, QString&) (context=..., message=...) at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:2112
        #6  0x00007fffe35063e6 in qt_message(QtMsgType, const 
QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *)
            (msgType=QtFatalMsg, context=..., msg=0x7fffe3b8afa8 "ASSERT 
failure in %s: \"%s\", file %s, line %d", ap=0x7fffad9faab8) at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:380
        #7  0x00007fffe35084b1 in QMessageLogger::fatal(char const*, ...) const 
(this=0x7fffad9fad00, msg=0x7fffe3b8afa8 "ASSERT failure in %s: \"%s\", file 
%s, line %d")
            at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qlogging.cpp:880
        #8  0x00007fffe34f969c in qt_assert_x(char const*, char const*, char 
const*, int)
            (where=0x7fffe3bae469 "QCoreApplication::sendEvent", 
what=0x7fff9d691f60 "Cannot send events to objects owned by a different thread. 
Current thread 0x0x7fff9c456670. Receiver 'QtMainWindowClassWindow' (of type 
'QWidgetWindow') was created in thread 0x0x55555560dc60", file=0x7fffe3bae098 
"/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp",
 line=547) at 
/home/michi/development/git/qt5/qtbase/src/corelib/global/qassert.cpp:114
        #9  0x00007fffe35f54e6 in 
QCoreApplicationPrivate::checkReceiverThread(QObject*) 
(receiver=0x55555bb8a180) at 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:547
        #10 0x00007fffe15a786e in QApplication::notify(QObject*, QEvent*) 
(this=0x55555560d9e0, receiver=0x55555bb8a180, e=0x7fffad9fb120) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2580
        #11 0x00007fffe35f68be in QCoreApplication::notifyInternal2(QObject*, 
QEvent*) (receiver=0x55555bb8a180, event=0x7fffad9fb120) at 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1154
        #12 0x00007fffe35f7677 in QCoreApplication::sendEvent(QObject*, 
QEvent*) (receiver=0x55555bb8a180, event=0x7fffad9fb120) at 
/home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1598
        #13 0x00007fffe24f74d0 in QWindow::setIcon(QIcon const&) 
(this=0x55555bb8a180, icon=...) at 
/home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindow.cpp:1094
        #14 0x00007fffe165564d in QWidgetPrivate::setWindowIcon_sys() 
(this=0x55555b24b370) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:6208
        #15 0x00007fffe1655598 in QWidget::setWindowIcon(QIcon const&) 
(this=0x55555735d7a0, icon=...) at 
/home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:6198
        #16 0x00007fffe42362a9 in QtFrame::SetIcon(unsigned short) 
(this=0x55555bba7d30, nIcon=4) at vcl/qt6/../qt5/QtFrame.cxx:378
        #17 0x00007fffee0a2aa6 in SystemWindow::SetIcon(unsigned short) 
(this=0x7fff9d68a7c0, nIcon=4) at 
/home/michi/development/git/libreoffice/vcl/source/window/syswin.cxx:332
        #18 0x00007ffff4c843f1 in 
framework::TitleBarUpdate::impl_updateIcon(com::sun::star::uno::Reference<com::sun::star::frame::XFrame>
 const&)
            (this=0x7fff9c452fe0, xFrame=uno::Reference to ((anonymous 
namespace)::XFrameImpl *) 0x7fff9d68c690) at 
/home/michi/development/git/libreoffice/framework/source/helper/titlebarupdate.cxx:278
        #19 0x00007ffff4c831c2 in framework::TitleBarUpdate::impl_forceUpdate() 
(this=0x7fff9c452fe0) at 
/home/michi/development/git/libreoffice/framework/source/helper/titlebarupdate.cxx:214
        #20 0x00007ffff4c8304b in 
framework::TitleBarUpdate::frameAction(com::sun::star::frame::FrameActionEvent 
const&) (this=0x7fff9c452fe0, aEvent=...) at 
/home/michi/development/git/libreoffice/framework/source/helper/titlebarupdate.cxx:95
        #21 0x00007ffff4e25397 in (anonymous 
namespace)::XFrameImpl::implts_sendFrameActionEvent(com::sun::star::frame::FrameAction
 const&)
            (this=0x7fff9d68c620, aAction=@0x7ffff4a01f68: 
com::sun::star::frame::FrameAction::FrameAction_COMPONENT_ATTACHED) at 
/home/michi/development/git/libreoffice/framework/source/services/frame.cxx:2960
        #22 0x00007ffff4e1df33 in (anonymous 
namespace)::XFrameImpl::setComponent(com::sun::star::uno::Reference<com::sun::star::awt::XWindow>
 const&, com::sun::star::uno::Reference<com::sun::star::frame::XController> 
const&)
            (this=0x7fff9d68c620, xComponentWindow=uno::Reference to 
(VCLXContainer *) 0x7fff9dd02cd0, xController=uno::Reference to (ScTabViewObj 
*) 0x7fff9d8d82d8)
            at 
/home/michi/development/git/libreoffice/framework/source/services/frame.cxx:1552
        #23 0x00007ffff40291b3 in 
utl::ConnectFrameControllerModel(com::sun::star::uno::Reference<com::sun::star::frame::XFrame>
 const&, com::sun::star::uno::Reference<com::sun::star::frame::XController2> 
const&, com::sun::star::uno::Reference<com::sun::star::frame::XModel> const&)
            (xFrame=uno::Reference to ((anonymous namespace)::XFrameImpl *) 
0x7fff9d68c690, xController=uno::Reference to (ScTabViewObj *) 0x7fff9d8d82d8, 
xModel=uno::Reference to (ScModelObj *) 0x7fff9c471680) at 
include/unotools/fcm.hxx:45
        #24 0x00007ffff402551a in (anonymous 
namespace)::SfxFrameLoader_Impl::impl_createDocumentView(com::sun::star::uno::Reference<com::sun::star::frame::XModel2>
 const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, 
comphelper::NamedValueCollection const&, rtl::OUString const&)
            (i_rModel=uno::Reference to (ScModelObj *) 0x7fff9c471680, 
i_rFrame=uno::Reference to ((anonymous namespace)::XFrameImpl *) 
0x7fff9d68c690, i_rViewFactoryArgs=..., i_rViewName="Default")
            at 
/home/michi/development/git/libreoffice/sfx2/source/view/frmload.cxx:584
        #25 0x00007ffff402272f in (anonymous 
namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
 const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
            (this=0x7fff9c451600, rArgs=uno::Sequence of length 11 = {...}, 
_rTargetFrame=uno::Reference to ((anonymous namespace)::XFrameImpl *) 
0x7fff9d68c690) at 
/home/michi/development/git/libreoffice/sfx2/source/view/frmload.cxx:759
        #26 0x00007ffff4dd7b61 in framework::LoadEnv::impl_loadContent() 
(this=0x7fffad9fcbb8) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:1176
        #27 0x00007ffff4dd48e4 in framework::LoadEnv::start() 
(this=0x7fffad9fcbb8) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:412
        #28 0x00007ffff4dd21b2 in 
framework::LoadEnv::startLoading(rtl::OUString const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, 
com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, 
rtl::OUString const&, int, LoadEnvFeatures)
            (this=0x7fffad9fcbb8, 
sURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods",
 lMediaDescriptor=uno::Sequence of length 1 = {...}, xBaseFrame=uno::Reference 
to (framework::Desktop *) 0x5555569ad308, sTarget="_blank", nSearchFlags=0, 
eFeature=LoadEnvFeatures::NONE) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:308
        #29 0x00007ffff4dd0998 in 
framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader>
 const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> 
const&, rtl::OUString const&, rtl::OUString const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
            (xLoader=uno::Reference to (framework::Desktop *) 0x5555569ad318, 
xContext=uno::Reference to (cppu::(anonymous namespace)::ComponentContext *) 
0x555555623d48, 
sURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods",
 sTarget="_blank", nSearchFlags=0, lArgs=uno::Sequence of length 1 = {...}) at 
/home/michi/development/git/libreoffice/framework/source/loadenv/loadenv.cxx:168
        #30 0x00007ffff4e06a3f in 
framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString 
const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
            (this=0x5555569ad2a0, 
sURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods",
 sTargetFrameName="_blank", nSearchFlags=0, lArguments=uno::Sequence of length 
1 = {...})
            at 
/home/michi/development/git/libreoffice/framework/source/services/desktop.cxx:592
        #31 0x00007ffff4e06b34 in non-virtual thunk to 
framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString 
const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) ()
            at 
/home/michi/development/git/libreoffice/instdir/program/libfwklo.so
        #32 0x00007ffff7ba9147 in 
desktop::testOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&, rtl::OUString const&)
            (xDesktop=uno::Reference to (framework::Desktop *) 0x5555569ad2f8, 
rURL="file:///home/michi/development/git/libreoffice/instdir/program/../program/opencl/cl-test.ods")
            at 
/home/michi/development/git/libreoffice/desktop/source/app/opencl.cxx:132
        #33 0x00007ffff7ba7f54 in 
desktop::Desktop::CheckOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&) (xDesktop=uno::Reference to (framework::Desktop *) 0x5555569ad2f8)
        --Type <RET> for more, q to quit, c to continue without paging--
            at 
/home/michi/development/git/libreoffice/desktop/source/app/opencl.cxx:241
        #34 0x00007ffff7b5719d in std::__invoke_impl<void, void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> 
>(std::__invoke_other, void 
(*&&)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>&&)
            (__f=@0x5555573c20b0: 0x7ffff7ba7760 
<desktop::Desktop::CheckOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&)>, __args=...)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61
        #35 0x00007ffff7b5712d in std::__invoke<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> >(void 
(*&&)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>&&)
            (__fn=@0x5555573c20b0: 0x7ffff7ba7760 
<desktop::Desktop::CheckOpenCLCompute(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2>
 const&)>, __args=...)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:96
        #36 0x00007ffff7b57102 in std::thread::_Invoker<std::tuple<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> > 
>::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (this=0x5555573c20a8) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:292
        #37 0x00007ffff7b570c5 in std::thread::_Invoker<std::tuple<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> > 
>::operator()()
            (this=0x5555573c20a8) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:299
        #38 0x00007ffff7b56e69 in 
std::thread::_State_impl<std::thread::_Invoker<std::tuple<void 
(*)(com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> const&), 
com::sun::star::uno::Reference<com::sun::star::frame::XDesktop2> > > 
>::_M_run() (this=0x5555573c20a0) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:244
        #39 0x00007ffff74dee24 in  () at /lib/x86_64-linux-gnu/libstdc++.so.6
        #40 0x00007ffff78a4dbb in start_thread (arg=<optimized out>) at 
./nptl/pthread_create.c:444
        #41 0x00007ffff79269f8 in clone3 () at 
../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
    
    Change-Id: Ic611eb26b140c060cba4d81603e506806cf43bab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167778
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index d4a43fc7a544..7c1ff38cb8cd 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -350,6 +350,14 @@ void QtFrame::SetTitle(const OUString& rTitle)
 
 void QtFrame::SetIcon(sal_uInt16 nIcon)
 {
+    QtInstance* pSalInst(GetQtInstance());
+    assert(pSalInst);
+    if (!pSalInst->IsMainThread())
+    {
+        pSalInst->RunInMainThread([this, nIcon]() { SetIcon(nIcon); });
+        return;
+    }
+
     if (m_nStyle
             & (SalFrameStyleFlags::PLUG | SalFrameStyleFlags::SYSTEMCHILD
                | SalFrameStyleFlags::FLOAT | SalFrameStyleFlags::INTRO

Reply via email to