gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r12256: Add more tests for unloading


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r12256: Add more tests for unloading DisplayObjects. Correct unloading for various
Date: Fri, 18 Jun 2010 11:14:04 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 12256 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2010-06-18 11:14:04 +0200
message:
  Add more tests for unloading DisplayObjects. Correct unloading for various
  passes in the swfdec testsuite, misc-ming.all, and the new tests in
  actionscript.all.
modified:
  libcore/Button.cpp
  libcore/Button.h
  libcore/DisplayList.cpp
  libcore/DisplayObject.cpp
  libcore/DisplayObject.h
  libcore/MovieClip.cpp
  libcore/MovieClip.h
  testsuite/actionscript.all/MovieClip.as
  testsuite/misc-ming.all/ActionOrderTest4.c
  testsuite/swfdec/PASSING
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp        2010-06-09 14:39:48 +0000
+++ b/libcore/Button.cpp        2010-06-17 09:36:43 +0000
@@ -854,7 +854,7 @@
 }
 
 bool
-Button::unload()
+Button::unloadChildren()
 {
 
     bool childsHaveUnload = false;
@@ -877,9 +877,7 @@
     //       hit instance off the GC).
     _hitCharacters.clear();
 
-    bool hasUnloadEvent = DisplayObject::unload();
-
-    return hasUnloadEvent || childsHaveUnload;
+    return childsHaveUnload;
 }
 
 void

=== modified file 'libcore/Button.h'
--- a/libcore/Button.h  2010-06-06 10:17:39 +0000
+++ b/libcore/Button.h  2010-06-17 09:36:43 +0000
@@ -116,7 +116,7 @@
        bool isEnabled();
        
        /// Properly unload contained DisplayObjects
-       bool unload();
+       virtual bool unloadChildren();
 
        /// Properly destroy contained DisplayObjects
        void destroy();

