diff options
author | László Németh <laszlo.nemeth@collabora.com> | 2015-11-20 19:30:42 +0100 |
---|---|---|
committer | László Németh <laszlo.nemeth@collabora.com> | 2015-11-20 19:33:40 +0100 |
commit | 58e2a9efe554ff2ac09a902d13a18e954487b672 (patch) | |
tree | 122103ee10483e6aa3f7eb3a9596e85e5b691e19 /sfx2 | |
parent | 8f7025b50f50839a30565d2308dcf340bbf46a97 (diff) |
tdf#95614 fix freezing with linked images
Change-Id: Id9c718fda8f15d804e07ad87ff4ca930c2ea70cf
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/fileobj.cxx | 25 | ||||
-rw-r--r-- | sfx2/source/appl/fileobj.hxx | 5 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx index e65276830c0a..3b68b34e9ef4 100644 --- a/sfx2/source/appl/fileobj.cxx +++ b/sfx2/source/appl/fileobj.cxx @@ -46,6 +46,8 @@ #define FILETYPE_GRF 2 #define FILETYPE_OBJECT 3 +FnHashSet SvFileObject::m_aAsyncLoadsInProgress; + SvFileObject::SvFileObject() : nPostUserEventId(nullptr) , mxDelMed() @@ -79,6 +81,26 @@ bool SvFileObject::GetData( css::uno::Any & rData, const OUString & rMimeType, bool bGetSynchron ) { + + // avoid loading of the same graphics asynchronously in the same document + if ( !bAsyncLoadsInProgress ) + { + // asynchronous loading of the same graphic in progress? + if ( m_aAsyncLoadsInProgress.find(sFileNm + sReferer) != m_aAsyncLoadsInProgress.end() ) + { + // remove graphic id to sign overloading + m_aAsyncLoadsInProgress.erase(sFileNm + sReferer); + return true; + } + } + else + { + bAsyncLoadsInProgress = false; + // sign of overloading? + if ( m_aAsyncLoadsInProgress.find(sFileNm + sReferer) == m_aAsyncLoadsInProgress.end() ) + return true; + } + SotClipboardFormatId nFmt = SotExchange::RegisterFormatMimeType( rMimeType ); switch( nType ) { @@ -262,6 +284,8 @@ bool SvFileObject::LoadFile_Impl() if( !bSynchron ) { + m_aAsyncLoadsInProgress.insert(sFileNm + sReferer); + bAsyncLoadsInProgress = true; bLoadAgain = bDataReady = bInNewData = false; bWaitForData = true; @@ -495,6 +519,7 @@ IMPL_LINK_NOARG_TYPED( SvFileObject, DelMedium_Impl, void*, void ) { nPostUserEventId = nullptr; mxDelMed.Clear(); + m_aAsyncLoadsInProgress.erase(sFileNm + sReferer); } IMPL_LINK_TYPED( SvFileObject, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void ) diff --git a/sfx2/source/appl/fileobj.hxx b/sfx2/source/appl/fileobj.hxx index a84126f06017..b6f878c33178 100644 --- a/sfx2/source/appl/fileobj.hxx +++ b/sfx2/source/appl/fileobj.hxx @@ -22,10 +22,13 @@ #include <sfx2/linksrc.hxx> #include <sfx2/docfile.hxx> #include <sfx2/linkmgr.hxx> +#include <unordered_set> class Graphic; namespace sfx2 { class FileDialogHelper; } +typedef std::unordered_set< OUString, OUStringHash, ::std::equal_to< OUString > > FnHashSet; + class SvFileObject : public sfx2::SvLinkSource { OUString sFileNm; @@ -36,6 +39,7 @@ class SvFileObject : public sfx2::SvLinkSource ImplSVEvent* nPostUserEventId; tools::SvRef<SfxMedium> mxDelMed; VclPtr<vcl::Window> pOldParent; + static FnHashSet m_aAsyncLoadsInProgress; sal_uInt8 nType; @@ -49,6 +53,7 @@ class SvFileObject : public sfx2::SvLinkSource bool bClearMedium : 1; bool bStateChangeCalled : 1; bool bInCallDownload : 1; + bool bAsyncLoadsInProgress : 1; bool GetGraphic_Impl( Graphic&, SvStream* pStream = nullptr ); bool LoadFile_Impl(); |