summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-08-26 13:49:13 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2021-08-27 05:51:07 +0200
commit76cb48b6a00cde41987a1b67b78fee68a133ad53 (patch)
tree1d225c521312f706113f484f47c2396c7f22e58b /vcl
parent7c1f4284562e905372b5c14b6017f1eb438f54b5 (diff)
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 <glogow@fbihome.de> (cherry picked from commit 923b30aa27ceb377d6a540c012000e89ce5db31e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121063 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/Qt5Instance.cxx18
-rw-r--r--vcl/unx/kf5/KF5SalInstance.cxx15
2 files changed, 27 insertions, 6 deletions
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