gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11769: Documentation, tabs to space


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11769: Documentation, tabs to spaces.
Date: Mon, 18 Jan 2010 16:48:46 +0100
User-agent: Bazaar (2.0.2)

------------------------------------------------------------
revno: 11769 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2010-01-18 16:48:46 +0100
message:
  Documentation, tabs to spaces.
  
  Minor algorithm improvements.
removed:
  gnash_0.8.1.bb
modified:
  libbase/GnashAlgorithm.h
  libcore/MovieClip.cpp
  libcore/as_object.cpp
  libcore/asobj/flash/net/NetConnection_as.cpp
  libcore/asobj/flash/net/NetStream_as.cpp
  libcore/movie_root.cpp
  libcore/parser/SWFMovieDefinition.cpp
  libcore/parser/sprite_definition.cpp
  libcore/swf/DefineButtonTag.cpp
  libcore/swf/DefineVideoStreamTag.cpp
  libcore/swf/PlaceObject2Tag.cpp
=== removed file 'gnash_0.8.1.bb'
--- a/gnash_0.8.1.bb    2007-12-07 17:26:17 +0000
+++ b/gnash_0.8.1.bb    1970-01-01 00:00:00 +0000
@@ -1,90 +0,0 @@
-PR = "r0"
-DESCRIPTION = "Gnash is a GNU Flash movie player that supports many SWF v7 
features"
-
-LICENSE = "GPL-3"
-HOMEPAGE = "http://www.gnu.org/software/gnash";
-
-DEPENDS = "gtk+ cairo libxml2 libmad libsdl-mixer zlib boost jpeg pango curl 
agg"
-
-#SRC_URI = "ftp://ftp.gnu.org/pub/gnu/gnash/${PV}/gnash-${PV}.tar.bz2";
-#SRC_URI = 
"cvs://address@hidden/cvsroot/puppy;method=pserver;module=ftpd-topfield;tag=FTPD_TOPFIELD_0_7_4
-SRC_URI = "cvs://address@hidden/sources/gnash;method=pserver;module=gnash"
-S = "${WORKDIR}/gnash"
-
-EXTRA_OECONF = "--enable-gui=gtk \
-                --enable-renderer=agg \
-               --enable-media=gst \
-                --disable-klash \
-               --enable-z \
-               --enable-jpeg \
-               --disable-glext \
-               --enable-Xft \
-               --enable-expat \
-               --enable-mad \
-               --enable-cairo \
-               --disable-plugin \
-               --disable-cygnal \
-               --disable-ltdl-install \
-               --with-boost-incl=${STAGING_INCDIR} \
-               --with-boost-lib=${STAGING_LIBDIR} \
-               --with-libxml-incl=${STAGING_INCDIR}/libxml2 \
-               --with-libxml-lib=${STAGING_LIBDIR} \
-               --with-glib-incl=${STAGING_INCDIR}/glib-2.0 \
-#              --with-glib-lib=${STAGING_LIBDIR} \
-               --with-gtk2-incl=${STAGING_INCDIR}/gtk-2.0 \
-               --with-pango-incl=${STAGING_INCDIR}/pango-1.0 \
-#              --with-pango-lib=${STAGING_LIBDIR} \
-               --with-sdl-incl=${STAGING_INCDIR}/SDL \
-               --with-atk-incl=${STAGING_INCDIR}/atk-1.0 \
-               --with-Xft-incl=${STAGING_INCDIR}/X11 \
-               --with-expat-incl=${STAGING_INCDIR} \
-               --with-mad-incl=${STAGING_INCDIR} \
-               --with-cairo-incl=${STAGING_INCDIR}/cairo \
-               --with-curl-incl=${STAGING_INCDIR} \
-               --with-curl-lib=${STAGING_LIBDIR} \
-               " 
-
-inherit autotools pkgconfig
-
-LDFLAGS += " -L${STAGING_LIBDIR} -lcurl  -lboost_date_time -lboost_filesystem 
-lboost_iostreams -lboost_signals -lboost_thread-mt "
-CFLAGS += " -I${STAGING_INCDIR} -I${STAGING_LIBDIR}/gtk-2.0/include/ "
-CXXFLAGS += " -I${STAGING_INCDIR} -I${STAGING_LIBDIR}/gtk-2.0/include/ 
-I${STAGING_INCDIR}/cairo/ "
-
-do_configure_prepend() {
-       pwd
-       cd ${S}
-       ./autogen.sh
-}
-
-
-do_configure_append() {
-        for i in `find . -name Makefile` ; do
-               sed -i s:I/usr/include:I${STAGING_INCDIR}:g $i
-       done
-}
-
-
-PARALLEL_MAKE = ""
-
-do_compile() {
-        oe_runmake 'CC=${CC}' 'LD=${LD}' 'CFLAGS=${CFLAGS}' \
-                   'ZLIB_INCLUDE=${STAGING_INCDIR}' \
-                   'ZLIB_LIBS=${STAGING_LIBDIR}' \
-                  'PNG_INCLUDE=${STAGING_INCDIR}' \    
-                  'PNG_LIBS=${STAGING_LIBDIR}'
-}
-
-
-PACKAGES =+ " libgnashamf libgnashbackend libgnashbase libgnashgeo libgnashgui 
libgnashserver "
-
-FILES_libgnashamf = "${libdir}/libgnashamf-${PV}.so"
-FILES_libgnashbackend = "${libdir}/libgnashbackend-${PV}.so"
-FILES_libgnashbase = "${libdir}/libgnashbase-${PV}.so"
-FILES_libgnashgeo = "${libdir}/libgnashgeo-${PV}.so"
-FILES_libgnashgui = "${libdir}/libgnashgui-${PV}.so"
-FILES_libgnashserver = "${libdir}/libgnashserver-${PV}.so"
-
-do_stage() {
-        autotools_stage_all
-}
-

=== modified file 'libbase/GnashAlgorithm.h'
--- a/libbase/GnashAlgorithm.h  2010-01-01 17:48:26 +0000
+++ b/libbase/GnashAlgorithm.h  2010-01-18 14:55:27 +0000
@@ -1,4 +1,4 @@
-// GnashAlgorithm.h:  Moderately useful functors for generic algorithms
+// GnashAlgorithm.h: useful templates and functors for generic algorithms
 //
 //   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 //
@@ -20,6 +20,7 @@
 #ifndef GNASH_ALGORITHM_H
 #define GNASH_ALGORITHM_H
 
+#include <iterator>
 #include <algorithm>
 #include <boost/checked_delete.hpp>
 #include <boost/intrusive_ptr.hpp>
@@ -113,6 +114,9 @@
 template<typename T>
 struct CheckedDeleter<T**>
 {
+    /// Typedef for use in boost::bind.
+    typedef typename CheckedDeleter<T*>::result_type result_type;
+
     void operator()(T** p) const {
         CheckedDeleter<T*>()(*p);
     }
@@ -121,19 +125,64 @@
 template<typename T>
 struct CheckedDeleter<T*>
 {
+    /// Typedef for use in boost::bind.
+    typedef void result_type;
+
     void operator()(T* p) const {
         boost::checked_delete<T>(p);
     }
 };
 
-template<typename T>
-void
-deleteAllChecked(const T& c)
-{
-    std::for_each(c.begin(), c.end(),
-            CheckedDeleter<typename T::value_type>());
-}
-
+
+/// Call a functor on the second element of each element in a range.
+//
+/// @tparam T           An iterator type satisfying the requirements of a
+///                     forward iterator
+/// @tparam U           The type of the functor op.
+/// @param begin        The start of the range to call op on.
+/// @param end          The end of the range to call op on.
+/// @param op           The function to call on each second element.
+template<typename T, typename U>
+void
+foreachSecond(T begin, T end, U op)
+{
+    typedef SecondElement<typename std::iterator_traits<T>::value_type> S;
+    std::for_each(begin, end, boost::bind(op, boost::bind(S(), _1)));
+}
+
+/// Safely call delete on each element in a range.
+//
+/// This checks that the type is fully known, but cannot check whether the
+/// pointer was allocated with new. Pointers allocated with new[] or any other
+/// allocation function should never be passed to this function.
+//
+/// @param begin        The start of the range to call delete on.
+/// @param end          The end of the range to call delete on.
+template<typename T>
+void
+deleteChecked(T begin, T end)
+{
+    typedef typename std::iterator_traits<T>::value_type value_type;
+    std::for_each(begin, end, CheckedDeleter<value_type>());
+}
+
+/// Safely call delete on each second element in a range of pairs.
+//
+/// This checks that the type is fully known, but cannot check whether the
+/// pointer was allocated with new. Pointers allocated with new[] or any other
+/// allocation function should never be passed to this function.
+//
+/// @param begin        The start of the range to call delete on.
+/// @param end          The end of the range to call delete on.
+template<typename T>
+void
+deleteSecondElements(T begin, T end)
+{
+    typedef SecondElement<typename std::iterator_traits<T>::value_type> S;
+    foreachSecond(begin, end, CheckedDeleter<typename S::result_type>());
+}
+
+            
 } // namespace gnash
 
 #endif

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2010-01-18 07:13:09 +0000
+++ b/libcore/MovieClip.cpp     2010-01-18 14:43:24 +0000
@@ -401,7 +401,7 @@
     stage().remove_key_listener(this);
     stage().remove_mouse_listener(this);
 
-    deleteAllChecked(_loadVariableRequests);
+    deleteChecked(_loadVariableRequests.begin(), _loadVariableRequests.end());
 }
 
 int

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2010-01-11 12:38:41 +0000
+++ b/libcore/as_object.cpp     2010-01-18 15:05:31 +0000
@@ -641,11 +641,6 @@
     // TODO: in this case, return the underlying value !
     as_value curVal = prop ? prop->getCache() : as_value(); 
 
-    log_debug("Existing property %s is being watched: "
-            "firing trigger on update (current val:%s, "
-            "new val:%s)",
-            getStringTable(*this).value(getName(uri)), curVal, val);
-
     as_value newVal = trig.call(curVal, val, *this);
     
     // This is a particularly clear and concise way of removing dead triggers.
@@ -656,12 +651,8 @@
     // so we check for its existence again, and do NOT put
     // it back in if it was deleted
     prop = findUpdatableProperty(uri);
-    if (!prop) {
-        log_debug("Property %s deleted by trigger on update",
-                getStringTable(*this).value(getName(uri)));
-        // Return true?
-        return;
-    }
+    if (!prop) return;
+
     prop->setValue(*this, newVal); 
     prop->clearVisible(getSWFVersion(*this));
     

=== modified file 'libcore/asobj/flash/net/NetConnection_as.cpp'
--- a/libcore/asobj/flash/net/NetConnection_as.cpp      2010-01-11 06:41:38 
+0000
+++ b/libcore/asobj/flash/net/NetConnection_as.cpp      2010-01-18 14:43:24 
+0000
@@ -681,7 +681,7 @@
 // here to have HTTPRemotingHandler definition available
 NetConnection_as::~NetConnection_as()
 {
-    deleteAllChecked(_queuedConnections);
+    deleteChecked(_queuedConnections.begin(), _queuedConnections.end());
 }
 
 // extern (used by Global.cpp)

