diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-02-05 14:35:17 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-02-05 17:19:48 +0100 |
commit | b030e83fccbff8d82a4c84462075baa8442cde54 (patch) | |
tree | ea43fbba2864d484ed90348d639f70484e498e87 /sfx2 | |
parent | e7ce52acd75cf90ff90ed5fb6a809b5813337411 (diff) |
sfx2: allow storeToURL() on the main thread
This is similar to commit f1e775470e68fb1ca1fee390c10064c55932180d
(framework: allow storeSelf() on the main thread, 2019-01-30), just this
handles "save as" instead of "save".
The result is that combining this commit with the previous OnMainThread
ones allows all of document load/save/save-as/command-dispatch on the
main thread even when the action is invoked via remote UNO, which would
run on a non-main thread by default.
Change-Id: I7d50cceb66ecc6619fe25734107a2524ca872c2a
Reviewed-on: https://gerrit.libreoffice.org/67412
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 9d8b48f35cf4..e163345dac7a 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -126,7 +126,7 @@ #include <sfx2/sfxresid.hxx> #include <comphelper/profilezone.hxx> #include <vcl/threadex.hxx> - +#include <unotools/mediadescriptor.hxx> // namespaces @@ -1504,6 +1504,17 @@ static bool SaveImplStatic(SfxObjectShell* pThis, const SfxItemSet* pParams) return pThis->Save_Impl(pParams); } +/** + * Proxy around SfxBaseModel::impl_store(), as vcl::solarthread::syncExecute() + * does not seem to accept lambdas or void functions. + */ +static bool ImplStoreStatic(SfxBaseModel* pThis, const OUString& rURL, + const uno::Sequence<beans::PropertyValue>& rArgs, bool bSaveTo) +{ + pThis->impl_store(rURL, rArgs, bSaveTo); + return true; +} + // XStorable2 @@ -1688,7 +1699,12 @@ void SAL_CALL SfxBaseModel::storeToURL( const OUString& rURL { SfxSaveGuard aSaveGuard(this, m_pData.get()); try { - impl_store(rURL, rArgs, true); + utl::MediaDescriptor aDescriptor(rArgs); + bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false); + if (bOnMainThread) + vcl::solarthread::syncExecute(std::bind(&ImplStoreStatic, this, rURL, rArgs, true)); + else + impl_store(rURL, rArgs, true); } catch (const uno::Exception &e) { |