Cleanup unref and null
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 14 Feb 2014 17:27:10 +0000 (17:27 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 14 Feb 2014 17:27:10 +0000 (17:27 +0000)
BUG=skia:
R=mtklein@google.com, scroggo@google.com, iancottrell@chromium.org

Author: iancottrell@google.com

Review URL: https://codereview.chromium.org/163053005

git-svn-id: http://skia.googlecode.com/svn/trunk@13457 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkPicture.cpp

index e226c26..7762939 100644 (file)
@@ -164,12 +164,7 @@ void SkPicture::clone(SkPicture* pictures, int count) const {
 
         clone->fWidth = fWidth;
         clone->fHeight = fHeight;
-        clone->fRecord = NULL;
-
-        if (NULL != clone->fRecord) {
-            clone->fRecord->unref();
-            clone->fRecord = NULL;
-        }
+        SkSafeSetNull(clone->fRecord);
         SkDELETE(clone->fPlayback);
 
         /*  We want to copy the src's playback. However, if that hasn't been built
@@ -196,10 +191,7 @@ SkCanvas* SkPicture::beginRecording(int width, int height,
         fPlayback = NULL;
     }
 
-    if (NULL != fRecord) {
-        fRecord->unref();
-        fRecord = NULL;
-    }
+    SkSafeSetNull(fRecord);
 
     SkBitmap bm;
     bm.setConfig(SkBitmap::kNo_Config, width, height);
@@ -246,8 +238,7 @@ void SkPicture::endRecording() {
         if (NULL != fRecord) {
             fRecord->endRecording();
             fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
-            fRecord->unref();
-            fRecord = NULL;
+            SkSafeSetNull(fRecord);
         }
     }
     SkASSERT(NULL == fRecord);