vcl/qt5/Qt5Instance.cxx | 18 +++++++++++++++--- vcl/unx/kf5/KF5SalInstance.cxx | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-)
New commits: commit 923b30aa27ceb377d6a540c012000e89ce5db31e Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Thu Aug 26 13:49:13 2021 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Thu Aug 26 17:58:03 2021 +0200 tdf#144008 Qt5/Kf5 create frames in the GUI thread There was a 50% chance my pick would have been correct... ok, just half-true, as in hindsight, I should have preferred the secure variant using RunInMain to start with. I thought I could use some templated class functions to get rid of all the copy and paste, but that looked even more ugly. P.S. if you wonder - like myself - about the code formatting in Qt5Instance::CreateFrame: that if from clang-format. Change-Id: I3a6b0c12c9d71ad8e777ed82526d1515a249832c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121091 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx index 432af5e6f718..f1e34d2761b1 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -285,13 +285,21 @@ void Qt5Instance::deleteObjectLater(QObject* pObject) { pObject->deleteLater(); SalFrame* Qt5Instance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle) { - return new Qt5Frame(nullptr, nStyle, m_bUseCairo); + SalFrame* pRet(nullptr); + RunInMainThread([&, this]() { pRet = new Qt5Frame(nullptr, nStyle, useCairo()); }); + assert(pRet); + return pRet; } SalFrame* Qt5Instance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) { assert(!pParent || dynamic_cast<Qt5Frame*>(pParent)); - return new Qt5Frame(static_cast<Qt5Frame*>(pParent), nStyle, m_bUseCairo); + + SalFrame* pRet(nullptr); + RunInMainThread( + [&, this]() { pRet = new Qt5Frame(static_cast<Qt5Frame*>(pParent), nStyle, useCairo()); }); + assert(pRet); + return pRet; } void Qt5Instance::DestroyFrame(SalFrame* pFrame) @@ -306,7 +314,11 @@ void Qt5Instance::DestroyFrame(SalFrame* pFrame) SalObject* Qt5Instance::CreateObject(SalFrame* pParent, SystemWindowData*, bool bShow) { assert(!pParent || dynamic_cast<Qt5Frame*>(pParent)); - return new Qt5Object(static_cast<Qt5Frame*>(pParent), bShow); + + SalObject* pRet(nullptr); + RunInMainThread([&]() { pRet = new Qt5Object(static_cast<Qt5Frame*>(pParent), bShow); }); + assert(pRet); + return pRet; } void Qt5Instance::DestroyObject(SalObject* pObject) diff --git a/vcl/unx/kf5/KF5SalInstance.cxx b/vcl/unx/kf5/KF5SalInstance.cxx index 608b5dccc4dc..9279ec50b98b 100644 --- a/vcl/unx/kf5/KF5SalInstance.cxx +++ b/vcl/unx/kf5/KF5SalInstance.cxx @@ -42,13 +42,22 @@ KF5SalInstance::KF5SalInstance(std::unique_ptr<QApplication>& pQApp, bool bUseCa SalFrame* KF5SalInstance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle) { - return new KF5SalFrame(nullptr, nStyle, useCairo()); + SalFrame* pRet(nullptr); + RunInMainThread([&, this]() { pRet = new KF5SalFrame(nullptr, nStyle, useCairo()); }); + assert(pRet); + return pRet; } -SalFrame* KF5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nState) +SalFrame* KF5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) { assert(!pParent || dynamic_cast<KF5SalFrame*>(pParent)); - return new KF5SalFrame(static_cast<KF5SalFrame*>(pParent), nState, useCairo()); + + SalFrame* pRet(nullptr); + RunInMainThread([&, this]() { + pRet = new KF5SalFrame(static_cast<KF5SalFrame*>(pParent), nStyle, useCairo()); + }); + assert(pRet); + return pRet; } bool KF5SalInstance::hasNativeFileSelection() const