summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2023-07-23 10:07:04 -0400
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-11 12:45:49 +0200
commit01e89930f8a0d50758ed23b0cf2bfd7b9ee47b9b (patch)
tree8144a0b0371badba5ef146097fd09cd803a3dea7 /desktop
parent40641b868b20c73e694770c2c7ea71e232514fa1 (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> (cherry picked from commit 5fba074e7f22ff0e5d5b9591a912193f7be8c08c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154868 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 67957a370751..40c11e54d080 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -8,6 +8,11 @@
*/
#include <sfx2/lokhelper.hxx>
+#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>
@@ -3170,6 +3175,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