summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-10-03 16:00:11 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-10-12 13:09:24 +0200
commit2e78c92dfeefc301b1cc69130433917c3e77bfdc (patch)
treeeed658c8b7bd9d99919f543753bc21c6bd49ace4 /vcl/inc
parent0f2bec39d5d90ec7f0879e57ff5b23d671bf8489 (diff)
use unique_ptr for SystemFontList, fix leak
Using unique_ptr here fixes a leak, which in turn was hiding the fact that we don't manage the lifecycle of CTFontDescriptor in CoreTextFontFace properly Change-Id: I2ade5fae9a40ad0ebb10538488018941f3f285c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140916 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/osx/saldata.hxx3
-rw-r--r--vcl/inc/quartz/ctfonts.hxx2
-rw-r--r--vcl/inc/quartz/salgdi.h8
3 files changed, 8 insertions, 5 deletions
diff --git a/vcl/inc/osx/saldata.hxx b/vcl/inc/osx/saldata.hxx
index e201f45715c2..ba4d6e8c856b 100644
--- a/vcl/inc/osx/saldata.hxx
+++ b/vcl/inc/osx/saldata.hxx
@@ -36,6 +36,7 @@
#include <functional>
#include <list>
#include <map>
+#include <memory>
#include <unordered_set>
#include <vector>
#include <o3tl/enumarray.hxx>
@@ -68,7 +69,7 @@ public:
SalObject *mpFirstObject; // pointer of first object window
SalVirtualDevice *mpFirstVD; // first VirDev
SalPrinter *mpFirstPrinter; // first printing printer
- SystemFontList *mpFontList;
+ std::unique_ptr<SystemFontList> mpFontList;
NSStatusItem* mpStatusItem; // one status item that draws all our statuses
// at the moment this is only one add menu button
CGColorSpaceRef mxRGBSpace;
diff --git a/vcl/inc/quartz/ctfonts.hxx b/vcl/inc/quartz/ctfonts.hxx
index 431385aeeda6..be68dea71c9a 100644
--- a/vcl/inc/quartz/ctfonts.hxx
+++ b/vcl/inc/quartz/ctfonts.hxx
@@ -23,7 +23,7 @@
#include <quartz/salgdi.h>
#include <sallayout.hxx>
-SystemFontList* GetCoretextFontList();
+std::unique_ptr<SystemFontList> GetCoretextFontList();
FontAttributes DevFontFromCTFontDescriptor(CTFontDescriptorRef, bool*);
#endif // INCLUDED_VCL_INC_QUARTZ_CTFONTS_HXX
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 0bf004033c52..5d2611f5b06e 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -61,11 +61,13 @@ class XorEmulation;
class CoreTextFontFace : public vcl::font::PhysicalFontFace
{
public:
- CoreTextFontFace( const FontAttributes&, sal_IntPtr nFontID );
+ CoreTextFontFace( const FontAttributes&, CTFontDescriptorRef xRef );
virtual ~CoreTextFontFace() override;
sal_IntPtr GetFontId() const override;
+ CTFontDescriptorRef GetFontDescriptorRef() const { return mxFontDescriptor; }
+
int GetFontTable( uint32_t nTagCode, unsigned char* ) const;
rtl::Reference<LogicalFontInstance> CreateFontInstance(const vcl::font::FontSelectPattern&) const override;
@@ -73,7 +75,7 @@ public:
virtual hb_blob_t* GetHbTable(hb_tag_t nTag) const override;
private:
- const sal_IntPtr mnFontId;
+ CTFontDescriptorRef mxFontDescriptor;
};
class CoreTextStyle final : public LogicalFontInstance
@@ -96,7 +98,7 @@ public:
bool mbFauxBold;
private:
- explicit CoreTextStyle(const vcl::font::PhysicalFontFace&, const vcl::font::FontSelectPattern&);
+ explicit CoreTextStyle(const CoreTextFontFace&, const vcl::font::FontSelectPattern&);
virtual void ImplInitHbFont(hb_font_t*) override;
bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;