vcl/inc/win/saldata.hxx | 2 +- vcl/win/app/salshl.cxx | 8 ++++---- vcl/win/gdi/salgdi.cxx | 7 +++---- 3 files changed, 8 insertions(+), 9 deletions(-)
New commits: commit 5e7d19b49c7c86b408b476e9bcbdd92baf4aba85 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Mar 2 14:27:24 2026 +0000 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Mar 2 19:54:09 2026 +0100 vcl win: Don't allocate SalIcon on the heap As pointed out by Noel Grandin in [1], this can now be further simplified to no longer allocate the SalIcon on the heap, now that the icon cache was switched to a std::unordered_map in earlier commit commit 5c62d0b2a1ad867b5339721e79fb660c5aca1991 Author: Michael Weghorn <[email protected]> Date: Fri Feb 27 08:13:06 2026 +0000 vcl win: Use a std::unordered_map for icon cache [1] https://gerrit.libreoffice.org/c/core/+/200566/comment/009934f8_3f29cf3a/ Change-Id: I0df9ff63101cbddb3d532800f95ff49e7bdf3968 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200834 Reviewed-by: Noel Grandin <[email protected]> Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx index 83798cf607e1..0469ae82629d 100644 --- a/vcl/inc/win/saldata.hxx +++ b/vcl/inc/win/saldata.hxx @@ -113,7 +113,7 @@ public: WPARAM mnSalObjWantKeyEvt; // KeyEvent that should be processed by SalObj-Hook bool mbObjClassInit; // is SALOBJECTCLASS initialised DWORD mnAppThreadId; // Id from Application-Thread - std::unordered_map<int, SalIcon*> maIconCache; // icon cache + std::unordered_map<int, SalIcon> maIconCache; // icon cache TempFontItem* mpTempFontItem; // LibreOffice own fonts (shared and embedded) bool mbThemeChanged; // true if visual theme was changed: throw away theme handles bool mbThemeMenuSupport; diff --git a/vcl/win/app/salshl.cxx b/vcl/win/app/salshl.cxx index b8485ca24412..6817f0d65a80 100644 --- a/vcl/win/app/salshl.cxx +++ b/vcl/win/app/salshl.cxx @@ -63,9 +63,9 @@ bool ImplLoadSalIcon(int nId, HICON& rIcon, HICON& rSmallIcon, SalData* pSalData auto aIt = pSalData->maIconCache.find(nId); if (aIt != pSalData->maIconCache.end()) { - SalIcon* pSalIcon = aIt->second; - rIcon = pSalIcon->hIcon; - rSmallIcon = pSalIcon->hSmallIcon; + SalIcon& rSalIcon = aIt->second; + rIcon = rSalIcon.hIcon; + rSmallIcon = rSalIcon.hSmallIcon; return (rSmallIcon != nullptr); } @@ -99,7 +99,7 @@ bool ImplLoadSalIcon(int nId, HICON& rIcon, HICON& rSmallIcon, SalData* pSalData if( rIcon ) { // add to icon cache - pSalData->maIconCache[nId] = new SalIcon{rIcon, rSmallIcon}; + pSalData->maIconCache[nId] = SalIcon{rIcon, rSmallIcon}; } return (rSmallIcon != nullptr); diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx index 1e75f045dea7..c5dbf1955f0d 100644 --- a/vcl/win/gdi/salgdi.cxx +++ b/vcl/win/gdi/salgdi.cxx @@ -107,10 +107,9 @@ void ImplFreeSalGDI() // delete icon cache for (auto aIt : pSalData->maIconCache) { - SalIcon* pIcon = aIt.second; - DestroyIcon( pIcon->hIcon ); - DestroyIcon( pIcon->hSmallIcon ); - delete pIcon; + SalIcon& rIcon = aIt.second; + DestroyIcon(rIcon.hIcon); + DestroyIcon(rIcon.hSmallIcon); } pSalData->maIconCache.clear();
