starmath/source/mathml/import.cxx   |    4 +--
 sw/source/uibase/utlui/tmplctrl.cxx |    4 +--
 vcl/inc/win/saldata.hxx             |    5 +---
 vcl/win/app/salinst.cxx             |    3 --
 vcl/win/gdi/salfont.cxx             |   37 +++++++++---------------------------
 vcl/win/gdi/salgdi.cxx              |    6 -----
 6 files changed, 18 insertions(+), 41 deletions(-)

New commits:
commit 00f074d7187fd8eb1486fadaa14eb5e8132a96d2
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Jul 31 19:54:54 2025 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Aug 13 20:11:34 2025 +0200

    cid#1660007 Overflowed constant
    
    Change-Id: I25ce37f3b792f21284a3b12c34eaeff9a378b37b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188718
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit cb78333ec14a7664f2fae9bd6a9ef6b32e45cfe0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189489
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/uibase/utlui/tmplctrl.cxx 
b/sw/source/uibase/utlui/tmplctrl.cxx
index 79a40011f9d1..e38b89d7dbbc 100644
--- a/sw/source/uibase/utlui/tmplctrl.cxx
+++ b/sw/source/uibase/utlui/tmplctrl.cxx
@@ -102,9 +102,9 @@ void SwTemplateControl::Command( const CommandEvent& rCEvt )
                 ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1, 1));
                 weld::Window* pParent = weld::GetPopupParent(GetStatusBar(), 
aRect);
                 OUString sResult = xPopup->popup_at_rect(pParent, aRect);