=== modified file 'libcore/asobj/flash/net/NetStream_as.cpp'
--- a/libcore/asobj/flash/net/NetStream_as.cpp  2010-01-11 06:41:38 +0000
+++ b/libcore/asobj/flash/net/NetStream_as.cpp  2010-01-18 14:43:24 +0000
@@ -1622,7 +1622,7 @@
 {
     boost::mutex::scoped_lock lock(_audioQueueMutex);
 
-    deleteAllChecked(_audioQueue);
+    deleteChecked(_audioQueue.begin(), _audioQueue.end());
 
     _audioQueue.clear();
 }

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2010-01-18 09:07:48 +0000
+++ b/libcore/movie_root.cpp    2010-01-18 15:16:10 +0000
@@ -92,54 +92,54 @@
 inline bool
 movie_root::testInvariant() const
 {
-       // TODO: fill this function !
-       // The _movies map can not invariantably
-       // be non-empty as the stage is autonomous
-       // itself
-       //assert( ! _movies.empty() );
+    // TODO: fill this function !
+    // The _movies map can not invariantably
+    // be non-empty as the stage is autonomous
+    // itself
+    //assert( ! _movies.empty() );
 
-       return true;
+    return true;
 }
 
 
 movie_root::movie_root(const movie_definition& def,
         VirtualClock& clock, const RunResources& runResources)
-       :
+    :
     _runResources(runResources),
     _originalURL(def.get_url()),
     _vm(VM::init(def.get_version(), *this, clock)),
-       _interfaceHandler(0),
-       _fsCommandHandler(0),
-       m_viewport_x0(0),
-       m_viewport_y0(0),
-       m_viewport_width(1),
-       m_viewport_height(1),
-       m_background_color(255, 255, 255, 255),
+    _interfaceHandler(0),
+    _fsCommandHandler(0),
+    m_viewport_x0(0),
+    m_viewport_y0(0),
+    m_viewport_width(1),
+    m_viewport_height(1),
+    m_background_color(255, 255, 255, 255),
     m_background_color_set(false),
-       m_timer(0.0f),
-       m_mouse_x(0),
-       m_mouse_y(0),
-       m_mouse_buttons(0),
-       _lastTimerId(0),
-       _lastKeyEvent(key::INVALID),
-       _currentFocus(0),
-       m_drag_state(),
-       _movies(),
-       _rootMovie(0),
-       _invalidated(true),
-       _disableScripts(false),
-       _processingActionLevel(movie_root::apSIZE),
-       _hostfd(-1),
+    m_timer(0.0f),
+    m_mouse_x(0),
+    m_mouse_y(0),
+    m_mouse_buttons(0),
+    _lastTimerId(0),
+    _lastKeyEvent(key::INVALID),
+    _currentFocus(0),
+    m_drag_state(),
+    _movies(),
+    _rootMovie(0),
+    _invalidated(true),
+    _disableScripts(false),
+    _processingActionLevel(movie_root::apSIZE),
+    _hostfd(-1),
     _quality(QUALITY_HIGH),
-       _alignMode(0),
-       _showMenu(true),
-       _scaleMode(showAll),
-       _displayState(DISPLAYSTATE_NORMAL),
-       _recursionLimit(256),
-       _timeoutLimit(15),
-       _movieAdvancementDelay(83), // ~12 fps by default
-       _lastMovieAdvancement(0),
-       _unnamedInstance(0),
+    _alignMode(0),
+    _showMenu(true),
+    _scaleMode(showAll),
+    _displayState(DISPLAYSTATE_NORMAL),
+    _recursionLimit(256),
+    _timeoutLimit(15),
+    _movieAdvancementDelay(83), // ~12 fps by default
+    _lastMovieAdvancement(0),
+    _unnamedInstance(0),
     _movieLoader(*this)
 {
     // This takes care of informing the renderer (if present) too.
@@ -149,12 +149,12 @@
 void
 movie_root::disableScripts()
 {
-       _disableScripts = true;
+    _disableScripts = true;
 
-       // NOTE: we won't clear the action queue now
-       // to avoid invalidating iterators as we've
-       // been probably called during processing
-       // of the queue.
+    // NOTE: we won't clear the action queue now
+    // to avoid invalidating iterators as we've
+    // been probably called during processing
+    // of the queue.
 }
 
     
@@ -171,30 +171,25 @@
     {
         ActionQueue& q = _actionQueue[lvl];
 
-        deleteAllChecked(q);
-           q.clear();
+        deleteChecked(q.begin(), q.end());
+        q.clear();
     }
 }
 
 void
 movie_root::clearIntervalTimers()
 {
-       for (TimerMap::iterator it=_intervalTimers.begin(),
-                       itE=_intervalTimers.end();
-                       it != itE; ++it)
-       {
-               delete it->second;
-       }
-       _intervalTimers.clear();
+    deleteSecondElements(_intervalTimers.begin(), _intervalTimers.end());
+    _intervalTimers.clear();
 }
 
 movie_root::~movie_root()
 {
-       clearActionQueue();
-       clearIntervalTimers();
-       _movieLoader.clear();
+    clearActionQueue();
+    clearIntervalTimers();
+    _movieLoader.clear();
 
-       assert(testInvariant());
+    assert(testInvariant());
 }
 
 Movie*
@@ -209,116 +204,116 @@
 void
 movie_root::setRootMovie(Movie* movie)
 {
-       _rootMovie = movie;
-
-       m_viewport_x0 = 0;
-       m_viewport_y0 = 0;
-       const movie_definition* md = movie->definition();
-       float fps = md->get_frame_rate();
-       _movieAdvancementDelay = static_cast<int>(1000/fps);
-
-       _lastMovieAdvancement = _vm.getTime();
-
-       m_viewport_width = static_cast<int>(md->get_width_pixels());
-       m_viewport_height = static_cast<int>(md->get_height_pixels());
-
-       // assert(movie->get_depth() == 0); ?
-       movie->set_depth(DisplayObject::staticDepthOffset);
-
-       try
-       {
-               setLevel(0, movie);
-
-               // actions in first frame of _level0 must execute now,
+    _rootMovie = movie;
+
+    m_viewport_x0 = 0;
+    m_viewport_y0 = 0;
+    const movie_definition* md = movie->definition();
+    float fps = md->get_frame_rate();
+    _movieAdvancementDelay = static_cast<int>(1000/fps);
+
+    _lastMovieAdvancement = _vm.getTime();
+
+    m_viewport_width = static_cast<int>(md->get_width_pixels());
+    m_viewport_height = static_cast<int>(md->get_height_pixels());
+
+    // assert(movie->get_depth() == 0); ?
+    movie->set_depth(DisplayObject::staticDepthOffset);
+
+    try
+    {
+        setLevel(0, movie);
+
+        // actions in first frame of _level0 must execute now,
         // before next advance,
-               // or they'll be executed with _currentframe being set to 2
-               processActionQueue();
-       }
-       catch (ActionLimitException& al)
-       {
-               boost::format fmt = boost::format(_("ActionLimits hit during "
+        // or they'll be executed with _currentframe being set to 2
+        processActionQueue();
+    }
+    catch (ActionLimitException& al)
+    {
+        boost::format fmt = boost::format(_("ActionLimits hit during "
                     "setRootMovie: %s. Disable scripts?")) % al.what();
-               handleActionLimitHit(fmt.str());
-       }
+        handleActionLimitHit(fmt.str());
+    }
     catch (ActionParserException& e)
     {
         log_error("ActionParserException thrown during setRootMovie: %s",
                 e.what());
     }
 
-       cleanupAndCollect();
+    cleanupAndCollect();
 }
 
 /*private*/
 void
 movie_root::handleActionLimitHit(const std::string& msg)
 {
-       bool disable = true;
-       if ( _interfaceHandler ) disable = _interfaceHandler->yesNo(msg);
-       else log_error("No user interface registered, assuming 'Yes' answer to "
+    bool disable = true;
+    if ( _interfaceHandler ) disable = _interfaceHandler->yesNo(msg);
+    else log_error("No user interface registered, assuming 'Yes' answer to "
             "question: %s", msg);
-       if ( disable )
-       {
-               disableScripts();
-               clearActionQueue();
-       }
+    if ( disable )
+    {
+        disableScripts();
+        clearActionQueue();
+    }
 }
 
 void
 movie_root::cleanupAndCollect()
 {
-       // Cleanup the stack.
-       _vm.getStack().clear();
+    // Cleanup the stack.
+    _vm.getStack().clear();
 
-       cleanupUnloadedListeners();
-       cleanupDisplayList();
-       GC::get().fuzzyCollect();
+    cleanupUnloadedListeners();
+    cleanupDisplayList();
+    GC::get().fuzzyCollect();
 }
 
 /* private */
 void
 movie_root::setLevel(unsigned int num, Movie* movie)
 {
-       assert(movie != NULL);
-       assert(static_cast<unsigned int>(movie->get_depth()) ==
-                               num + DisplayObject::staticDepthOffset);
-
-
-       Levels::iterator it = _movies.find(movie->get_depth());
-       if ( it == _movies.end() )
-       {
-               _movies[movie->get_depth()] = movie; 
-       }
-       else
-    {
-               // don't leak overloaded levels
-
-               LevelMovie lm = it->second;
-               if (lm == _rootMovie)
-               {
-                       // NOTE: this is not enough to trigger
-                       //       an application reset. Was tested
-                       //       but not automated. If curious
-                       //       use swapDepths against _level0
-                       //       and load into the new target while
-                       //       a timeout/interval is active.
-                       log_debug("Replacing starting movie");
-               }
-
-               if ( num == 0 )
-               {
-                       log_debug("Loading into _level0");
-
-                       // NOTE: this was tested but not automated, the
-                       //       test sets an interval and then loads something
-                       //       in _level0. The result is the interval is 
disabled.
-                       clearIntervalTimers();
-
-
-                       // TODO: check what else we should do in these cases 
-                       //       (like, unregistering all childs etc...)
-                       //       Tested, but not automated, is that other
-                       //       levels should be maintained alive.
+    assert(movie != NULL);
+    assert(static_cast<unsigned int>(movie->get_depth()) ==
+                            num + DisplayObject::staticDepthOffset);
+
+
+    Levels::iterator it = _movies.find(movie->get_depth());
+    if ( it == _movies.end() )
+    {
+        _movies[movie->get_depth()] = movie; 
+    }
+    else
+    {
+        // don't leak overloaded levels
+
+        LevelMovie lm = it->second;
+        if (lm == _rootMovie)
+        {
+            // NOTE: this is not enough to trigger
+            //       an application reset. Was tested
+            //       but not automated. If curious
+            //       use swapDepths against _level0
+            //       and load into the new target while
+            //       a timeout/interval is active.
+            log_debug("Replacing starting movie");
+        }
+
+        if ( num == 0 )
+        {
+            log_debug("Loading into _level0");
+
+            // NOTE: this was tested but not automated, the
+            //       test sets an interval and then loads something
+            //       in _level0. The result is the interval is disabled.
+            clearIntervalTimers();
+
+
+            // TODO: check what else we should do in these cases 
+            //       (like, unregistering all childs etc...)
+            //       Tested, but not automated, is that other
+            //       levels should be maintained alive.
             // Sat Nov 14 10:31:19 CET 2009
             // ^^^ not confirmed in this date, I think other levels 
             //     are dropped too! (strk)
@@ -333,143 +328,143 @@
                 ss << m_viewport_width << "x" << m_viewport_height;
                 _interfaceHandler->call("Stage.resize", ss.str());
             }
-               }
-
-               it->second->destroy();
-               it->second = movie;
-       }
-
-       movie->set_invalidated();
-       
-       /// Notify placement 
-       movie->stagePlacementCallback();
-
-       assert(testInvariant());
+        }
+
+        it->second->destroy();
+        it->second = movie;
+    }
+
+    movie->set_invalidated();
+    
+    /// Notify placement 
+    movie->stagePlacementCallback();
+
+    assert(testInvariant());
 }
 
 void
 movie_root::swapLevels(MovieClip* movie, int depth)
 {
-       assert(movie);
+    assert(movie);
 
 //#define GNASH_DEBUG_LEVELS_SWAPPING 1
 
-       int oldDepth = movie->get_depth();
+    int oldDepth = movie->get_depth();
 
 #ifdef GNASH_DEBUG_LEVELS_SWAPPING
-       log_debug("Before swapLevels (source depth %d, target depth %d) "
+    log_debug("Before swapLevels (source depth %d, target depth %d) "
             "levels are: ", oldDepth, depth);
-       for (Levels::const_iterator i=_movies.begin(), e=_movies.end(); i!=e; 
++i)
-       {
-               log_debug(" %d: %p (%s @ depth %d)", i->first,
+    for (Levels::const_iterator i=_movies.begin(), e=_movies.end(); i!=e; ++i)
+    {
+        log_debug(" %d: %p (%s @ depth %d)", i->first,
                 (void*)(i->second), i->second->getTarget(),
                 i->second->get_depth());
-       }
+    }
 #endif
 
-       if ( oldDepth < DisplayObject::staticDepthOffset ) // should include 
_level0 !
-       {
-               IF_VERBOSE_ASCODING_ERRORS(
-               log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below "
-                "static depth zone (%d), won't swap its depth"),
-                movie->getTarget(), depth, oldDepth,
-                DisplayObject::staticDepthOffset);
-               );
-               return;
-       }
-
-       if ( oldDepth >= 0 ) 
-       {
-               IF_VERBOSE_ASCODING_ERRORS(
-               log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below "
-                "static depth zone (%d), won't swap its depth"),
-                movie->getTarget(), depth, oldDepth,
-                DisplayObject::staticDepthOffset);
-               );
-               return;
-       }
-
-       int oldNum = oldDepth; // -DisplayObject::staticDepthOffset;
-       Levels::iterator oldIt = _movies.find(oldNum);
-       if ( oldIt == _movies.end() )
-       {
-               log_debug("%s.swapDepth(%d): target depth (%d) contains no 
movie",
-                       movie->getTarget(), depth, oldNum);
-               return;
-       }
-
-       int newNum = depth; // -DisplayObject::staticDepthOffset;
-       movie->set_depth(depth);
-       Levels::iterator targetIt = _movies.find(newNum);
-       if ( targetIt == _movies.end() )
-       {
-               _movies.erase(oldIt);
-               _movies[newNum] = movie;
-       }
-       else
-       {
-               MovieClip* otherMovie = targetIt->second;
-               otherMovie->set_depth(oldDepth);
-               oldIt->second = otherMovie;
-               targetIt->second = movie;
-       }
-       
+    if ( oldDepth < DisplayObject::staticDepthOffset ) // should include 
_level0 !
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below "
+                "static depth zone (%d), won't swap its depth"),
+                movie->getTarget(), depth, oldDepth,
+                DisplayObject::staticDepthOffset);
+        );
+        return;
+    }
+
+    if ( oldDepth >= 0 ) 
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below "
+                "static depth zone (%d), won't swap its depth"),
+                movie->getTarget(), depth, oldDepth,
+                DisplayObject::staticDepthOffset);
+        );
+        return;
+    }
+
+    int oldNum = oldDepth; // -DisplayObject::staticDepthOffset;
+    Levels::iterator oldIt = _movies.find(oldNum);
+    if ( oldIt == _movies.end() )
+    {
+        log_debug("%s.swapDepth(%d): target depth (%d) contains no movie",
+            movie->getTarget(), depth, oldNum);
+        return;
+    }
+
+    int newNum = depth; // -DisplayObject::staticDepthOffset;
+    movie->set_depth(depth);
+    Levels::iterator targetIt = _movies.find(newNum);
+    if ( targetIt == _movies.end() )
+    {
+        _movies.erase(oldIt);
+        _movies[newNum] = movie;
+    }
+    else
+    {
+        MovieClip* otherMovie = targetIt->second;
+        otherMovie->set_depth(oldDepth);
+        oldIt->second = otherMovie;
+        targetIt->second = movie;
+    }
+    
 #ifdef GNASH_DEBUG_LEVELS_SWAPPING
