Bug 991400 - Prevent gfxPath instances from being created on the stack (they're refcounted). r=dholbert, a=sylvestre
authorJonathan Watt <jwatt@jwatt.org>
Sun, 13 Apr 2014 11:10:33 +0100
changeset 183735 679aa869f39fc4e1ee84f856cc6ba51cfcf80936
parent 183734 b074e386a410372f41afd3f7bbe9ab134db5442b
child 183736 c6f80ae1ee23a00a1ea3dc2a1c9af4095d931390
push id3464
push userjwatt@jwatt.org
push dateMon, 14 Apr 2014 09:18:29 +0000
treeherdermozilla-beta@679aa869f39f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, sylvestre
bugs991400
milestone29.0
Bug 991400 - Prevent gfxPath instances from being created on the stack (they're refcounted). r=dholbert, a=sylvestre
content/svg/content/src/SVGEllipseElement.cpp
gfx/thebes/gfxPath.h
--- a/content/svg/content/src/SVGEllipseElement.cpp
+++ b/content/svg/content/src/SVGEllipseElement.cpp
@@ -93,18 +93,18 @@ SVGEllipseElement::GetLengthInfo()
 // nsSVGPathGeometryElement methods
 
 void
 SVGEllipseElement::ConstructPath(gfxContext *aCtx)
 {
   if (!aCtx->IsCairo()) {
     RefPtr<Path> path = BuildPath();
     if (path) {
-      gfxPath gfxpath(path);
-      aCtx->SetPath(&gfxpath);
+      nsRefPtr<gfxPath> gfxpath = new gfxPath(path);
+      aCtx->SetPath(gfxpath);
     }
     return;
   }
 
   float x, y, rx, ry;
 
   GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr);
 
--- a/gfx/thebes/gfxPath.h
+++ b/gfx/thebes/gfxPath.h
@@ -18,25 +18,27 @@ namespace gfx {
 class Path;
 }
 }
 
 /**
  * Class representing a path. Can be created by copying the current path
  * of a gfxContext.
  */
-class gfxPath {
+class gfxPath MOZ_FINAL {
     NS_INLINE_DECL_REFCOUNTING(gfxPath)
 
     friend class gfxContext;
 
     gfxPath(cairo_path_t* aPath);
 
 public:
     gfxPath(mozilla::gfx::Path* aPath);
-    virtual ~gfxPath();
 
 private:
+    // Private destructor, to discourage deletion outside of Release():
+    ~gfxPath();
+
     cairo_path_t* mPath;
     mozilla::RefPtr<mozilla::gfx::Path> mMoz2DPath;
 };
 
 #endif