[Libreoffice-commits] .: Branch 'gr2' - vcl/inc vcl/source vcl/win

Martin Hosken mhosken at kemper.freedesktop.org
Mon Mar 7 20:47:33 PST 2011


 vcl/inc/vcl/graphite_layout.hxx         |    5 ++++-
 vcl/source/glyphs/graphite_features.cxx |    6 +-----
 vcl/win/source/gdi/winlayout.cxx        |    1 +
 3 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 12c6b0c619cecccf814341f36ce6b08650d94c91
Author: Martin Hosken <martin_hosken at sil.org>
Date:   Tue Mar 8 11:45:16 2011 +0700

    Attempt to fix winlayout memory leak

diff --git a/vcl/inc/vcl/graphite_layout.hxx b/vcl/inc/vcl/graphite_layout.hxx
index 1c8900f..2012e2b 100644
--- a/vcl/inc/vcl/graphite_layout.hxx
+++ b/vcl/inc/vcl/graphite_layout.hxx
@@ -81,6 +81,8 @@ public:
     };
     void addFont(int ppm, gr_font * pFont)
     {
+        if (m_fonts[ppm])
+            gr_font_destroy(m_fonts[ppm]);
         m_fonts[ppm] = pFont;
     }
 private:
@@ -107,7 +109,7 @@ public:
 
 private:
     const gr_face *         mpFace; // not owned by layout
-    gr_font *               mpFont; // owned by layout
+    gr_font *               mpFont; // not owned by layout
     int                     mnSegCharOffset; // relative to ImplLayoutArgs::mpStr
     long                    mnWidth;
     std::vector<int>        mvChar2BaseGlyph;
@@ -150,6 +152,7 @@ public:
 
     virtual ~GraphiteLayout() throw();
     void SetFont(gr_font * pFont) { mpFont = pFont; }
+    gr_font * GetFont() { return mpFont; }
     void SetFeatures(grutils::GrFeatureParser * aFeature) { mpFeatures = aFeature; }
     void SetFontScale(float s) { mfScaling = s; };
     virtual sal_GlyphId getKashidaGlyph(int & width) = 0;
diff --git a/vcl/source/glyphs/graphite_features.cxx b/vcl/source/glyphs/graphite_features.cxx
index 6445765..dabb11f 100644
--- a/vcl/source/glyphs/graphite_features.cxx
+++ b/vcl/source/glyphs/graphite_features.cxx
@@ -161,7 +161,7 @@ void GrFeatureParser::setLang(const gr_face * pFace, const rtl::OString & lang)
 {
     FeatId aLang;
     aLang.num = 0;
-    if (lang.getLength() > 2)
+    if (lang.getLength() >= 2)
     {
         for (sal_Int32 i = 0; i < lang.getLength() && i < 3; i++)
         {
@@ -194,17 +194,13 @@ void GrFeatureParser::setLang(const gr_face * pFace, const rtl::OString & lang)
         if (i != gr_face_n_languages(pFace))
         {
             if (mpSettings)
-            {
                 gr_featureval_destroy(mpSettings);
-            }
             mpSettings = gr_face_featureval_for_lang(pFace, maLang.num);
             mnHash = maLang.num;
         }
     }
     if (!mpSettings)
-    {
         mpSettings = gr_face_featureval_for_lang(pFace, 0);
-    }
 }
 
 GrFeatureParser::~GrFeatureParser()
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 48aa477..683fa00 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -2805,6 +2805,7 @@ private:
 public:
     GraphiteWinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWFE);
 
+    ~GraphiteWinLayout() { gr_font_destroy(maImpl.getFont()); }
     // used by upper layers
     virtual bool  LayoutText( ImplLayoutArgs& );    // first step of layout
     virtual void  AdjustLayout( ImplLayoutArgs& );  // adjusting after fallback etc.


More information about the Libreoffice-commits mailing list