-       log_debug("After swapLevels levels are: ");
-       for (Levels::const_iterator i=_movies.begin(), e=_movies.end(); i!=e; 
++i)
-       {
-               log_debug(" %d: %p (%s @ depth %d)", i->first, 
+    log_debug("After swapLevels levels are: ");
+    for (Levels::const_iterator i=_movies.begin(), e=_movies.end(); i!=e; ++i)
+    {
+        log_debug(" %d: %p (%s @ depth %d)", i->first, 
                 (void*)(i->second), i->second->getTarget(),
                 i->second->get_depth());
-       }
+    }
 #endif
-       
-       // TODO: invalidate self, not the movie
+    
+    // TODO: invalidate self, not the movie
     //       movie_root::setInvalidated() seems
     //       to do just that, if anyone feels
     //       like more closely research on this
     //       (does level swapping require full redraw always?)
-       movie->set_invalidated();
-       
-       assert(testInvariant());
+    movie->set_invalidated();
+    
+    assert(testInvariant());
 }
 
 void
 movie_root::dropLevel(int depth)
 {
-       // should be checked by caller
-       assert ( depth >= 0 && depth <= 1048575 );
+    // should be checked by caller
+    assert ( depth >= 0 && depth <= 1048575 );
 
-       Levels::iterator it = _movies.find(depth);
-       if ( it == _movies.end() )
-       {
-               log_error("movie_root::dropLevel called against a movie not "
+    Levels::iterator it = _movies.find(depth);
+    if ( it == _movies.end() )
+    {
+        log_error("movie_root::dropLevel called against a movie not "
                 "found in the levels container");
-               return;
-       }
-
-       MovieClip* mo = it->second;
-       if (mo == _rootMovie)
-       {
-               IF_VERBOSE_ASCODING_ERRORS(
-               log_aserror(_("Original root movie can't be removed"));
-               );
-               return;
-       }
-
-       // TOCHECK: safe to erase here ?
-       mo->unload();
-       mo->destroy();
-       _movies.erase(it);
-
-       assert(testInvariant());
+        return;
+    }
+
+    MovieClip* mo = it->second;
+    if (mo == _rootMovie)
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("Original root movie can't be removed"));
+        );
+        return;
+    }
+
+    // TOCHECK: safe to erase here ?
+    mo->unload();
+    mo->destroy();
+    _movies.erase(it);
+
+    assert(testInvariant());
 }
 
 void
 movie_root::replaceLevel(unsigned int num, Movie* extern_movie)
 {
-       extern_movie->set_depth(num + DisplayObject::staticDepthOffset);
-       Levels::iterator it = _movies.find(extern_movie->get_depth());
+    extern_movie->set_depth(num + DisplayObject::staticDepthOffset);
+    Levels::iterator it = _movies.find(extern_movie->get_depth());
     if ( it == _movies.end() )
     {
         log_error("TESTME: loadMovie called on level %d which is not available 
at load time, skipped placement for now");
@@ -477,94 +472,94 @@
     }
 
     // TODO: rework this to avoid the double scan 
-       setLevel(num, extern_movie);
+    setLevel(num, extern_movie);
 }
 
 MovieClip*
 movie_root::getLevel(unsigned int num) const
 {
-       Levels::const_iterator i =
+    Levels::const_iterator i =
         _movies.find(num + DisplayObject::staticDepthOffset);
 
-       if (i == _movies.end()) return 0;
+    if (i == _movies.end()) return 0;
 
-       return i->second;
+    return i->second;
 }
 
 void
 movie_root::reset()
 {
-       sound::sound_handler* sh = _runResources.soundHandler();
-       if ( sh ) sh->reset();
-       clear();
-       _disableScripts = false;
+    sound::sound_handler* sh = _runResources.soundHandler();
+    if ( sh ) sh->reset();
+    clear();
+    _disableScripts = false;
 }
 
 void
 movie_root::clear()
 {
-       // reset background color, to allow 
-       // next load to set it again.
-       m_background_color.set(255,255,255,255);
-       m_background_color_set = false;
-
-       // wipe out live chars
-       _liveChars.clear();
-
-       // wipe out queued actions
-       clearActionQueue();
-
-       // wipe out all levels
-       _movies.clear();
-
-       // remove all intervals
-       clearIntervalTimers();
+    // reset background color, to allow 
+    // next load to set it again.
+    m_background_color.set(255,255,255,255);
+    m_background_color_set = false;
+
+    // wipe out live chars
+    _liveChars.clear();
+
+    // wipe out queued actions
+    clearActionQueue();
+
+    // wipe out all levels
+    _movies.clear();
+
+    // remove all intervals
+    clearIntervalTimers();
 
     // remove all loadMovie requests
-       _movieLoader.clear();
-
-       // remove key/mouse listeners
-       _keyListeners.clear();
-       _mouseListeners.clear();
-
-       // Cleanup the stack.
-       _vm.getStack().clear();
+    _movieLoader.clear();
+
+    // remove key/mouse listeners
+    _keyListeners.clear();
+    _mouseListeners.clear();
+
+    // Cleanup the stack.
+    _vm.getStack().clear();
 
 #ifdef GNASH_USE_GC
-       // Run the garbage collector again
-       GC::get().fuzzyCollect();
+    // Run the garbage collector again
+    GC::get().fuzzyCollect();
 #endif
 
-       setInvalidated();
+    setInvalidated();
 }
 
 void
 movie_root::set_display_viewport(int x0, int y0, int w, int h)
 {
-       assert(testInvariant());
-
-       m_viewport_x0 = x0;
-       m_viewport_y0 = y0;
-       m_viewport_width = w;
-       m_viewport_height = h;
-
-       if (_scaleMode == noScale) {
-               //log_debug("Rescaling disabled");
-               as_object* stage = getBuiltinObject(*this, NSV::PROP_iSTAGE);
-               if (stage) {
+    assert(testInvariant());
+
+    m_viewport_x0 = x0;
+    m_viewport_y0 = y0;
+    m_viewport_width = w;
+    m_viewport_height = h;
+
+    if (_scaleMode == noScale) {
+        //log_debug("Rescaling disabled");
+        as_object* stage = getBuiltinObject(*this, NSV::PROP_iSTAGE);
+        if (stage) {
             log_debug("notifying Stage listeners about a resize");
             callMethod(stage, NSV::PROP_BROADCAST_MESSAGE, "onResize");
         }
 
-       }
+    }
 
-       assert(testInvariant());
+    assert(testInvariant());
 }
 
 bool
 movie_root::notify_mouse_moved(int x, int y)
 {
-       assert(testInvariant());
+    assert(testInvariant());
 
     m_mouse_x = x;
     m_mouse_y = y;
@@ -583,67 +578,67 @@
         _unreleasedKeys.set(keycode, down);
     }
 
-       // Notify DisplayObject key listeners for clip key events
-       notify_key_listeners(k, down);
+    // Notify DisplayObject key listeners for clip key events
+    notify_key_listeners(k, down);
 
-       // Notify both DisplayObject and non-DisplayObject Key listeners
-       //      for user defined handers.
+    // Notify both DisplayObject and non-DisplayObject Key listeners
+    //    for user defined handers.
     as_object* key = getBuiltinObject(*this, NSV::CLASS_KEY);
-       if (key) {
+    if (key) {
 
-           try {
-               // Can throw an action limit exception if the stack limit is 0 
or 1,
-               // i.e. if the stack is at the limit before it contains 
anything.
+        try {
+            // Can throw an action limit exception if the stack limit is 0 or 
1,
+            // i.e. if the stack is at the limit before it contains anything.
             // A stack limit like that is hardly of any use, but could be used
             // maliciously to crash Gnash.
-                   if (down) {
+            if (down) {
                 callMethod(key, NSV::PROP_BROADCAST_MESSAGE, "onKeyDown");
-                   }
-                   else {
+            }
+            else {
                 callMethod(key, NSV::PROP_BROADCAST_MESSAGE, "onKeyUp");
-               }
-           }
-           catch (ActionLimitException &e)
-           {
+            }
+        }
+        catch (ActionLimitException &e)
+        {
             log_error(_("ActionLimits hit notifying key listeners: %s."),
                     e.what());
             clearActionQueue();
-           }
-       }
-
-       processActionQueue();
-
-       return false; // should return true if needs update ...
+        }
+    }
+
+    processActionQueue();
+
+    return false; // should return true if needs update ...
 }
 
 
 bool
 movie_root::notify_mouse_clicked(bool mouse_pressed, int button_mask)
 {
-       assert(testInvariant());
-
-       //log_debug("Mouse click notification");
-       if (mouse_pressed)
-       {
-               m_mouse_buttons |= button_mask;
-               notify_mouse_listeners(event_id(event_id::MOUSE_DOWN));
-       }
-       else
-       {
-               m_mouse_buttons &= ~button_mask;
-               notify_mouse_listeners(event_id(event_id::MOUSE_UP));
-       }
-
-       return fire_mouse_event();
+    assert(testInvariant());
+
+    //log_debug("Mouse click notification");
+    if (mouse_pressed)
+    {
+        m_mouse_buttons |= button_mask;
+        notify_mouse_listeners(event_id(event_id::MOUSE_DOWN));
+    }
+    else
+    {
+        m_mouse_buttons &= ~button_mask;
+        notify_mouse_listeners(event_id(event_id::MOUSE_UP));
+    }
+
+    return fire_mouse_event();
 }
 
 
 bool
 movie_root::fire_mouse_event()
 {
-//     GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
 
-       assert(testInvariant());
+    assert(testInvariant());
 
     boost::int32_t x = pixelsToTwips(m_mouse_x);
     boost::int32_t y = pixelsToTwips(m_mouse_y);
@@ -696,130 +691,130 @@
         boost::int32_t& buttons)
 {
 
-       assert(testInvariant());
-
-       x = m_mouse_x;
-       y = m_mouse_y;
-       buttons = m_mouse_buttons;
-
-       assert(testInvariant());
+    assert(testInvariant());
+
+    x = m_mouse_x;
+    y = m_mouse_y;
+    buttons = m_mouse_buttons;
+
+    assert(testInvariant());
 }
 
 void
 movie_root::get_drag_state(drag_state& st)
 {
-       assert(testInvariant());
-
-       st = m_drag_state;
-
-       assert(testInvariant());
+    assert(testInvariant());
+
+    st = m_drag_state;
+
+    assert(testInvariant());
 }
 
 void
 movie_root::set_drag_state(const drag_state& st)
 {
-       m_drag_state = st;
-       DisplayObject* ch = st.getCharacter();
-       if ( ch && ! st.isLockCentered() )
-       {
-               // Get coordinates of the DisplayObject's origin
-               point origin(0, 0);
-               SWFMatrix chmat = ch->getWorldMatrix();
-               point world_origin;
-               chmat.transform(&world_origin, origin);
-
-               // Get current mouse coordinates
-               boost::int32_t x, y, buttons;
-               get_mouse_state(x, y, buttons);
-               point world_mouse(pixelsToTwips(x), pixelsToTwips(y));
-
-               boost::int32_t xoffset = world_mouse.x - world_origin.x;
-               boost::int32_t yoffset = world_mouse.y - world_origin.y;
-
-               m_drag_state.setOffset(xoffset, yoffset);
-       }
-       assert(testInvariant());
+    m_drag_state = st;
+    DisplayObject* ch = st.getCharacter();
+    if ( ch && ! st.isLockCentered() )
+    {
+        // Get coordinates of the DisplayObject's origin
+        point origin(0, 0);
+        SWFMatrix chmat = ch->getWorldMatrix();
+        point world_origin;
+        chmat.transform(&world_origin, origin);
+
+        // Get current mouse coordinates
+        boost::int32_t x, y, buttons;
+        get_mouse_state(x, y, buttons);
+        point world_mouse(pixelsToTwips(x), pixelsToTwips(y));
+
+        boost::int32_t xoffset = world_mouse.x - world_origin.x;
+        boost::int32_t yoffset = world_mouse.y - world_origin.y;
+
+        m_drag_state.setOffset(xoffset, yoffset);
+    }
+    assert(testInvariant());
 }
 
 void
 movie_root::doMouseDrag()
 {
-       DisplayObject* dragChar = getDraggingCharacter(); 
-       if ( ! dragChar ) return; // nothing to do
-
-       if ( dragChar->unloaded() )
-       {
-               // Reset drag state if dragging char was unloaded
-               m_drag_state.reset();
-               return; 
-       }
-
-       boost::int32_t x, y, buttons;
-       get_mouse_state(x, y, buttons);
-
-       point world_mouse(pixelsToTwips(x), pixelsToTwips(y));
-
-       SWFMatrix       parent_world_mat;
-       DisplayObject* parent = dragChar->get_parent();
-       if (parent != NULL)
-       {
-           parent_world_mat = parent->getWorldMatrix();
-       }
-
-       if (! m_drag_state.isLockCentered())
-       {
-               world_mouse.x -= m_drag_state.xOffset();
-               world_mouse.y -= m_drag_state.yOffset();
-       }
-
-       if ( m_drag_state.hasBounds() )
-       {
-               SWFRect bounds;
-               // bounds are in local coordinate space
-               bounds.enclose_transformed_rect(parent_world_mat, 
m_drag_state.getBounds());
-               // Clamp mouse coords within a defined SWFRect.
-               bounds.clamp(world_mouse);
-       }
-
-    parent_world_mat.invert().transform(world_mouse);                  
-       // Place our origin so that it coincides with the mouse coords
-       // in our parent frame.
-       // TODO: add a DisplayObject::set_translation ?
-       SWFMatrix       local = dragChar->getMatrix();
-       local.set_translation(world_mouse.x, world_mouse.y);
-       dragChar->setMatrix(local); //no need to update caches when only 
changing translation
+    DisplayObject* dragChar = getDraggingCharacter(); 
+    if ( ! dragChar ) return; // nothing to do
+
+    if ( dragChar->unloaded() )
+    {
+        // Reset drag state if dragging char was unloaded
+        m_drag_state.reset();
+        return; 
+    }
+
+    boost::int32_t x, y, buttons;
+    get_mouse_state(x, y, buttons);
+
+    point world_mouse(pixelsToTwips(x), pixelsToTwips(y));
+
+    SWFMatrix    parent_world_mat;
+    DisplayObject* parent = dragChar->get_parent();
+    if (parent != NULL)
+    {
+        parent_world_mat = parent->getWorldMatrix();
+    }
+
+    if (! m_drag_state.isLockCentered())
+    {
+        world_mouse.x -= m_drag_state.xOffset();
+        world_mouse.y -= m_drag_state.yOffset();
+    }
+
+    if ( m_drag_state.hasBounds() )
+    {
+        SWFRect bounds;
+        // bounds are in local coordinate space
+        bounds.enclose_transformed_rect(parent_world_mat, 
m_drag_state.getBounds());
+        // Clamp mouse coords within a defined SWFRect.
+        bounds.clamp(world_mouse);
+    }
+
+    parent_world_mat.invert().transform(world_mouse);            
+    // Place our origin so that it coincides with the mouse coords
+    // in our parent frame.
+    // TODO: add a DisplayObject::set_translation ?
+    SWFMatrix    local = dragChar->getMatrix();
+    local.set_translation(world_mouse.x, world_mouse.y);
+    dragChar->setMatrix(local); //no need to update caches when only changing 
translation
 }
 
 
 unsigned int
 movie_root::add_interval_timer(std::auto_ptr<Timer> timer)
 {
-       assert(timer.get());
-       assert(testInvariant());
-                       
-       int id = ++_lastTimerId;
+    assert(timer.get());
+    assert(testInvariant());
+            
+    int id = ++_lastTimerId;
 
-       assert(_intervalTimers.find(id) == _intervalTimers.end());
-       _intervalTimers[id] = timer.release(); 
-       return id;
+    assert(_intervalTimers.find(id) == _intervalTimers.end());
+    _intervalTimers[id] = timer.release(); 
+    return id;
 }
-       
+    
 bool
 movie_root::clear_interval_timer(unsigned int x)
 {
-       TimerMap::iterator it = _intervalTimers.find(x);
-       if ( it == _intervalTimers.end() ) return false;
-
-       // We do not remove the element here because
-       // we might have been called during execution
-       // of another timer, thus during a scan of the _intervalTimers
-       // container. If we use erase() here, the iterators in executeTimers
-       // would be invalidated. Rather, executeTimers() would check container
-       // elements for being still active and remove the cleared one in a safe 
way
-       // at each iteration.
-       it->second->clearInterval();
-
-       return true;
+    TimerMap::iterator it = _intervalTimers.find(x);
+    if ( it == _intervalTimers.end() ) return false;
+
+    // We do not remove the element here because
+    // we might have been called during execution
+    // of another timer, thus during a scan of the _intervalTimers
+    // container. If we use erase() here, the iterators in executeTimers
+    // would be invalidated. Rather, executeTimers() would check container
+    // elements for being still active and remove the cleared one in a safe way
+    // at each iteration.
+    it->second->clearInterval();
+
+    return true;
 
 }
 
@@ -829,19 +824,19 @@
     // We can't actually rely on now being later than _lastMovieAdvancement,
     // so we will have to check. Otherwise we risk elapsed being
     // contructed from a negative value.
-       const size_t now = std::max<size_t>(_vm.getTime(), 
_lastMovieAdvancement);
+    const size_t now = std::max<size_t>(_vm.getTime(), _lastMovieAdvancement);
 
     bool advanced = false;
 
     try {
 
         const size_t elapsed = now - _lastMovieAdvancement;
-           if (elapsed >= _movieAdvancementDelay)
-           {
+        if (elapsed >= _movieAdvancementDelay)
+        {
             advanced = true;
-                   advanceMovie();
+            advanceMovie();
 
-                   // To catch-up lateness we pretend we advanced when 
+            // To catch-up lateness we pretend we advanced when 
             // was time for it. 
             // NOTE:
             //   now - _lastMovieAdvancement
@@ -849,20 +844,20 @@
             //
             _lastMovieAdvancement += _movieAdvancementDelay;
 
-           }
+        }
 
         //log_debug("Latenss: %d", now-_lastMovieAdvancement);
         
         executeAdvanceCallbacks();
-           
-           executeTimers();
-       
-       }
-       catch (ActionLimitException& al) {
+        
+        executeTimers();
+    
+    }
+    catch (ActionLimitException& al) {
         // The PP does not disable scripts when the stack limit is reached,
         // but rather struggles on. 
-           log_error(_("Action limit hit during advance: %s"), al.what());
-           clearActionQueue();
+        log_error(_("Action limit hit during advance: %s"), al.what());
+        clearActionQueue();
     }
     catch (ActionParserException& e) {
         log_error(_("Buffer overread during advance: %s"), e.what());
@@ -871,23 +866,23 @@
 
     return advanced;
 }
-       
+    
 void
 movie_root::advanceMovie()
 {
 
-       // Do mouse drag, if needed
-       doMouseDrag();
+    // Do mouse drag, if needed
+    doMouseDrag();
 
     // Advance all non-unloaded DisplayObjects in the LiveChars list
-       // in reverse order (last added, first advanced)
-       // NOTE: can throw ActionLimitException
-       advanceLiveChars(); 
+    // in reverse order (last added, first advanced)
+    // NOTE: can throw ActionLimitException
+    advanceLiveChars(); 
 
     // Process loadMovie requests
     // 
     // NOTE: should be done before executing timers,
-    //          see swfdec's test/trace/loadmovie-case-{5,6}.swf 
+    //      see swfdec's test/trace/loadmovie-case-{5,6}.swf 
     // NOTE: processing loadMovie requests after advanceLiveChars
     //       is known to fix more tests in misc-mtasc.all/levels.swf
     //       to be checked if it keeps the swfdec testsuite safe
@@ -914,55 +909,55 @@
 void
 movie_root::display()
 {
-//     GNASH_REPORT_FUNCTION;
-
-       assert(testInvariant());
-
-       clearInvalidated();
-
-       // TODO: should we consider the union of all levels bounds ?
-       const SWFRect& frame_size = _rootMovie->get_frame_size();
-       if ( frame_size.is_null() )
-       {
-               // TODO: check what we should do if other levels
-               //       have valid bounds
-               log_debug("original root movie had null bounds, not 
displaying");
-               return;
-       }
+//    GNASH_REPORT_FUNCTION;
+
+    assert(testInvariant());
+
+    clearInvalidated();
+
+    // TODO: should we consider the union of all levels bounds ?
+    const SWFRect& frame_size = _rootMovie->get_frame_size();
+    if ( frame_size.is_null() )
+    {
+        // TODO: check what we should do if other levels
+        //       have valid bounds
+        log_debug("original root movie had null bounds, not displaying");
+        return;
+    }
 
     Renderer* renderer = _runResources.renderer();
     if (!renderer) return;
 
-       renderer->begin_display(
-               m_background_color,
-               m_viewport_x0, m_viewport_y0,
-               m_viewport_width, m_viewport_height,
-               frame_size.get_x_min(), frame_size.get_x_max(),
-               frame_size.get_y_min(), frame_size.get_y_max());
-
-
-       for (Levels::iterator i=_movies.begin(), e=_movies.end(); i!=e; ++i)
-       {
-               MovieClip* movie = i->second;
-
-               movie->clear_invalidated();
-
-               if (movie->visible() == false) continue;
-
-               // null frame size ? don't display !
-               const SWFRect& sub_frame_size = movie->get_frame_size();
-
-               if ( sub_frame_size.is_null() )
-               {
-                       log_debug("_level%u has null frame size, skipping", 
i->first);
-                       continue;
-               }
-
-               movie->display(*renderer);
-
-       }
-
-       renderer->end_display();
+    renderer->begin_display(
+        m_background_color,
+        m_viewport_x0, m_viewport_y0,
+        m_viewport_width, m_viewport_height,
+        frame_size.get_x_min(), frame_size.get_x_max(),
+        frame_size.get_y_min(), frame_size.get_y_max());
+
+
+    for (Levels::iterator i=_movies.begin(), e=_movies.end(); i!=e; ++i)
+    {
+        MovieClip* movie = i->second;
+
+        movie->clear_invalidated();
+
+        if (movie->visible() == false) continue;
+
+        // null frame size ? don't display !
+        const SWFRect& sub_frame_size = movie->get_frame_size();
+
+        if ( sub_frame_size.is_null() )
+        {
+            log_debug("_level%u has null frame size, skipping", i->first);
+            continue;
+        }
+
+        movie->display(*renderer);
+
+    }
+
+    renderer->end_display();
 }
 
 
@@ -1019,98 +1014,98 @@
 movie_root::notify_key_listeners(key::code k, bool down)
 {
 
-       Listeners copy = _keyListeners;
-       for (Listeners::iterator iter = copy.begin(), itEnd=copy.end();
-                       iter != itEnd; ++iter)
-       {
-               // sprite, button & input_edit_text DisplayObjects
-               DisplayObject* const ch = *iter;
-               if (!ch->unloaded()) {
-                       if (down) {
-                               // KEY_UP and KEY_DOWN events are unrelated to 
any key!
-                               ch->notifyEvent(event_id(event_id::KEY_DOWN, 
key::INVALID)); 
-                               // Pass the unique Gnash key code!
-                               ch->notifyEvent(event_id(event_id::KEY_PRESS, 
k));
-                       }
-                       else {
-                               ch->notifyEvent(event_id(event_id::KEY_UP, 
key::INVALID));   
-                       }
-               }
-       }
+    Listeners copy = _keyListeners;
+    for (Listeners::iterator iter = copy.begin(), itEnd=copy.end();
+            iter != itEnd; ++iter)
+    {
+        // sprite, button & input_edit_text DisplayObjects
+        DisplayObject* const ch = *iter;
+        if (!ch->unloaded()) {
+            if (down) {
+                // KEY_UP and KEY_DOWN events are unrelated to any key!
+                ch->notifyEvent(event_id(event_id::KEY_DOWN, key::INVALID)); 
+                // Pass the unique Gnash key code!
+                ch->notifyEvent(event_id(event_id::KEY_PRESS, k));
+            }
+            else {
+                ch->notifyEvent(event_id(event_id::KEY_UP, key::INVALID));   
+            }
+        }
+    }
 
     assert(testInvariant());
 
     if (!copy.empty()) {
-               // process actions queued in the above step
-               processActionQueue();
-       }
+        // process actions queued in the above step
+        processActionQueue();
+    }
 }
 
 void
 movie_root::add_listener(Listeners& ll, DisplayObject* listener)
 {
-       assert(listener);
+    assert(listener);
 
     // Don't add the same listener twice (why not use a set?)
     if (std::find(ll.begin(), ll.end(), listener) != ll.end()) return;
 
-       ll.push_front(listener);
+    ll.push_front(listener);
 }
 
 
 void
 movie_root::remove_listener(Listeners& ll, DisplayObject* listener)
 {
-       assert(listener);
-       ll.remove_if(std::bind2nd(std::equal_to<DisplayObject*>(), listener));
+    assert(listener);
+    ll.remove_if(std::bind2nd(std::equal_to<DisplayObject*>(), listener));
 }
 
 void
 movie_root::notify_mouse_listeners(const event_id& event)
 {
 
-       Listeners copy = _mouseListeners;
-       for (Listeners::iterator iter = copy.begin(), itEnd=copy.end();
-                       iter != itEnd; ++iter)
-       {
-               DisplayObject* const ch = *iter;
-               if (!ch->unloaded())
-               {
-                       ch->notifyEvent(event);
-               }
-       }
+    Listeners copy = _mouseListeners;
+    for (Listeners::iterator iter = copy.begin(), itEnd=copy.end();
+            iter != itEnd; ++iter)
+    {
+        DisplayObject* const ch = *iter;
+        if (!ch->unloaded())
+        {
+            ch->notifyEvent(event);
+        }
+    }
 
-       as_object* mouseObj = getBuiltinObject(*this, NSV::CLASS_MOUSE);
-       if (mouseObj) {
+    as_object* mouseObj = getBuiltinObject(*this, NSV::CLASS_MOUSE);
+    if (mouseObj) {
 
         try {
             // Can throw an action limit exception if the stack limit is 0 or 
1.
             // A stack limit like that is hardly of any use, but could be used
             // maliciously to crash Gnash.
-                   callMethod(mouseObj, NSV::PROP_BROADCAST_MESSAGE, 
+            callMethod(mouseObj, NSV::PROP_BROADCAST_MESSAGE, 
                     event.functionName());
-               }
-           catch (ActionLimitException &e) {
+        }
+        catch (ActionLimitException &e) {
             log_error(_("ActionLimits hit notifying mouse events: %s."),
                     e.what());
             clearActionQueue();
-           }
-           
-       }
+        }
+        
+    }
 
-       assert(testInvariant());
+    assert(testInvariant());
 
     if (!copy.empty()) {
-               // process actions queued in the above step
-               processActionQueue();
-       }
+        // process actions queued in the above step
+        processActionQueue();
+    }
 }
 
 DisplayObject*
 movie_root::getFocus()
 {
-       assert(testInvariant());
-       return _currentFocus;
+    assert(testInvariant());
+    return _currentFocus;
 }
 
 bool
@@ -1163,7 +1158,7 @@
                 getObject(from), getObject(to));
     }
 
