diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2023-07-23 10:07:04 -0400 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-07-23 21:18:39 +0200 |
commit | 5fba074e7f22ff0e5d5b9591a912193f7be8c08c (patch) | |
tree | b206162dc41882faaf0104727598dbb93da5eaea /desktop | |
parent | 6c6bb1d434d5c0be2f71470483f3ce56f5210e01 (diff) |
lok: flush the VOC primitives when trimming memory
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: I0a7748a1fb1b58b3bcfc6b8fdfa1410a345849a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154812
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
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 |