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>
(cherry picked from commit 76cb48b6a00cde41987a1b67b78fee68a133ad53)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121568
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 184f822..c1e82aa 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -285,13 +285,21 @@
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 @@
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 608b5dc..9279ec5 100644
--- a/vcl/unx/kf5/KF5SalInstance.cxx
+++ b/vcl/unx/kf5/KF5SalInstance.cxx
@@ -42,13 +42,22 @@
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