-       assert(testInvariant());
+    assert(testInvariant());
 
     return true;
 }
@@ -1171,29 +1166,29 @@
 DisplayObject*
 movie_root::getActiveEntityUnderPointer() const
 {
-       return _mouseButtonState.activeEntity;
+    return _mouseButtonState.activeEntity;
 }
 
 DisplayObject*
 movie_root::getDraggingCharacter() const
 {
-       return m_drag_state.getCharacter();
+    return m_drag_state.getCharacter();
 }
 
 const DisplayObject*
 movie_root::getEntityUnderPointer() const
 {
-       boost::int32_t x = pixelsToTwips(m_mouse_x);
-       boost::int32_t y = pixelsToTwips(m_mouse_y);
+    boost::int32_t x = pixelsToTwips(m_mouse_x);
+    boost::int32_t y = pixelsToTwips(m_mouse_y);
     const DisplayObject* dropChar = findDropTarget(x, y, 
getDraggingCharacter()); 
-       return dropChar;
+    return dropChar;
 }
 
 
 bool
 movie_root::isMouseOverActiveEntity() const
 {
-       assert(testInvariant());
+    assert(testInvariant());
     return (_mouseButtonState.activeEntity);
 }
 
@@ -1289,7 +1284,7 @@
 bool
 movie_root::getShowMenuState() const
 {
-       return _showMenu;
+    return _showMenu;
 }
 
 /// Sets the value of _showMenu and calls the gui handler to process the 
