Kaydet (Commit) 58e2a9ef authored tarafından László Németh's avatar László Németh

tdf#95614 fix freezing with linked images

Change-Id: Id9c718fda8f15d804e07ad87ff4ca930c2ea70cf
üst 8f7025b5
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#define FILETYPE_GRF 2 #define FILETYPE_GRF 2
#define FILETYPE_OBJECT 3 #define FILETYPE_OBJECT 3
FnHashSet SvFileObject::m_aAsyncLoadsInProgress;
SvFileObject::SvFileObject() SvFileObject::SvFileObject()
: nPostUserEventId(nullptr) : nPostUserEventId(nullptr)
, mxDelMed() , mxDelMed()
...@@ -79,6 +81,26 @@ bool SvFileObject::GetData( css::uno::Any & rData, ...@@ -79,6 +81,26 @@ bool SvFileObject::GetData( css::uno::Any & rData,
const OUString & rMimeType, const OUString & rMimeType,
bool bGetSynchron ) 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 ); SotClipboardFormatId nFmt = SotExchange::RegisterFormatMimeType( rMimeType );
switch( nType ) switch( nType )
{ {
...@@ -262,6 +284,8 @@ bool SvFileObject::LoadFile_Impl() ...@@ -262,6 +284,8 @@ bool SvFileObject::LoadFile_Impl()
if( !bSynchron ) if( !bSynchron )
{ {
m_aAsyncLoadsInProgress.insert(sFileNm + sReferer);
bAsyncLoadsInProgress = true;
bLoadAgain = bDataReady = bInNewData = false; bLoadAgain = bDataReady = bInNewData = false;
bWaitForData = true; bWaitForData = true;
...@@ -495,6 +519,7 @@ IMPL_LINK_NOARG_TYPED( SvFileObject, DelMedium_Impl, void*, void ) ...@@ -495,6 +519,7 @@ IMPL_LINK_NOARG_TYPED( SvFileObject, DelMedium_Impl, void*, void )
{ {
nPostUserEventId = nullptr; nPostUserEventId = nullptr;
mxDelMed.Clear(); mxDelMed.Clear();
m_aAsyncLoadsInProgress.erase(sFileNm + sReferer);
} }
IMPL_LINK_TYPED( SvFileObject, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void ) IMPL_LINK_TYPED( SvFileObject, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
......
...@@ -22,10 +22,13 @@ ...@@ -22,10 +22,13 @@
#include <sfx2/linksrc.hxx> #include <sfx2/linksrc.hxx>
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <sfx2/linkmgr.hxx> #include <sfx2/linkmgr.hxx>
#include <unordered_set>
class Graphic; class Graphic;
namespace sfx2 { class FileDialogHelper; } namespace sfx2 { class FileDialogHelper; }
typedef std::unordered_set< OUString, OUStringHash, ::std::equal_to< OUString > > FnHashSet;
class SvFileObject : public sfx2::SvLinkSource class SvFileObject : public sfx2::SvLinkSource
{ {
OUString sFileNm; OUString sFileNm;
...@@ -36,6 +39,7 @@ class SvFileObject : public sfx2::SvLinkSource ...@@ -36,6 +39,7 @@ class SvFileObject : public sfx2::SvLinkSource
ImplSVEvent* nPostUserEventId; ImplSVEvent* nPostUserEventId;
tools::SvRef<SfxMedium> mxDelMed; tools::SvRef<SfxMedium> mxDelMed;
VclPtr<vcl::Window> pOldParent; VclPtr<vcl::Window> pOldParent;
static FnHashSet m_aAsyncLoadsInProgress;
sal_uInt8 nType; sal_uInt8 nType;
...@@ -49,6 +53,7 @@ class SvFileObject : public sfx2::SvLinkSource ...@@ -49,6 +53,7 @@ class SvFileObject : public sfx2::SvLinkSource
bool bClearMedium : 1; bool bClearMedium : 1;
bool bStateChangeCalled : 1; bool bStateChangeCalled : 1;
bool bInCallDownload : 1; bool bInCallDownload : 1;
bool bAsyncLoadsInProgress : 1;
bool GetGraphic_Impl( Graphic&, SvStream* pStream = nullptr ); bool GetGraphic_Impl( Graphic&, SvStream* pStream = nullptr );
bool LoadFile_Impl(); bool LoadFile_Impl();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment