sfx2/source/appl/fileobj.cxx |   25 +++++++++++++++++++++++++
 sfx2/source/appl/fileobj.hxx |    5 +++++
 2 files changed, 30 insertions(+)

New commits:
commit 58e2a9efe554ff2ac09a902d13a18e954487b672
Author: László Németh <laszlo.nem...@collabora.com>
Date:   Fri Nov 20 19:30:42 2015 +0100

    tdf#95614 fix freezing with linked images
    
    Change-Id: Id9c718fda8f15d804e07ad87ff4ca930c2ea70cf

diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx
index e652768..3b68b34 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 a84126f..b6f878c3 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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to