@@ -1297,13 +1292,13 @@
 void
 movie_root::setShowMenuState(bool state)
 {
-       _showMenu = state;
-       //FIXME: The gui code for show menu is semantically different than what
-       //   ActionScript expects it to be. In gtk.cpp the showMenu function 
hides
-       //   or shows the menubar. Flash expects this option to disable some 
-       //   context menu items.
-       // callInterface is the proper handler for this
-       callInterface("Stage.showMenu", (_showMenu) ? "true" : "false");  //or 
this?
+    _showMenu = state;
+    //FIXME: The gui code for show menu is semantically different than what
+    //   ActionScript expects it to be. In gtk.cpp the showMenu function hides
+    //   or shows the menubar. Flash expects this option to disable some 
+    //   context menu items.
+    // callInterface is the proper handler for this
+    callInterface("Stage.showMenu", (_showMenu) ? "true" : "false");  //or 
this?
 }
 
 
@@ -1371,32 +1366,31 @@
         callMethod(stage, NSV::PROP_BROADCAST_MESSAGE, "onFullScreen", fs);
     }
 
-       if (!_interfaceHandler) return; // No registered callback
-       
+    if (!_interfaceHandler) return; // No registered callback
+    
     switch (_displayState)
     {
         case DISPLAYSTATE_FULLSCREEN:
             callInterface("Stage.displayState", "fullScreen");
             break;
         case DISPLAYSTATE_NORMAL:
-               callInterface("Stage.displayState", "normal");
+            callInterface("Stage.displayState", "normal");
             break;
-       }   
+    }   
 }
 
 void
 movie_root::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
 {
-       if ( isInvalidated() )
-       {
-               ranges.setWorld();
-               return;
-       }
+    if (isInvalidated()) {
+        ranges.setWorld();
+        return;
+    }
 
-       for (Levels::reverse_iterator i=_movies.rbegin(), e=_movies.rend(); 
i!=e; ++i)
-       {
-               i->second->add_invalidated_bounds(ranges, force);
-       }
+    for (Levels::reverse_iterator i=_movies.rbegin(), e=_movies.rend(); i!=e;
+                        ++i) {
+        i->second->add_invalidated_bounds(ranges, force);
+    }
 
 }
 
