From 923b30aa27ceb377d6a540c012000e89ce5db31e Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Thu, 26 Aug 2021 13:49:13 +0200 Subject: 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 --- vcl/qt5/Qt5Instance.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'vcl/qt5') 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(pParent)); - return new Qt5Frame(static_cast(pParent), nStyle, m_bUseCairo); + + SalFrame* pRet(nullptr); + RunInMainThread( + [&, this]() { pRet = new Qt5Frame(static_cast(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(pParent)); - return new Qt5Object(static_cast(pParent), bShow); + + SalObject* pRet(nullptr); + RunInMainThread([&]() { pRet = new Qt5Object(static_cast(pParent), bShow); }); + assert(pRet); + return pRet; } void Qt5Instance::DestroyObject(SalObject* pObject) -- cgit