Bug 991285 part 2: Give nsRenderingContext a private destructor and mark it as MOZ_FINAL, for safer refcounting. r=roc
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 15 Apr 2014 12:55:24 -0700
changeset 178630 920ab5ed8ee5f21b3594373e9ffb5e91b3abd6f8
parent 178629 22cf932abe41d839d05f7a194af29581c661a62c
child 178631 f4929fbf4ea1643bfeea67d959e0da33fe0a7074
push id42325
push userdholbert@mozilla.com
push dateTue, 15 Apr 2014 19:56:25 +0000
treeherdermozilla-inbound@920ab5ed8ee5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs991285
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 991285 part 2: Give nsRenderingContext a private destructor and mark it as MOZ_FINAL, for safer refcounting. r=roc
gfx/src/nsRenderingContext.h
--- a/gfx/src/nsRenderingContext.h
+++ b/gfx/src/nsRenderingContext.h
@@ -29,25 +29,24 @@ struct nsRect;
 
 typedef enum {
     nsLineStyle_kNone   = 0,
     nsLineStyle_kSolid  = 1,
     nsLineStyle_kDashed = 2,
     nsLineStyle_kDotted = 3
 } nsLineStyle;
 
-class nsRenderingContext
+class nsRenderingContext MOZ_FINAL
 {
     typedef mozilla::gfx::UserData UserData;
     typedef mozilla::gfx::UserDataKey UserDataKey;
     typedef mozilla::gfx::DrawTarget DrawTarget;
 
 public:
     nsRenderingContext() : mP2A(0.) {}
-    // ~nsRenderingContext() {}
 
     NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
 
     void Init(nsDeviceContext* aContext, gfxASurface* aThebesSurface);
     void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
     void Init(nsDeviceContext* aContext, DrawTarget* aDrawTarget);
 
     // These accessors will never return null.
@@ -125,17 +124,22 @@ public:
     }
     void *GetUserData(UserDataKey *key) {
       return mUserData.Get(key);
     }
     void *RemoveUserData(UserDataKey *key) {
       return mUserData.Remove(key);
     }
 
-protected:
+private:
+    // Private destructor, to discourage deletion outside of Release():
+    ~nsRenderingContext()
+    {
+    }
+
     int32_t GetMaxChunkLength();
 
     nsRefPtr<gfxContext> mThebes;
     nsRefPtr<nsDeviceContext> mDeviceContext;
     nsRefPtr<nsFontMetrics> mFontMetrics;
 
     double mP2A; // cached app units per device pixel value