@@ -1404,90 +1398,90 @@
 int
 movie_root::minPopulatedPriorityQueue() const
 {
-       for (int l=0; l<apSIZE; ++l)
-       {
-               if (!_actionQueue[l].empty()) return l;
-       }
-       return apSIZE;
+    for (int l=0; l<apSIZE; ++l)
+    {
+        if (!_actionQueue[l].empty()) return l;
+    }
+    return apSIZE;
 }
 
 int
 movie_root::processActionQueue(int lvl)
 {
-       ActionQueue& q = _actionQueue[lvl];
-
-       assert( minPopulatedPriorityQueue() == lvl );
-
-#ifdef GNASH_DEBUG
-       static unsigned calls=0;
-       ++calls;
-       bool actionsToProcess = !q.empty();
-       if ( actionsToProcess )
-       {
-               log_debug(" Processing %d actions in priority queue %d (call 
%u)",
-                           q.size(), lvl, calls);
-       }
-#endif
-
-       // _actionQueue may be changed due to actions (appended-to)
-       // this loop might be optimized by using an iterator
-       // and a final call to .clear() 
-       while ( ! q.empty() )
-       {
-               std::auto_ptr<ExecutableCode> code(q.front());
-               q.pop_front(); 
-               code->execute();
-
-               int minLevel = minPopulatedPriorityQueue();
-               if ( minLevel < lvl )
-               {
-#ifdef GNASH_DEBUG
-                       log_debug(" Actions pushed in priority %d (< "
-                                       "%d), restarting the scan (call"
-                                       " %u)", minLevel, lvl, calls);
-#endif
-                       return minLevel;
-               }
-       }
-
-       assert(q.empty());
-
-#ifdef GNASH_DEBUG
-       if ( actionsToProcess )
-       {
-               log_debug(" Done processing actions in priority queue "
-                               "%d (call %u)", lvl, calls);
-       }
-#endif
-
-       return minPopulatedPriorityQueue();
+    ActionQueue& q = _actionQueue[lvl];
+
+    assert( minPopulatedPriorityQueue() == lvl );
+
+#ifdef GNASH_DEBUG
+    static unsigned calls=0;
+    ++calls;
+    bool actionsToProcess = !q.empty();
+    if ( actionsToProcess )
+    {
+        log_debug(" Processing %d actions in priority queue %d (call %u)",
+                    q.size(), lvl, calls);
+    }
+#endif
+
+    // _actionQueue may be changed due to actions (appended-to)
+    // this loop might be optimized by using an iterator
+    // and a final call to .clear() 
+    while ( ! q.empty() )
+    {
+        std::auto_ptr<ExecutableCode> code(q.front());
+        q.pop_front(); 
+        code->execute();
+
+        int minLevel = minPopulatedPriorityQueue();
+        if ( minLevel < lvl )
+        {
+#ifdef GNASH_DEBUG
+            log_debug(" Actions pushed in priority %d (< "
+                    "%d), restarting the scan (call"
+                    " %u)", minLevel, lvl, calls);
+#endif
+            return minLevel;
+        }
+    }
+
+    assert(q.empty());
+
+#ifdef GNASH_DEBUG
+    if ( actionsToProcess )
+    {
+        log_debug(" Done processing actions in priority queue "
+                "%d (call %u)", lvl, calls);
+    }
+#endif
+
+    return minPopulatedPriorityQueue();
 }
 
 void
 movie_root::flushHigherPriorityActionQueues()
 {
     if( ! processingActions() )
-       {
-               // only flush the actions queue when we are 
-               // processing the queue.
-               // ie. we don't want to flush the queue 
-               // during executing user event handlers,
-               // which are not pushed at the moment.
-               return;
-       }
-
-       if ( _disableScripts )
-       {
-               /// cleanup anything pushed later..
-               clearActionQueue();
-               return;
-       }
-
-       int lvl=minPopulatedPriorityQueue();
-       while ( lvl<_processingActionLevel )
-       {
-               lvl = processActionQueue(lvl);
-       }
+    {
+        // only flush the actions queue when we are 
+        // processing the queue.
+        // ie. we don't want to flush the queue 
+        // during executing user event handlers,
+        // which are not pushed at the moment.
+        return;
+    }
+
+    if ( _disableScripts )
+    {
+        /// cleanup anything pushed later..
+        clearActionQueue();
+        return;
+    }
+
+    int lvl=minPopulatedPriorityQueue();
+    while ( lvl<_processingActionLevel )
+    {
+        lvl = processActionQueue(lvl);
+    }
 
 }
 
