speculative fix in TransitionView. don't validate after detachFromParent (we may...
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 14 Jun 2013 17:46:07 +0000 (17:46 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 14 Jun 2013 17:46:07 +0000 (17:46 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@9619 2bbb7eff-a529-9590-31e7-b0007b416f81

include/views/SkView.h
samplecode/TransitionView.cpp
src/views/SkView.cpp

index 66709ee..d03c741 100644 (file)
@@ -365,19 +365,20 @@ protected:
     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;
index 1caff13..e4fa38e 100644 (file)
@@ -77,12 +77,18 @@ protected:
     }
     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")) {
index b1bdb25..e3e05f9 100644 (file)
@@ -556,7 +556,6 @@ void SkView::detachFromParent() {
         this->detachFromParent_NoLayout();
         parent->invokeLayout();
     }
-    this->validate();
 }
 
 SkView* SkView::attachChildToBack(SkView* child) {
@@ -777,6 +776,7 @@ SkView* SkView::B2FIter::next() {
 #ifdef SK_DEBUG
 
 void SkView::validate() const {
+//    SkASSERT(this->getRefCnt() > 0 && this->getRefCnt() < 100);
     if (fParent) {
         SkASSERT(fNextSibling);
         SkASSERT(fPrevSibling);