desktop/source/lib/init.cxx | 35 +++++++++++++++++++++++++++++++++ svx/source/sdr/contact/viewcontact.cxx | 2 + vcl/source/filter/graphicfilter.cxx | 2 + 3 files changed, 39 insertions(+)
New commits: commit 5fba074e7f22ff0e5d5b9591a912193f7be8c08c Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Sun Jul 23 10:07:04 2023 -0400 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Jul 23 21:18:39 2023 +0200 lok: flush the VOC primitives when trimming memory Signed-off-by: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Change-Id: I0a7748a1fb1b58b3bcfc6b8fdfa1410a345849a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154812 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 81f797e5f197..c1ebf5d934ea 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -7,7 +7,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "sal/types.h" #include "sfx2/lokhelper.hxx" +#include "svx/sdr/contact/viewcontact.hxx" +#include "svx/svdpage.hxx" +#include "svx/svdpagv.hxx" #include <config_buildconfig.h> #include <config_cairo_rgba.h> #include <config_features.h> @@ -3151,6 +3155,37 @@ static char* lo_extractRequest(LibreOfficeKit* /*pThis*/, const char* pFilePath) static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget) { vcl::lok::trimMemory(nTarget); + + if (nTarget > 2000) + { + SolarMutexGuard aGuard; + + // Flush all buffered VOC primitives from the pages. + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (pViewShell) + { + const SdrView* pView = pViewShell->GetDrawView(); + if (pView) + { + SdrPageView* pPageView = pView->GetSdrPageView(); + if (pPageView) + { + SdrPage* pCurPage = pPageView->GetPage(); + if (pCurPage) + { + SdrModel& sdrModel = pCurPage->getSdrModelFromSdrPage(); + for (sal_uInt16 i = 0; i < sdrModel.GetPageCount(); ++i) + { + SdrPage* pPage = sdrModel.GetPage(i); + if (pPage) + pPage->GetViewContact().flushViewObjectContacts(); + } + } + } + } + } + } + if (nTarget > 1000) { #ifdef HAVE_MALLOC_TRIM diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 2a5d73e509c3..9ecb324e200f 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -58,6 +58,8 @@ void ViewContact::deleteAllVOCs() // assert when there were new entries added during deletion DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList in VC (!)"); + + mxViewIndependentPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer(); } // get an Object-specific ViewObjectContact for a specific diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 6160493c3ec0..b113946c6ce8 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -716,12 +716,14 @@ void GraphicFilter::MakeGraphicsAvailableThreaded(std::vector<Graphic*>& graphic if( toLoad.empty()) return; std::vector< std::unique_ptr<SvStream>> streams; + streams.reserve(toLoad.size()); for( auto graphic : toLoad ) { streams.push_back( std::make_unique<SvMemoryStream>( const_cast<sal_uInt8*>(graphic->GetSharedGfxLink()->GetData()), graphic->GetSharedGfxLink()->GetDataSize(), StreamMode::READ | StreamMode::WRITE)); } std::vector< std::shared_ptr<Graphic>> loadedGraphics; + loadedGraphics.reserve(streams.size()); ImportGraphics(loadedGraphics, std::move(streams)); assert(loadedGraphics.size() == toLoad.size()); for( size_t i = 0; i < toLoad.size(); ++i )