@@ -1513,57 +1507,57 @@
 void
 movie_root::processActionQueue()
 {
-       if ( _disableScripts )
-       {
-               /// cleanup anything pushed later..
-               clearActionQueue();
-               return;
-       }
-
-       _processingActionLevel=minPopulatedPriorityQueue();
-       while ( _processingActionLevel<apSIZE )
-       {
-               _processingActionLevel = 
processActionQueue(_processingActionLevel);
-       }
-
-       // Cleanup the stack.
-       _vm.getStack().clear();
+    if ( _disableScripts )
+    {
+        /// cleanup anything pushed later..
+        clearActionQueue();
+        return;
+    }
+
+    _processingActionLevel=minPopulatedPriorityQueue();
+    while ( _processingActionLevel<apSIZE )
+    {
+        _processingActionLevel = processActionQueue(_processingActionLevel);
+    }
+
+    // Cleanup the stack.
+    _vm.getStack().clear();
 
 }
 
 void
 movie_root::pushAction(std::auto_ptr<ExecutableCode> code, int lvl)
 {
-       assert(lvl >= 0 && lvl < apSIZE);
-       _actionQueue[lvl].push_back(code.release());
+    assert(lvl >= 0 && lvl < apSIZE);
+    _actionQueue[lvl].push_back(code.release());
 }
 
 void
 movie_root::pushAction(const action_buffer& buf, DisplayObject* target, int 
lvl)
 {
-       assert(lvl >= 0 && lvl < apSIZE);
+    assert(lvl >= 0 && lvl < apSIZE);
 #ifdef GNASH_DEBUG
-       log_debug("Pushed action buffer for target %s", 
-                       target->getTargetPath());
+    log_debug("Pushed action buffer for target %s", 
+            target->getTargetPath());
 #endif
 
-       std::auto_ptr<ExecutableCode> code(new GlobalCode(buf, target));
+    std::auto_ptr<ExecutableCode> code(new GlobalCode(buf, target));
 
-       _actionQueue[lvl].push_back(code.release());
+    _actionQueue[lvl].push_back(code.release());
 }
 
 void
 movie_root::pushAction(as_function* func, DisplayObject* target, int lvl)
 {
-       assert(lvl >= 0 && lvl < apSIZE);
+    assert(lvl >= 0 && lvl < apSIZE);
 #ifdef GNASH_DEBUG
-       log_debug("Pushed function (event hanlder?) with target %s",
+    log_debug("Pushed function (event hanlder?) with target %s",
             target->getTargetPath());
 #endif
 
-       std::auto_ptr<ExecutableCode> code(new FunctionCode(func, target));
+    std::auto_ptr<ExecutableCode> code(new FunctionCode(func, target));
 
-       _actionQueue[lvl].push_back(code.release());
+    _actionQueue[lvl].push_back(code.release());
 }
 
 void
@@ -1597,51 +1591,46 @@
         log_debug("Checking %d timers for expiry", _intervalTimers.size());
 #endif
 
-       unsigned long now = _vm.getTime();
-
-       typedef std::multimap<unsigned int, Timer*> ExpiredTimers;
-       ExpiredTimers expiredTimers;
-
-       for (TimerMap::iterator it=_intervalTimers.begin(),
+    unsigned long now = _vm.getTime();
+
+    typedef std::multimap<unsigned int, Timer*> ExpiredTimers;
+    ExpiredTimers expiredTimers;
+
+    for (TimerMap::iterator it=_intervalTimers.begin(),
             itEnd=_intervalTimers.end(); it != itEnd; ) {
 
-               // Get an iterator to next element, as we'll use
-               // erase to drop cleared timers, and that would
-               // invalidate the current iterator.
-               //
-               // FYI: it's been reported on ##iso-c++ that next
-               //      C++ version will fix std::map<>::erase(iterator)
-               //      to return the next valid iterator,
-               //      like std::list<>::erase(iterator) does.
-               //      For now, we'll have to handle this manually)
-               //
-               TimerMap::iterator nextIterator = it;
-               ++nextIterator;
-
-               Timer* timer = it->second;
-
-               if ( timer->cleared() )
-               {
-                       // this timer was cleared, erase it
-                       delete timer;
-                       _intervalTimers.erase(it);
-               }
-               else
-               {
-                       unsigned long elapsed;
-                       if (timer->expired(now, elapsed))
-                       {
-                               expiredTimers.insert( std::make_pair(elapsed, 
timer) );
-                       }
-               }
-
-               it = nextIterator;
-       }
-
-       for (ExpiredTimers::iterator it=expiredTimers.begin(),
-            itEnd=expiredTimers.end(); it != itEnd; ++it) {
-               it->second->executeAndReset();
-       }
+        // Get an iterator to next element, as we'll use
+        // erase to drop cleared timers, and that would
+        // invalidate the current iterator.
+        //
+        // FYI: it's been reported on ##iso-c++ that next
+        //      C++ version will fix std::map<>::erase(iterator)
+        //      to return the next valid iterator,
+        //      like std::list<>::erase(iterator) does.
+        //      For now, we'll have to handle this manually)
+        //
+        TimerMap::iterator nextIterator = it;
+        ++nextIterator;
+
+        Timer* timer = it->second;
+
+        if (timer->cleared()) {
+            // this timer was cleared, erase it
+            delete timer;
+            _intervalTimers.erase(it);
+        }
+        else {
+            unsigned long elapsed;
+            if (timer->expired(now, elapsed)) {
+                expiredTimers.insert(std::make_pair(elapsed, timer));
+            }
+        }
+
+        it = nextIterator;
+    }
+
+    foreachSecond(expiredTimers.begin(), expiredTimers.end(),
+            std::mem_fun(&Timer::executeAndReset));
 
     if (!expiredTimers.empty()) processActionQueue();
 
@@ -1651,12 +1640,8 @@
 void
 movie_root::markReachableResources() const
 {
-    // Mark movie levels as reachable
-    for (Levels::const_reverse_iterator i=_movies.rbegin(), e=_movies.rend();
-            i!=e; ++i)
-    {
-        i->second->setReachable();
-    }
+    foreachSecond(_movies.rbegin(), _movies.rend(),
+            std::mem_fun(&MovieClip::setReachable));
 
     // Mark original top-level movie
     // This should always be in _movies, but better make sure
@@ -1666,11 +1651,8 @@
     _mouseButtonState.markReachableResources();
     
     // Mark timer targets
-    for (TimerMap::const_iterator i=_intervalTimers.begin(),
-            e=_intervalTimers.end(); i != e; ++i)
-    {
-        i->second->markReachableResources();
-    }
+    foreachSecond(_intervalTimers.begin(), _intervalTimers.end(),
+            std::mem_fun(&Timer::markReachableResources));
 
     std::for_each(_objectCallbacks.begin(), _objectCallbacks.end(),
             std::mem_fun(&ActiveRelay::setReachable));
@@ -1742,14 +1724,14 @@
 movie_root::getTopmostMouseEntity(boost::int32_t x, boost::int32_t y) const
 {
 
-       for (Levels::const_reverse_iterator i=_movies.rbegin(), 
e=_movies.rend();
+    for (Levels::const_reverse_iterator i=_movies.rbegin(), e=_movies.rend();
             i != e; ++i)
-       {
-               InteractiveObject* ret = i->second->topmostMouseEntity(x, y);
-               if (ret) return ret;
-       }
+    {
+        InteractiveObject* ret = i->second->topmostMouseEntity(x, y);
+        if (ret) return ret;
+    }
 
-       return 0;
+    return 0;
 }
 
 const DisplayObject *
@@ -1759,11 +1741,11 @@
 
     for (Levels::const_reverse_iterator i=_movies.rbegin(), e=_movies.rend();
             i!=e; ++i) {
-               
+        
         const DisplayObject* ret = i->second->findDropTarget(x, y, dragging);
-               if (ret) return ret;
-       }
-       return 0;
+        if (ret) return ret;
+    }
+    return 0;
 }
 
 void
@@ -1773,16 +1755,15 @@
 #define GNASH_DEBUG_INSTANCE_LIST 1
 
 #ifdef GNASH_DEBUG_INSTANCE_LIST
-       // This 
-       static size_t maxLiveChars = 0;
+    static size_t maxLiveChars = 0;
 #endif
 
-       // Let every sprite cleanup the local DisplayList
+    // Let every sprite cleanup the local DisplayList
     //
-    // TODO: we might skip this additinal scan by delegating
+    // TODO: we might skip this additional scan by delegating
     //       cleanup of the local DisplayLists in the ::display
     //       method of each sprite, but that will introduce 
-    //       problems when we'll implement skipping ::display()
+    //       problems when we implement skipping ::display()
     //       when late on FPS. Alternatively we may have the
     //       MovieClip::markReachableResources take care
     //       of cleaning up unloaded... but that will likely
@@ -1791,82 +1772,79 @@
     //       The invariant to keep is that cleanup of unloaded DisplayObjects
     //       in local display lists must happen at the *end* of global action
     //       queue processing.
+    foreachSecond(_movies.rbegin(), _movies.rend(),
+            std::mem_fun(&MovieClip::cleanupDisplayList));
+
+    // Now remove from the instance list any unloaded DisplayObject
+    // Note that some DisplayObjects may be unloaded but not yet destroyed,
+    // in this case we'll also destroy them, which in turn might unload
+    // further DisplayObjects, maybe already scanned, so we keep scanning
+    // the list until no more unloaded-but-non-destroyed DisplayObjects
+    // are found.
+    // Keeping unloaded-but-non-destroyed DisplayObjects wouldn't really hurt
+    // in that ::advanceLiveChars would skip any unloaded DisplayObjects.
+    // Still, the more we remove the less work GC has to do...
     //
-    for (Levels::reverse_iterator i=_movies.rbegin(), e=_movies.rend(); i!=e; 
++i)
-    {
-        i->second->cleanupDisplayList();
-    }
-
-       // Now remove from the instance list any unloaded DisplayObject
-       // Note that some DisplayObjects may be unloaded but not yet destroyed,
-       // in this case we'll also destroy them, which in turn might unload
-       // further DisplayObjects, maybe already scanned, so we keep scanning
-       // the list until no more unloaded-but-non-destroyed DisplayObjects
-       // are found.
-       // Keeping unloaded-but-non-destroyed DisplayObjects wouldn't really 
hurt
-       // in that ::advanceLiveChars would skip any unloaded DisplayObjects.
-       // Still, the more we remove the less work GC has to do...
-       //
-
-       bool needScan;
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-       int scansCount = 0;
-#endif
-       do {
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-               scansCount++;
-               int cleaned =0;
-#endif
-               needScan=false;
-
-               // Remove unloaded DisplayObjects from the _liveChars list
-               for (LiveChars::iterator i=_liveChars.begin(), 
e=_liveChars.end(); i!=e;)
-               {
-                       DisplayObject* ch = *i;
-                       if (ch->unloaded()) {
-                               // the sprite might have been destroyed already
-                               // by effect of an unload() call with no 
onUnload
-                               // handlers available either in self or child
-                               // DisplayObjects
-                               if (!ch->isDestroyed()) {
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-                                       cout << ch->getTarget() << "(" << 
typeName(*ch) <<
+
+    bool needScan;
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+    int scansCount = 0;
+#endif
+    do {
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+        scansCount++;
+        int cleaned =0;
+#endif
+        needScan=false;
+
+        // Remove unloaded DisplayObjects from the _liveChars list
+        for (LiveChars::iterator i=_liveChars.begin(), e=_liveChars.end(); 
i!=e;)
+        {
+            DisplayObject* ch = *i;
+            if (ch->unloaded()) {
+                // the sprite might have been destroyed already
+                // by effect of an unload() call with no onUnload
+                // handlers available either in self or child
+                // DisplayObjects
+                if (!ch->isDestroyed()) {
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+                    cout << ch->getTarget() << "(" << typeName(*ch) <<
                         ") was unloaded but not destroyed, destroying now" <<
                         endl;
 #endif
-                                       ch->destroy();
+                    ch->destroy();
                     // destroy() might mark already-scanned chars as unloaded
-                                       needScan = true; 
-                               }
+                    needScan = true; 
+                }
 #ifdef GNASH_DEBUG_DLIST_CLEANUP
-                               else {
-                                       cout << ch->getTarget() << "(" << 
typeName(*ch) <<
+                else {
+                    cout << ch->getTarget() << "(" << typeName(*ch) <<
                         ") was unloaded and destroyed" << endl;
-                               }
-#endif
-
-                               i = _liveChars.erase(i);
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-                               cleaned++;
-#endif
-                       }
-                       else ++i; 
-               }
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-               cout << " Scan " << scansCount << " cleaned " << cleaned <<
+                }
+#endif
+
+                i = _liveChars.erase(i);
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+                cleaned++;
+#endif
+            }
+            else ++i; 
+        }
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+        cout << " Scan " << scansCount << " cleaned " << cleaned <<
             " instances" << endl;
 #endif
-       } while (needScan);
+    } while (needScan);
 
 #ifdef GNASH_DEBUG_INSTANCE_LIST
-       if ( _liveChars.size() > maxLiveChars )
-       {
-               maxLiveChars = _liveChars.size();
-               log_debug("Global instance list grew to %d entries", 
maxLiveChars);
-       }
+    if ( _liveChars.size() > maxLiveChars )
+    {
+        maxLiveChars = _liveChars.size();
+        log_debug("Global instance list grew to %d entries", maxLiveChars);
+    }
 #endif
 
 }