-                if (!sResult.isEmpty())
+                sal_uInt32 nCurrId = sResult.toUInt32();
+                if (nCurrId > 0)
                 {
-                    sal_uInt32 nCurrId = sResult.toUInt32();
                     // looks a bit awkward, but another way is not possible
                     pStyle = xIter->operator[]( nCurrId - 1 );
                     SfxStringItem aStyle( FN_SET_PAGE_STYLE, pStyle->GetName() 
);
commit 926d43c7cfef2e8c27aa5a83b74935665eaf3eb4
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Jul 30 11:04:35 2025 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Aug 13 20:11:27 2025 +0200

    cid#1660282 Resource leak
    
    this all looks a bit error prone, but minimally fix this.
    
    Change-Id: Icfaf38c3c2028cc591f5c4bae0317587eccf5d48
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188591
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit c6d852d6ee54e3261103f253267bd676195b327a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189490
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/starmath/source/mathml/import.cxx 
b/starmath/source/mathml/import.cxx
index 9c3392fa2b38..f3c2996d6a04 100644
--- a/starmath/source/mathml/import.cxx
+++ b/starmath/source/mathml/import.cxx
@@ -917,8 +917,8 @@ void SmMLImportContext::handleAttributes(const 
Reference<XFastAttributeList>& aA
             case XML_HREF:
             {
                 
aAttribute.setMlAttributeValueType(SmMlAttributeValueType::MlHref);
-                OUString* aRef = new OUString(aIter.toString());
-                SmMlHref aHref = { SmMlAttributeValueHref::NMlValid, aRef };
+                OUString aRef(aIter.toString());
+                SmMlHref aHref = { SmMlAttributeValueHref::NMlValid, &aRef };
                 aAttribute.setMlHref(&aHref);
                 break;
             }
commit 6f6c4408bb9dd6e9bad72e76f9bb80110a534dfc
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Aug 7 18:29:41 2025 +0500
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Aug 13 20:11:21 2025 +0200

    tdf#167849: don't release embedded fonts in 
WinSalGraphics::ClearDevFontCache
    
    Commit 8e63934c398dd5065f3589c8a7d1b3008f5514d1 (WIN separate LO shared and
    embedded fonts, 2019-07-05) made the call only release embedded fonts, not
    all temporary fonts. But embedded fonts must not be released there, too:
    they are not re-added back by anything. Therefore, any reload of font data
    drops all open documents' embedded fonts: this could be opening another
    document with embedded font, or a user installing a font in their system.
    
    Clearing embedded fonts itself could be a useful operation, performed when
    a document ownong the font is closed. But that must be implemented properly
    for all platforms, counting references for each such font; additionally, it
    could handle restricted fonts correctly, not showing them in font list.
    
    Change-Id: I239f15cef64c94522e70e17e295b572664317bfc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189100
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189479

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 6a00566cca31..5b037f35288d 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -118,8 +118,7 @@ public:
     bool                    mbObjClassInit;         // is SALOBJECTCLASS 
initialised
     DWORD                   mnAppThreadId;          // Id from 
Application-Thread
     SalIcon*                mpFirstIcon;            // icon cache, points to 
first icon, NULL if none
-    TempFontItem*           mpSharedTempFontItem;   // LibreOffice shared fonts
-    TempFontItem*           mpOtherTempFontItem;    // other temporary fonts 
(embedded?)
+    TempFontItem*           mpTempFontItem;         // LibreOffice own fonts 
(shared and embedded)
     bool                    mbThemeChanged;         // true if visual theme 
was changed: throw away theme handles
     bool                    mbThemeMenuSupport;
 
@@ -150,7 +149,7 @@ void ImplClearHDCCache( SalData* pData );
 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
 void ImplReleaseCachedDC( sal_uLong nID );
 
-void ImplReleaseTempFonts(SalData&, bool bAll);
+void ImplReleaseTempFonts(SalData&);
 
 HCURSOR ImplLoadSalCursor( int nId );
 HBITMAP ImplLoadSalBitmap( int nId );
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 10607e82daa7..f2667638b5cc 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -274,8 +274,7 @@ SalData::SalData()
     mbObjClassInit = false;     // is SALOBJECTCLASS initialised
     mnAppThreadId = 0;          // Id from Application-Thread
     mpFirstIcon = nullptr;      // icon cache, points to first icon, NULL if 
none
-    mpSharedTempFontItem = nullptr;
-    mpOtherTempFontItem = nullptr;
+    mpTempFontItem = nullptr;
     mbThemeChanged = false;     // true if visual theme was changed: throw 
away theme handles
     mbThemeMenuSupport = false;
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index d3c181af17fa..c0a7c2f29dcd 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -909,7 +909,7 @@ struct TempFontItem
     TempFontItem* mpNextItem;
 };
 
-static int lcl_AddFontResource(SalData& rSalData, const OUString& 
rFontFileURL, bool bShared)
+static int lcl_AddFontResource(SalData& rSalData, const OUString& rFontFileURL)
 {
     OUString aFontSystemPath;
     OSL_VERIFY(!osl::FileBase::getSystemPathFromFileURL(rFontFileURL, 
aFontSystemPath));
@@ -921,35 +921,19 @@ static int lcl_AddFontResource(SalData& rSalData, const 
OUString& rFontFileURL,
 
     TempFontItem* pNewItem = new TempFontItem;
     pNewItem->maFontResourcePath = aFontSystemPath;
-    if (bShared)
-    {
-        pNewItem->mpNextItem = rSalData.mpSharedTempFontItem;
-        rSalData.mpSharedTempFontItem = pNewItem;
-    }
-    else
-    {
-        pNewItem->mpNextItem = rSalData.mpOtherTempFontItem;
-        rSalData.mpOtherTempFontItem = pNewItem;
-    }
+
+    pNewItem->mpNextItem = rSalData.mpTempFontItem;
+    rSalData.mpTempFontItem = pNewItem;
+
     return nRet;
 }
 
-void ImplReleaseTempFonts(SalData& rSalData, bool bAll)
+void ImplReleaseTempFonts(SalData& rSalData)
 {
-    while (TempFontItem* p = rSalData.mpOtherTempFontItem)
-    {
-        RemoveFontResourceExW(o3tl::toW(p->maFontResourcePath.getStr()), 
FR_PRIVATE, nullptr);
-        rSalData.mpOtherTempFontItem = p->mpNextItem;
-        delete p;
-    }
-
-    if (!bAll)
-        return;
-
-    while (TempFontItem* p = rSalData.mpSharedTempFontItem)
+    while (TempFontItem* p = rSalData.mpTempFontItem)
     {
         RemoveFontResourceExW(o3tl::toW(p->maFontResourcePath.getStr()), 
FR_PRIVATE, nullptr);
-        rSalData.mpSharedTempFontItem = p->mpNextItem;
+        rSalData.mpTempFontItem = p->mpNextItem;
         delete p;
     }
 }
@@ -1022,7 +1006,7 @@ bool 
WinSalGraphics::AddTempDevFont(vcl::font::PhysicalFontCollection* pFontColl
         return false;
     }
 
-    int nFonts = lcl_AddFontResource(*GetSalData(), rFontFileURL, false);
+    int nFonts = lcl_AddFontResource(*GetSalData(), rFontFileURL);
     if (nFonts <= 0)
         return false;
 
@@ -1069,7 +1053,7 @@ void WinSalGraphics::GetDevFontList( 
vcl::font::PhysicalFontCollection* pFontCol
                     osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL);
                     rcOSL = aDirItem.getFileStatus(aFileStatus);
                     if (rcOSL == osl::FileBase::E_None)
-                        lcl_AddFontResource(*pSalData, 
aFileStatus.getFileURL(), true);
+                        lcl_AddFontResource(*pSalData, 
aFileStatus.getFileURL());
                 }
             }
         };
@@ -1115,7 +1099,6 @@ void WinSalGraphics::GetDevFontList( 
vcl::font::PhysicalFontCollection* pFontCol
 void WinSalGraphics::ClearDevFontCache()
 {
     mWinSalGraphicsImplBase->ClearDevFontCache();
-    ImplReleaseTempFonts(*GetSalData(), false);
 }
 
 bool WinFontInstance::GetGlyphOutline(sal_GlyphId nId, 
basegfx::B2DPolyPolygon& rB2DPolyPoly, bool) const
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 3bd595699f1b..11da396cd402 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -74,10 +74,6 @@ void ImplInitSalGDI()
     pSalData->mhStockBrushAry[2]        = CreateSolidBrush( 
pSalData->maStockBrushColorAry[2] );
     pSalData->mhStockBrushAry[3]        = CreateSolidBrush( 
pSalData->maStockBrushColorAry[3] );
     pSalData->mnStockBrushCount = 4;
-
-    // initialize temporary font lists
-    pSalData->mpSharedTempFontItem = nullptr;
-    pSalData->mpOtherTempFontItem = nullptr;
 }
 
 void ImplFreeSalGDI()
@@ -123,7 +119,7 @@ void ImplFreeSalGDI()
     }
 
     // delete temporary font list
-    ImplReleaseTempFonts(*pSalData, true);
+    ImplReleaseTempFonts(*pSalData);
 
     pSalData->mbResourcesAlreadyFreed = true;
 }

Reply via email to