Replace reference parameter with pointer so that we can pass NULL
authortomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 8 Jul 2011 14:41:12 +0000 (14:41 +0000)
committertomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 8 Jul 2011 14:41:12 +0000 (14:41 +0000)
in SkDrawPaint::add(); check the pointer when it's used to avoid
dereferencing NULL.

Add title to Animator sample slide.

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

samplecode/SampleAnimator.cpp
src/animator/SkDrawPaint.cpp
src/animator/SkDrawPaint.h
src/animator/SkPaintParts.cpp

index 99173fc8abc76f3f224055980e335c978c2e7a28..b4e487a73c4c36275f073f6c443c4d6a613c6cca 100644 (file)
@@ -24,6 +24,7 @@ public:
 protected:
     // overrides
     virtual void onDraw(SkCanvas*);
+    virtual bool onQuery(SkEvent* evt);
     
 private:
     SkString fBaseURI;
@@ -140,6 +141,14 @@ void SkAnimatorView::onDraw(SkCanvas* canvas) {
     }
 }
 
+bool SkAnimatorView::onQuery(SkEvent* evt) {
+    if (SampleCode::TitleQ(*evt)) {
+        SampleCode::TitleR(evt, "Animator");
+        return true;
+    }
+    return this->INHERITED::onQuery(evt);
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 static SkView* MyFactory() {
index f21a15a10eb5d0643a803dffa96583587a1cbc83..cd2c915e236efc115b992e1e037b40ff71dcf049 100644 (file)
@@ -98,11 +98,11 @@ SkDrawPaint::~SkDrawPaint() {
         delete typeface;
 }
 
-bool SkDrawPaint::add(SkAnimateMaker& maker, SkDisplayable* child) {
+bool SkDrawPaint::add(SkAnimateMaker* maker, SkDisplayable* child) {
     SkASSERT(child && child->isPaintPart());
     SkPaintPart* part = (SkPaintPart*) child;
-    if (part->add())
-        maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint);
+    if (part->add() && maker)
+        maker->setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint);
     return true;
 }
 
index ea77acd93368a2fe94202a0adbc394ed3a4e0414..b68fb6b4bb62d468b03dd1db4fe42679ce501a65 100644 (file)
@@ -34,7 +34,7 @@ class SkDrawPaint : public SkDrawable {
     DECLARE_DRAW_MEMBER_INFO(Paint);
     SkDrawPaint();
     virtual ~SkDrawPaint();
-    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual bool add(SkAnimateMaker* , SkDisplayable* child);
     virtual SkDisplayable* deepCopy(SkAnimateMaker* );
     virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
index 48799c68a4041a9c8bbf5e9b866468ad605b7719..38d3ae017be2be0742ccd9a6eb351fb994c0b9d6 100644 (file)
@@ -61,7 +61,7 @@ bool SkDrawPathEffect::add() {
         fPaint->fOwnsPathEffect = true;
         return false;
     }
-    fPaint->add(*(SkAnimateMaker*) NULL, this);
+    fPaint->add(NULL, this);
     return false;
 }