vcl/source/app/svdata.cxx |    8 ++++++--
 vcl/source/app/svmain.cxx |    8 +-------
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 6fb7330f35424f3b9f04a6dfb99b1754e2dcfa0f
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Fri Jun 9 12:17:36 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Jun 9 16:54:04 2023 +0200

    trimMemory - fix crash modifying structure during clear.
    
    Re-use existing code from shutdown, to avoid ~Bitmap mutating
    maScaleCache while we're iterating it inside clear.
    
    Change-Id: I021d9075cf5c449702af091c2c8a4de64887f2ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152785
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Michael Meeks <michael.me...@collabora.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index febed41cb98c..cb7778fcfd40 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -419,9 +419,13 @@ ImplSVData::ImplSVData()
 
 void ImplSVData::dropCaches()
 {
-    maGDIData.maScaleCache.clear();
-    maGDIData.maThemeImageCache.clear();
+    // we are iterating over a map and doing erase while inside a loop which 
is doing erase
+    // hence we can't use clear() here
+    maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
+                                                { return true; });
+
     maGDIData.maThemeDrawCommandsCache.clear();
+    maGDIData.maThemeImageCache.clear();
 }
 
 void ImplSVData::dumpState(rtl::OStringBuffer &rState)
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 7c5505f364cb..2838cfc3a63c 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -588,13 +588,7 @@ void DeInitVCL()
 
     pSVData->maGDIData.mxScreenFontList.reset();
     pSVData->maGDIData.mxScreenFontCache.reset();
-    // we are iterating over a map and doing erase while inside a loop which 
is doing erase
-    // hence we can't use clear() here
-    pSVData->maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
-                                                { return true; });
-
-    pSVData->maGDIData.maThemeDrawCommandsCache.clear();
-    pSVData->maGDIData.maThemeImageCache.clear();
+    pSVData->dropCaches();
 
     // Deinit Sal
     if (pSVData->mpDefInst)

Reply via email to