@@ -1874,18 +1852,18 @@
 void
 movie_root::advanceLiveChar(DisplayObject* ch)
 {
-       if (!ch->unloaded())
-       {
+    if (!ch->unloaded())
+    {
 #ifdef GNASH_DEBUG
-               log_debug("    advancing DisplayObject %s", ch->getTarget());
+        log_debug("    advancing DisplayObject %s", ch->getTarget());
 #endif
-               ch->advance();
-       }
+        ch->advance();
+    }
 #ifdef GNASH_DEBUG
-       else {
-               log_debug("    DisplayObject %s is unloaded, not advancing it",
+    else {
+        log_debug("    DisplayObject %s is unloaded, not advancing it",
                 ch->getTarget());
-       }
+    }
 #endif
 }
 
@@ -1894,76 +1872,76 @@
 {
 
 #ifdef GNASH_DEBUG
-       log_debug("---- movie_root::advance: %d live DisplayObjects in "
+    log_debug("---- movie_root::advance: %d live DisplayObjects in "
             "the global list", _liveChars.size());
 #endif
 
-       std::for_each(_liveChars.begin(), _liveChars.end(),
+    std::for_each(_liveChars.begin(), _liveChars.end(),
             boost::bind(advanceLiveChar, _1));
 }
 
 void
 movie_root::set_background_color(const rgba& color)
 {
-       if (m_background_color_set) return;
-       m_background_color_set = true;
+    if (m_background_color_set) return;
+    m_background_color_set = true;
     
     rgba newcolor = color;
     newcolor.m_a = m_background_color.m_a;
 
     if (m_background_color != color) {
-               setInvalidated();
+        setInvalidated();
         m_background_color = color;
-       }
+    }
 }
 
 void
 movie_root::set_background_alpha(float alpha)
 {
 
-       boost::uint8_t newAlpha = clamp<int>(frnd(alpha * 255.0f), 0, 255);
+    boost::uint8_t newAlpha = clamp<int>(frnd(alpha * 255.0f), 0, 255);
 
     if (m_background_color.m_a != newAlpha) {
-               setInvalidated();
+        setInvalidated();
         m_background_color.m_a = newAlpha;
-       }
+    }
 }
 
 DisplayObject*
 movie_root::findCharacterByTarget(const std::string& tgtstr) const
 {
-       if (tgtstr.empty()) return 0;
-
-       string_table& st = _vm.getStringTable();
-
-       // NOTE: getRootMovie() would be problematic in case the original
-       //       root movie is replaced by a load to _level0... 
-       //       (but I guess we'd also drop loadMovie requests in that
-       //       case... just not tested)
-       as_object* o = getObject(_movies.begin()->second);
+    if (tgtstr.empty()) return 0;
+
+    string_table& st = _vm.getStringTable();
+
+    // NOTE: getRootMovie() would be problematic in case the original
+    //       root movie is replaced by a load to _level0... 
+    //       (but I guess we'd also drop loadMovie requests in that
+    //       case... just not tested)
+    as_object* o = getObject(_movies.begin()->second);
     assert(o);
 
-       std::string::size_type from = 0;
-       while (std::string::size_type to = tgtstr.find('.', from))
-       {
-               std::string part(tgtstr, from, to - from);
+    std::string::size_type from = 0;
+    while (std::string::size_type to = tgtstr.find('.', from))
+    {
+        std::string part(tgtstr, from, to - from);
 
         // TODO: there is surely a cleaner way to implement path finding.
         o = o->displayObject() ?
             o->displayObject()->pathElement(st.find(part)) :
             o->get_path_element(st.find(part));
 
-               if (!o) {
+        if (!o) {
 #ifdef GNASH_DEBUG_TARGET_RESOLUTION
-                       log_debug("Evaluating DisplayObject target path: 
element "
+            log_debug("Evaluating DisplayObject target path: element "
                     "'%s' of path '%s' not found", part, tgtstr);
 #endif
-                       return NULL;
-               }
-               if (to == std::string::npos) break;
-               from = to + 1;
-       }
-       return get<DisplayObject>(o);
+            return NULL;
+        }
+        if (to == std::string::npos) break;
+        from = to + 1;
+    }
+    return get<DisplayObject>(o);
 }
 
 void
@@ -2158,12 +2136,12 @@
     localIter = tr.append_child(it, StringPair(_("Live DisplayObjects"),
                 os.str()));
 
-       /// Live DisplayObjects tree
-       for (LiveChars::const_iterator i=_liveChars.begin(), e=_liveChars.end();
-                                                                  i != e; ++i)
-       {
-           (*i)->getMovieInfo(tr, localIter);
-       }
+    /// Live DisplayObjects tree
+    for (LiveChars::const_iterator i=_liveChars.begin(), e=_liveChars.end();
+                                                               i != e; ++i)
+    {
+        (*i)->getMovieInfo(tr, localIter);
+    }
 
 }
 
@@ -2173,23 +2151,23 @@
 movie_root::handleFsCommand(const std::string& cmd, const std::string& arg)
     const
 {
-       if (_fsCommandHandler) _fsCommandHandler->notify(cmd, arg);
+    if (_fsCommandHandler) _fsCommandHandler->notify(cmd, arg);
 }
 
 void
 movie_root::errorInterface(const std::string& msg) const
 {
-       if (_interfaceHandler) _interfaceHandler->error(msg);
+    if (_interfaceHandler) _interfaceHandler->error(msg);
 }
 
 std::string
 movie_root::callInterface(const std::string& cmd, const std::string& arg) const
 {
-       if (_interfaceHandler) return _interfaceHandler->call(cmd, arg);
-
-       log_error("Hosting application registered no callback for 
events/queries");
-
-       return "<no iface to hosting app>";
+    if (_interfaceHandler) return _interfaceHandler->call(cmd, arg);
+
+    log_error("Hosting application registered no callback for events/queries");
+
+    return "<no iface to hosting app>";
 }
 
 bool
@@ -2333,8 +2311,8 @@
 generate_mouse_button_events(movie_root& mr, MouseButtonState& ms)
 {
 
-       // Did this event trigger any action that needs redisplay ?
-       bool need_redisplay = false;
+    // Did this event trigger any action that needs redisplay ?
+    bool need_redisplay = false;
 
     // TODO: have mouseEvent return
     // whether the action must trigger
@@ -2343,79 +2321,79 @@
     switch (ms.previousButtonState)
     {
         case MouseButtonState::DOWN:
-           {
-                   // TODO: Handle trackAsMenu dragOver
-                   // Handle onDragOut, onDragOver
-                   if (!ms.wasInsideActiveEntity) {
-
-                           if (ms.topmostEntity == ms.activeEntity) {
-
-                                   // onDragOver
-                                   if (ms.activeEntity) {
-                                           
ms.activeEntity->mouseEvent(event_id::DRAG_OVER);
-                                           need_redisplay=true;
-                                   }
-                                   ms.wasInsideActiveEntity = true;
-                           }
-                   }
-                   else if (ms.topmostEntity != ms.activeEntity) {
-                           // onDragOut
-                           if (ms.activeEntity) {
-                                   
ms.activeEntity->mouseEvent(event_id::DRAG_OUT);
-                                   need_redisplay=true;
-                           }
-                           ms.wasInsideActiveEntity = false;
-                   }
-
-                   // Handle onRelease, onReleaseOutside
-                   if (ms.currentButtonState == MouseButtonState::UP) {
-                           // Mouse button just went up.
-                           ms.previousButtonState = MouseButtonState::UP;
-
-                           if (ms.activeEntity) {
-                                   if (ms.wasInsideActiveEntity) {
-                                           // onRelease
-                                           
ms.activeEntity->mouseEvent(event_id::RELEASE);
-                                           need_redisplay = true;
-                                   }
-                                   else {
-                                           // TODO: Handle trackAsMenu 
-                                           // onReleaseOutside
-                                           
ms.activeEntity->mouseEvent(event_id::RELEASE_OUTSIDE);
-                                           // We got out of active entity
-                                           ms.activeEntity = 0; // so we don't 
get RollOut next...
-                                           need_redisplay = true;
-                                   }
-                           }
-                   }
-               return need_redisplay;
-           }
-
-           case MouseButtonState::UP:
-        {
-               // New active entity is whatever is below the mouse right now.
-               if (ms.topmostEntity != ms.activeEntity)
-               {
-                       // onRollOut
-                       if (ms.activeEntity) {
-                               ms.activeEntity->mouseEvent(event_id::ROLL_OUT);
-                               need_redisplay=true;
-                       }
-
-                       ms.activeEntity = ms.topmostEntity;
-
-                       // onRollOver
-                       if (ms.activeEntity) {
-                               
ms.activeEntity->mouseEvent(event_id::ROLL_OVER);
-                               need_redisplay=true;
-                       }
-
-                       ms.wasInsideActiveEntity = true;
-               }
-
-               // mouse button press
-               if (ms.currentButtonState == MouseButtonState::DOWN) {
-                       // onPress
+        {
+            // TODO: Handle trackAsMenu dragOver
+            // Handle onDragOut, onDragOver
+            if (!ms.wasInsideActiveEntity) {
+
+                if (ms.topmostEntity == ms.activeEntity) {
+
+                    // onDragOver
+                    if (ms.activeEntity) {
+                        ms.activeEntity->mouseEvent(event_id::DRAG_OVER);
+                        need_redisplay=true;
+                    }
+                    ms.wasInsideActiveEntity = true;
+                }
+            }
+            else if (ms.topmostEntity != ms.activeEntity) {
+                // onDragOut
+                if (ms.activeEntity) {
+                    ms.activeEntity->mouseEvent(event_id::DRAG_OUT);
+                    need_redisplay=true;
+                }
+                ms.wasInsideActiveEntity = false;
+            }
+
+            // Handle onRelease, onReleaseOutside
+            if (ms.currentButtonState == MouseButtonState::UP) {
+                // Mouse button just went up.
+                ms.previousButtonState = MouseButtonState::UP;
+
+                if (ms.activeEntity) {
+                    if (ms.wasInsideActiveEntity) {
+                        // onRelease
+                        ms.activeEntity->mouseEvent(event_id::RELEASE);
+                        need_redisplay = true;
+                    }
+                    else {
+                        // TODO: Handle trackAsMenu 
+                        // onReleaseOutside
+                        ms.activeEntity->mouseEvent(event_id::RELEASE_OUTSIDE);
+                        // We got out of active entity
+                        ms.activeEntity = 0; // so we don't get RollOut next...
+                        need_redisplay = true;
+                    }
+                }
+            }
+            return need_redisplay;
+        }
+
+        case MouseButtonState::UP:
+        {
+            // New active entity is whatever is below the mouse right now.
+            if (ms.topmostEntity != ms.activeEntity)
+            {
+                // onRollOut
+                if (ms.activeEntity) {
+                    ms.activeEntity->mouseEvent(event_id::ROLL_OUT);
+                    need_redisplay=true;
+                }
+
+                ms.activeEntity = ms.topmostEntity;
+
+                // onRollOver
+                if (ms.activeEntity) {
+                    ms.activeEntity->mouseEvent(event_id::ROLL_OVER);
+                    need_redisplay=true;
+                }
+
+                ms.wasInsideActiveEntity = true;
+            }
+
+            // mouse button press
+            if (ms.currentButtonState == MouseButtonState::DOWN) {
+                // onPress
 
                 // Try setting focus on the new DisplayObject. This will handle
                 // all necessary events and removal of current focus.
@@ -2423,16 +2401,16 @@
                 if (ms.activeEntity) {
                     mr.setFocus(ms.activeEntity);
 
-                               ms.activeEntity->mouseEvent(event_id::PRESS);
-                               need_redisplay=true;
-                       }
+                    ms.activeEntity->mouseEvent(event_id::PRESS);
+                    need_redisplay=true;
+                }
 
-                       ms.wasInsideActiveEntity = true;
-                       ms.previousButtonState = MouseButtonState::DOWN;
-               }
+                ms.wasInsideActiveEntity = true;
+                ms.previousButtonState = MouseButtonState::DOWN;
+            }
         }
         default:
-           return need_redisplay;
+              return need_redisplay;
     }
 
 }

=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp     2010-01-11 06:41:38 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp     2010-01-18 14:43:24 +0000
@@ -177,7 +177,7 @@
             e = m_playlist.end(); i != e; ++i)
        {
                PlayList& pl = i->second;
-        deleteAllChecked(pl);
+        deleteChecked(pl.begin(), pl.end());
     }
 
 }

=== modified file 'libcore/parser/sprite_definition.cpp'
--- a/libcore/parser/sprite_definition.cpp      2010-01-11 06:41:38 +0000
+++ b/libcore/parser/sprite_definition.cpp      2010-01-18 14:43:24 +0000
@@ -66,7 +66,7 @@
             i != e; ++i)
        {
                PlayList& pl = i->second;
-        deleteAllChecked(pl);
+        deleteChecked(pl.begin(), pl.end());
     }
 }
 

=== modified file 'libcore/swf/DefineButtonTag.cpp'
--- a/libcore/swf/DefineButtonTag.cpp   2010-01-11 06:41:38 +0000
+++ b/libcore/swf/DefineButtonTag.cpp   2010-01-18 14:43:24 +0000
@@ -68,7 +68,7 @@
 
 DefineButtonTag::~DefineButtonTag()
 {
-    deleteAllChecked(_buttonActions);
+    deleteChecked(_buttonActions.begin(), _buttonActions.end());
 }
 
 

=== modified file 'libcore/swf/DefineVideoStreamTag.cpp'
--- a/libcore/swf/DefineVideoStreamTag.cpp      2010-01-11 06:41:38 +0000
+++ b/libcore/swf/DefineVideoStreamTag.cpp      2010-01-18 14:43:24 +0000
@@ -67,7 +67,7 @@
 
 DefineVideoStreamTag::~DefineVideoStreamTag()
 {
-    deleteAllChecked(_video_frames);
+    deleteChecked(_video_frames.begin(), _video_frames.end());
 }
 
 

=== modified file 'libcore/swf/PlaceObject2Tag.cpp'
--- a/libcore/swf/PlaceObject2Tag.cpp   2010-01-01 17:48:26 +0000
+++ b/libcore/swf/PlaceObject2Tag.cpp   2010-01-18 14:43:24 +0000
@@ -479,8 +479,8 @@
 
 PlaceObject2Tag::~PlaceObject2Tag()
 {
-    deleteAllChecked(_eventHandlers);
-    deleteAllChecked(_actionBuffers);
+    deleteChecked(_eventHandlers.begin(), _eventHandlers.end());
+    deleteChecked(_actionBuffers.begin(), _actionBuffers.end());
 }
 
 /* public static */


reply via email to

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