[Libreoffice-commits] core.git: vcl/inc vcl/source

Eike Rathke erack at redhat.com
Fri May 10 05:22:38 PDT 2013


 vcl/inc/impfont.hxx     |    8 +++++---
 vcl/source/gdi/font.cxx |   10 ++++++----
 2 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit 4afd9a501eae7c17c3ab8adf70d2d0146bd83fe1
Author: Eike Rathke <erack at redhat.com>
Date:   Fri May 10 11:44:15 2013 +0200

    Font refcount is not uint16 (anymore)
    
    Change-Id: I1aa89a8d6f712abb4f768a413ebac29e14612484

diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index 0d91254..1ac8bd6 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -32,6 +32,8 @@
 // - Impl_Font -
 // ------------
 
+typedef sal_uInt32 FontRefCount;
+
 class Impl_Font
 {
 public:
@@ -50,7 +52,7 @@ private:
     friend class Font;
     void                AskConfig();
 
-    int                 mnRefCount;
+    FontRefCount        mnRefCount;
     String              maFamilyName;
     String              maStyleName;
     Size                maSize;
@@ -99,7 +101,7 @@ private:
     long    mnLineHeight;  // Ascent+Descent+EmphasisMark
     long    mnSlant;       // Slant
     sal_uInt16  mnMiscFlags;   // Misc Flags
-    sal_uInt32  mnRefCount;    // Reference Counter
+    FontRefCount mnRefCount;    // Reference Counter
 
     enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 };
 
@@ -206,7 +208,7 @@ private:
     const sal_uInt16*       mpGlyphIds;       // individual glyphid mappings
     int                 mnRangeCount;
     int                 mnCharCount;      // covered codepoints
-    mutable int         mnRefCount;
+    mutable FontRefCount    mnRefCount;
 };
 
 // CmapResult is a normalized version of the many CMAP formats
diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx
index 4d313c5..94c64e1 100644
--- a/vcl/source/gdi/font.cxx
+++ b/vcl/source/gdi/font.cxx
@@ -240,11 +240,12 @@ Font::Font( const Font& rFont )
 {
     DBG_CTOR( Font, NULL );
     DBG_CHKOBJ( &rFont, Font, NULL );
-    DBG_ASSERT( rFont.mpImplFont->mnRefCount < 0xFFFE, "Font: RefCount overflow" );
+    bool bRefIncrementable = rFont.mpImplFont->mnRefCount < ::std::numeric_limits<FontRefCount>::max();
+    DBG_ASSERT( bRefIncrementable, "Font: RefCount overflow" );
 
     mpImplFont = rFont.mpImplFont;
     // do not count static objects (where RefCount is zero)
-    if ( mpImplFont->mnRefCount )
+    if ( mpImplFont->mnRefCount && bRefIncrementable )
         mpImplFont->mnRefCount++;
 }
 
@@ -579,11 +580,12 @@ Font& Font::operator=( const Font& rFont )
 {
     DBG_CHKTHIS( Font, NULL );
     DBG_CHKOBJ( &rFont, Font, NULL );
-    DBG_ASSERT( rFont.mpImplFont->mnRefCount < 0xFFFE, "Font: RefCount overflow" );
+    bool bRefIncrementable = rFont.mpImplFont->mnRefCount < ::std::numeric_limits<FontRefCount>::max();
+    DBG_ASSERT( bRefIncrementable, "Font: RefCount overflow" );
 
     // Increment RefCount first, so that we can reference ourselves
     // RefCount == 0 for static objects
-    if ( rFont.mpImplFont->mnRefCount )
+    if ( rFont.mpImplFont->mnRefCount && bRefIncrementable )
         rFont.mpImplFont->mnRefCount++;
 
     // If it's not static ImplData and if it's the last reference, delete it


More information about the Libreoffice-commits mailing list