speculative fix in TransitionView. don't validate after detachFromParent (we may have been deleted)

git-svn-id: http://skia.googlecode.com/svn/trunk@9619 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/views/SkView.h b/include/views/SkView.h
index 66709ee..d03c741 100644
--- a/include/views/SkView.h
+++ b/include/views/SkView.h
@@ -365,19 +365,20 @@
     virtual void    onPostInflate(const SkTDict<SkView*>&);
 
 public:
+#ifdef SK_DEBUG
+    void validate() const;
+#else
+    void validate() const {}
+#endif
     // default action is to inval the view
     virtual void    onFocusChange(bool gainFocusP);
+
 protected:
 
     // override these if you're acting as a layer/host
     virtual bool    onGetFocusView(SkView**) const { return false; }
     virtual bool    onSetFocusView(SkView*) { return false; }
 
-#ifdef SK_DEBUG
-    void validate() const;
-#else
-    void validate() const {}
-#endif
 private:
     SkScalar    fWidth, fHeight;
     SkMatrix    fMatrix;
diff --git a/samplecode/TransitionView.cpp b/samplecode/TransitionView.cpp
index 1caff13..e4fa38e 100644
--- a/samplecode/TransitionView.cpp
+++ b/samplecode/TransitionView.cpp
@@ -77,12 +77,18 @@
     }
     virtual bool onEvent(const SkEvent& evt) {
         if (evt.isType(gReplaceTransitionEvt)) {
+            SkView* prev = fPrev;
+            prev->ref();
+
             fPrev->detachFromParent();
             fPrev = (SkView*)SkEventSink::FindSink(evt.getFast32());
             (void)SampleView::SetUsePipe(fPrev, SkOSMenu::kOffState);
             //attach the new fPrev and call unref to balance the ref in onDraw
             this->attachChildToBack(fPrev)->unref();
             this->inval(NULL);
+            
+            SkASSERT(1 == prev->getRefCnt());
+            prev->unref();
             return true;
         }
         if (evt.isType("transition-done")) {
diff --git a/src/views/SkView.cpp b/src/views/SkView.cpp
index b1bdb25..e3e05f9 100644
--- a/src/views/SkView.cpp
+++ b/src/views/SkView.cpp
@@ -556,7 +556,6 @@
         this->detachFromParent_NoLayout();
         parent->invokeLayout();
     }
-    this->validate();
 }
 
 SkView* SkView::attachChildToBack(SkView* child) {
@@ -777,6 +776,7 @@
 #ifdef SK_DEBUG
 
 void SkView::validate() const {
+//    SkASSERT(this->getRefCnt() > 0 && this->getRefCnt() < 100);
     if (fParent) {
         SkASSERT(fNextSibling);
         SkASSERT(fPrevSibling);