=== modified file 'libcore/DisplayList.cpp'
--- a/libcore/DisplayList.cpp   2010-06-06 10:17:39 +0000
+++ b/libcore/DisplayList.cpp   2010-06-18 08:44:46 +0000
@@ -574,37 +574,38 @@
 bool
 DisplayList::unload()
 {
-    //GNASH_REPORT_FUNCTION;
-
     testInvariant();
 
-    // Should we start looking from beginNonRemoved ?
-    // If I try, I get a failure in swfdec/gotoframe.swf
-    for (iterator it = _charsByDepth.begin(), itEnd = _charsByDepth.end();
-            it != itEnd; )
+    bool unloadHandler = false;
+
+    // All children with an unload handler should be unloaded. As soon as
+    // the first unload handler is encountered, subsequent children should
+    // not be destroyed or removed from the display list. This affects
+    // children without an unload handler.
+    for (iterator it = beginNonRemoved(_charsByDepth),
+            itEnd = _charsByDepth.end(); it != itEnd; )
     {
         // make a copy
         DisplayItem di = *it;
 
-        // skip if already unloaded
-        if (di->unloaded()) {
-            // TODO: call di->destroy(); ?
+        // Destroy those with a handler anyway?
+        if (di->unload()) {
+            unloadHandler = true;
             ++it;
             continue;
         }
 
-        if (!di->unload()) {
-            // no event handler queued, we remove
-            // will be destroyed on next iteration, or by unload
-            // handler ? we don't want soft-ref to rebind here
-            it = _charsByDepth.erase(it); 
+        if (!unloadHandler) {
+            di->destroy();
+            it = _charsByDepth.erase(it);
         }
         else ++it;
+
     }
 
     testInvariant();
 
-    return ! _charsByDepth.empty();
+    return unloadHandler;
 
 }
 

=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2010-06-14 11:16:09 +0000
+++ b/libcore/DisplayObject.cpp 2010-06-18 08:44:46 +0000
@@ -114,6 +114,12 @@
 {
     return _object;
 }
+    
+bool
+DisplayObject::unloaded() const
+{
+    return _unloaded;
+}
 
 void
 DisplayObject::getLoadedMovie(Movie* extern_movie)
@@ -471,6 +477,8 @@
 DisplayObject::unload()
 {
 
+    const bool childHandler = unloadChildren();
+
        if (!_unloaded) {
                queueEvent(event_id::UNLOAD, movie_root::PRIORITY_DOACTION);
        }
@@ -479,9 +487,11 @@
     if (_maskee) _maskee->setMask(0);
     if (_mask) _mask->setMaskee(0);
 
-       const bool hasEvent = hasEventHandler(event_id::UNLOAD);
+       const bool hasEvent = hasEventHandler(event_id::UNLOAD) || childHandler;
 
-    if (!hasEvent) stage().removeQueuedConstructor(this);
+    if (!hasEvent) {
+        stage().removeQueuedConstructor(this);
+    }
 
        _unloaded = true;
 

=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h   2010-06-06 10:17:39 +0000
+++ b/libcore/DisplayObject.h   2010-06-18 08:44:46 +0000
@@ -806,14 +806,13 @@
     /// @return true if any onUnload event handler was defined
     ///                 by either this or any child DisplayObjects, false
     ///                 otherwise.
-    ///
-    virtual bool unload();
+    bool unload();
 
     /// Accept a loaded Movie
     virtual void getLoadedMovie(Movie* newMovie);
 
     /// Return true if this DisplayObject was unloaded from the stage
-    bool unloaded() const { return _unloaded; }
+    bool unloaded() const;
 
     /// Mark this DisplayObject as destroyed
     //
@@ -978,6 +977,8 @@
     virtual void markOwnResources() const {}
 
 protected:
+    
+    virtual bool unloadChildren() { return false; }
 
     /// Get the movie_root to which this DisplayObject belongs.
     movie_root& stage() {

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2010-06-16 10:02:02 +0000
+++ b/libcore/MovieClip.cpp     2010-06-17 12:07:20 +0000
@@ -1845,7 +1845,7 @@
 }
 
 bool
-MovieClip::unload()
+MovieClip::unloadChildren()
 {
 #ifdef GNASH_DEBUG
     log_debug(_("Unloading movieclip '%s'"), getTargetPath());
@@ -1854,18 +1854,13 @@
     // stop any pending streaming sounds
     stopStreamSound();
 
-    bool childHaveUnloadHandler = _displayList.unload();
-
     // We won't be displayed again, so worth releasing
     // some memory. The drawable might take a lot of memory
     // on itself.
     _drawable.clear();
-
-    bool selfHaveUnloadHandler = DisplayObject::unload();
-
-    bool shouldKeepAlive = (selfHaveUnloadHandler || childHaveUnloadHandler);
-
-    return shouldKeepAlive;
+    
+    return _displayList.unload();
+
 }
 
 void

=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h       2010-06-06 10:17:39 +0000
+++ b/libcore/MovieClip.h       2010-06-17 09:36:43 +0000
@@ -385,7 +385,7 @@
 
     /// Unload all contents in the displaylist and this instance
     /// See DisplayObject::unload for more info
-    bool unload();
+    virtual bool unloadChildren();
 
     /// Mark this sprite as destroyed
     //

=== modified file 'testsuite/actionscript.all/MovieClip.as'
--- a/testsuite/actionscript.all/MovieClip.as   2010-01-11 06:41:38 +0000
+++ b/testsuite/actionscript.all/MovieClip.as   2010-06-18 07:43:35 +0000
@@ -123,11 +123,11 @@
 #endif
 
 #if OUTPUT_VERSION == 7
-       check_totals(927); // SWF7
+       check_totals(943); // SWF7
 #endif
 
 #if OUTPUT_VERSION >= 8
-       check_totals(1017); // SWF8+
+       check_totals(1033); // SWF8+
 #endif
 
        play();
@@ -728,6 +728,61 @@
 check_equals(sr61._name, "hardref");
 check_equals(sr62._name, "hardref");
 
+
+#if OUTPUT_VERSION > 6
+
+ul4 = _root.createEmptyMovieClip("hul4", getNextHighestDepth());
+ul5 = ul4.createEmptyMovieClip("hul5", ul4.getNextHighestDepth());
+ul5.a = 7;
+ul6 = ul4.createEmptyMovieClip("hul6", ul4.getNextHighestDepth());
+ul6.a = 7;
+ul7 = ul4.createEmptyMovieClip("hul7", ul4.getNextHighestDepth());
+ul7.a = 7;
+ul8 = ul4.createEmptyMovieClip("hul8", ul4.getNextHighestDepth());
+ul8.a = 7;
+ul9 = ul4.createEmptyMovieClip("hul9", ul4.getNextHighestDepth());
+ul9.a = 7;
+
+ul7.onUnload = function() {};
+ul9.onUnload = function() {};
+
+// Sanity check
+check_equals(ul5.a, 7);
+
+ul4.removeMovieClip();
+
+// Child property removed
+check_equals(typeof(ul4.hul5), "undefined");
+
+// MovieClip still exists
+check_equals(typeof(ul5), "movieclip");
+
+// But without properties.
+check_equals(ul5.a, undefined);
+
+// Same with this child
+check_equals(typeof(ul4.hul6), "undefined");
+check_equals(typeof(ul6), "movieclip");
+check_equals(ul6.a, undefined);
+
+// Has unload handler, so not removed.
+check_equals(typeof(ul4.hul7), "movieclip");
+check_equals(typeof(ul7), "movieclip");
+check_equals(ul7.a, 7);
+
+// No unload handler, but still not removed because there was a handler at
+// a lower depth.
+check_equals(typeof(ul4.hul8), "movieclip");
+check_equals(typeof(ul8), "movieclip");
+check_equals(ul8.a, 7);
+
+// Also has unload handler.
+check_equals(typeof(ul4.hul9), "movieclip");
+check_equals(typeof(ul9), "movieclip");
+check_equals(ul9.a, 7);
+
+#endif
+
 // When getting a member by name, the one with lowest
 // depth comes up first
 check_equals(hardref.member, 6); // depth 61 < 62

=== modified file 'testsuite/misc-ming.all/ActionOrderTest4.c'
--- a/testsuite/misc-ming.all/ActionOrderTest4.c        2010-06-17 07:44:01 
+0000
+++ b/testsuite/misc-ming.all/ActionOrderTest4.c        2010-06-17 11:36:16 
+0000
@@ -154,7 +154,7 @@
     
     SWFMovie_nextFrame(mo);
     
-    xcheck_equals(mo, "_global.arr.length", "24");
+    check_equals(mo, "_global.arr.length", "24");
     check_equals(mo, "_global.arr[0]", "'Frame 2 actions: undefined'");
     check_equals(mo, "_global.arr[1]", "'static load: undefined'");
     check_equals(mo, "_global.arr[2]", "'ctor: 0'");
@@ -162,22 +162,22 @@
     check_equals(mo, "_global.arr[4]", "'dynamic load: 0'");
     check_equals(mo, "_global.arr[5]", "'Frame 3 actions: 0'");
     check_equals(mo, "_global.arr[6]", "'Frame 2 actions: 0'");
-    xcheck_equals(mo, "_global.arr[7]", "'Frame 3 actions: 0'");
-    xcheck_equals(mo, "_global.arr[8]", "'Frame 2 actions: 0'");
-    xcheck_equals(mo, "_global.arr[9]", "'ctor: 1'");
-    xcheck_equals(mo, "_global.arr[10]", "'dynamic unload: 0'");
-    xcheck_equals(mo, "_global.arr[11]", "'static load: 1'");
-    xcheck_equals(mo, "_global.arr[12]", "'dynamic load: 1'");
-    xcheck_equals(mo, "_global.arr[13]", "'Frame 3 actions: 0'");
-    xcheck_equals(mo, "_global.arr[14]", "'Frame 2 actions: 0'");
+    check_equals(mo, "_global.arr[7]", "'Frame 3 actions: 0'");
+    check_equals(mo, "_global.arr[8]", "'Frame 2 actions: 0'");
+    check_equals(mo, "_global.arr[9]", "'ctor: 1'");
+    check_equals(mo, "_global.arr[10]", "'dynamic unload: 0'");
+    check_equals(mo, "_global.arr[11]", "'static load: 1'");
+    check_equals(mo, "_global.arr[12]", "'dynamic load: 1'");
+    check_equals(mo, "_global.arr[13]", "'Frame 3 actions: 0'");
+    check_equals(mo, "_global.arr[14]", "'Frame 2 actions: 0'");
     xcheck_equals(mo, "_global.arr[15]", "'Frame 3 actions: 1'");
     xcheck_equals(mo, "_global.arr[16]", "'Frame 2 actions: 1'");
-    xcheck_equals(mo, "_global.arr[17]", "'ctor: 2'");
-    xcheck_equals(mo, "_global.arr[18]", "'dynamic unload: 1'");
-    xcheck_equals(mo, "_global.arr[19]", "'static load: 2'");
-    xcheck_equals(mo, "_global.arr[20]", "'dynamic load: 2'");
-    xcheck_equals(mo, "_global.arr[21]", "'Frame 3 actions: 1'");
-    xcheck_equals(mo, "_global.arr[22]", "'Frame 2 actions: 1'");
+    check_equals(mo, "_global.arr[17]", "'ctor: 2'");
+    check_equals(mo, "_global.arr[18]", "'dynamic unload: 1'");
+    check_equals(mo, "_global.arr[19]", "'static load: 2'");
+    check_equals(mo, "_global.arr[20]", "'dynamic load: 2'");
+    check_equals(mo, "_global.arr[21]", "'Frame 3 actions: 1'");
+    check_equals(mo, "_global.arr[22]", "'Frame 2 actions: 1'");
     xcheck_equals(mo, "_global.arr[23]", "'Frame 3 actions: 2'");
     xcheck_equals(mo, "_global.arr.toString()", "'Frame 2 actions: 
undefined,static load: undefined,ctor: 0,static load: 0,dynamic load: 0,Frame 3 
actions: 0,Frame 2 actions: 0,Frame 3 actions: 0,Frame 2 actions: 0,ctor: 
1,dynamic unload: 0,static load: 1,dynamic load: 1,Frame 3 actions: 0,Frame 2 
actions: 0,Frame 3 actions: 1,Frame 2 actions: 1,ctor: 2,dynamic unload: 
1,static load: 2,dynamic load: 2,Frame 3 actions: 1,Frame 2 actions: 1,Frame 3 
actions: 2'");
 

=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING  2010-06-09 11:16:33 +0000
+++ b/testsuite/swfdec/PASSING  2010-06-17 11:36:16 +0000
@@ -804,6 +804,8 @@
 movieclip-property-priorities-8.swf:ff29d6b0d091084d8003508bcf65dac6
 movieclip-references-5.swf:1a9faa42d479cff63da56135c1b298aa
 movieclip-references-6.swf:d3cc27ec41e9368c21f27fee48027b89
+movieclip-references-7.swf:5ef7fdd8d1590c3e481fe31b31efd3ef
+movieclip-references-8.swf:8b2c889b1fd575a0de1c217037ff815f
 movieclip-set-prototype-5.swf:99235a738d69d9c78fa2bc5d355c6dae
 movieclip-set-prototype-6.swf:bae79ccbb89bb7c11cd1961d2c473022
 movieclip-set-prototype-7.swf:f147fff166cc46cdcda77d5012faddb0
@@ -1091,6 +1093,9 @@
 remove-with-onUnload-5.swf:5d41fcdce5757cff3e4c9678c9c3e72b
 replaceText-newline-5.swf:1add6bd68a2b79b0b794e0d6aed2ccbb
 resolve-parent-5.swf:2bfcdac89d2c7dc405ee275324ac8fc3
+resolve-parent-6.swf:fbbfc5dd220d0d94ca3c13db171a33ea
+resolve-parent-7.swf:c72cf7eff78f3cc8cdf5b3d3725661e6
+resolve-parent-8.swf:6b5da373437b7a20ca5cd7d133ce4c09
 rewind-remove-5.swf:70780bb0428e3795f6866a1c47bb46b0
 root-onload-5.swf:4f41e2bffb53d75ce665c54312f66190
 root-onload-6.swf:0d09109c7f942e8268aa0b9661071f1d


reply via email to

[Prev in Thread] Current Thread [Next in Thread]