gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. d82c81aa3356d17bb2f2


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. d82c81aa3356d17bb2f221575b78303fae965796
Date: Tue, 16 Nov 2010 12:21:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  d82c81aa3356d17bb2f221575b78303fae965796 (commit)
       via  e4101499661abdf3f8700932c7f5e2f33c20a86a (commit)
       via  506f23ba4e88ff448a54e0ee96fb072c446d5369 (commit)
      from  cfbed921b8956bbd15862684c52fc3463807d1ba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=d82c81aa3356d17bb2f221575b78303fae965796


commit d82c81aa3356d17bb2f221575b78303fae965796
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 16 12:59:24 2010 +0100

    Use intrusive_ptr to prevent possible leaks.

diff --git a/libbase/ref_counted.h b/libbase/ref_counted.h
index 2fb66f1..65a5c26 100644
--- a/libbase/ref_counted.h
+++ b/libbase/ref_counted.h
@@ -42,7 +42,6 @@ private:
        // (decrement & check in a single statement)
        //
        typedef boost::detail::atomic_count Counter;
-       // typedef long Counter;
 
        mutable Counter m_ref_count;
        
@@ -68,23 +67,21 @@ public:
        {
        }
 
-       void    add_ref() const
-       {
+       void add_ref() const {
                assert(m_ref_count >= 0);
                ++m_ref_count;
        }
 
-       void    drop_ref() const
-       {
+       void drop_ref() const {
+
                assert(m_ref_count > 0);
-               if (!--m_ref_count)
-               {
+               if (!--m_ref_count) {
                        // Delete me!
                        delete this;
                }
        }
 
-       long    get_ref_count() const { return m_ref_count; }
+       long get_ref_count() const { return m_ref_count; }
 };
 
 } // namespace gnash
diff --git a/libcore/parser/SWFMovieDefinition.h 
b/libcore/parser/SWFMovieDefinition.h
index 9aa17c5..9330cd0 100644
--- a/libcore/parser/SWFMovieDefinition.h
+++ b/libcore/parser/SWFMovieDefinition.h
@@ -281,7 +281,7 @@ public:
     }
 
     // See dox in movie_definition.h
-    void addControlTag(SWF::ControlTag* tag) {
+    void addControlTag(boost::intrusive_ptr<SWF::ControlTag> tag) {
         assert(tag);
         boost::mutex::scoped_lock lock(_frames_loaded_mutex);
         m_playlist[_frames_loaded].push_back(tag);
diff --git a/libcore/parser/movie_definition.h 
b/libcore/parser/movie_definition.h
index ef6fce0..50d720e 100644
--- a/libcore/parser/movie_definition.h
+++ b/libcore/parser/movie_definition.h
@@ -282,11 +282,7 @@ public:
        ///     The tag to add in the list of executable tags for
        ///     the frame currently being loaded. Ownership is transferred
        ///     to the SWFMovieDefinition.
-       ///
-       /// TODO: take an auto_ptr.
-       /// NOTE: the default implementation just let the ControlTag leak.
-       ///
-       virtual void addControlTag(SWF::ControlTag* /*c*/)
+       virtual void addControlTag(boost::intrusive_ptr<SWF::ControlTag> /*c*/)
        {
        }
 
diff --git a/libcore/parser/sprite_definition.h 
b/libcore/parser/sprite_definition.h
index 8721669..61e82fe 100644
--- a/libcore/parser/sprite_definition.h
+++ b/libcore/parser/sprite_definition.h
@@ -228,7 +228,7 @@ public:
             DisplayObject* parent) const;
 
        // See dox in movie_definition.h
-       virtual void addControlTag(SWF::ControlTag* c)
+       virtual void addControlTag(boost::intrusive_ptr<SWF::ControlTag> c)
        {
                m_playlist[m_loading_frame].push_back(c);
        }
diff --git a/libcore/swf/DefineSceneAndFrameLabelDataTag.h 
b/libcore/swf/DefineSceneAndFrameLabelDataTag.h
index 5407746..db64c47 100644
--- a/libcore/swf/DefineSceneAndFrameLabelDataTag.h
+++ b/libcore/swf/DefineSceneAndFrameLabelDataTag.h
@@ -59,8 +59,8 @@ public:
                     "non-AS3 SWF!");
         }
 
-        DefineSceneAndFrameLabelDataTag* t =
-            new DefineSceneAndFrameLabelDataTag(in);
+        boost::intrusive_ptr<ControlTag> t(
+            new DefineSceneAndFrameLabelDataTag(in));
 
         /// This tag is only added to the main timeline (SWFMovieDefinition).
         m.addControlTag(t);
diff --git a/libcore/swf/DoABCTag.h b/libcore/swf/DoABCTag.h
index 5c7094d..ffe0b89 100644
--- a/libcore/swf/DoABCTag.h
+++ b/libcore/swf/DoABCTag.h
@@ -94,7 +94,7 @@ public:
         }
 
         // _abc = block;
-               DoABCTag* ABCtag = new DoABCTag(block.release());
+               boost::intrusive_ptr<DoABCTag> ABCtag(new 
DoABCTag(block.release()));
                
                IF_VERBOSE_PARSE (
             log_parse(_("tag %d: DoABCDefine"), tag);
diff --git a/libcore/swf/DoActionTag.h b/libcore/swf/DoActionTag.h
index 0cb86cf..5284963 100644
--- a/libcore/swf/DoActionTag.h
+++ b/libcore/swf/DoActionTag.h
@@ -61,12 +61,12 @@ public:
             throw ParserException("DoAction tag found in AS3 SWF!");
         }
         
-               DoActionTag* da = new DoActionTag(m);
+               boost::intrusive_ptr<DoActionTag> da(new DoActionTag(m));
                da->read(in);
 
-               IF_VERBOSE_PARSE (
-               log_parse(_("tag %d: do_action_loader"), tag);
-               log_parse(_("-- actions in frame %d"), m.get_loading_frame());
+               IF_VERBOSE_PARSE(
+            log_parse(_("tag %d: do_action_loader"), tag);
+            log_parse(_("-- actions in frame %d"), m.get_loading_frame());
                );
 
                m.addControlTag(da); // ownership transferred
diff --git a/libcore/swf/DoInitActionTag.h b/libcore/swf/DoInitActionTag.h
index aae97c0..de5d594 100644
--- a/libcore/swf/DoInitActionTag.h
+++ b/libcore/swf/DoInitActionTag.h
@@ -73,6 +73,11 @@ public:
         in.ensureBytes(2);
         const boost::uint16_t cid = in.read_u16();
 
+        IF_VERBOSE_PARSE(
+            log_parse(_("  tag %d: do_init_action_loader"), tag);
+            log_parse(_("  -- init actions for sprite %d"), cid);
+        );
+
         // TODO: Currently, tags are only be executed for already parsed
         // character ids. This is known to be wrong: a more accurate
         // description is:
@@ -86,13 +91,7 @@ public:
         //
         // Gnash currently doesn't know which characters are on the stage, or
         // which IDs have been exported.
-        DoInitActionTag* da = new DoInitActionTag(in, m, cid);
-
-        IF_VERBOSE_PARSE(
-            log_parse(_("  tag %d: do_init_action_loader"), tag);
-            log_parse(_("  -- init actions for sprite %d"), cid);
-        );
-
+        boost::intrusive_ptr<ControlTag> da(new DoInitActionTag(in, m, cid));
         m.addControlTag(da); // ownership transferred
     }
 
diff --git a/libcore/swf/ExportAssetsTag.h b/libcore/swf/ExportAssetsTag.h
index ec4a40d..43be505 100644
--- a/libcore/swf/ExportAssetsTag.h
+++ b/libcore/swf/ExportAssetsTag.h
@@ -45,8 +45,8 @@ public:
     {
         assert(tag == SWF::EXPORTASSETS); // 56
 
-        std::auto_ptr<ControlTag> t(new ExportAssetsTag(in, m));
-        m.addControlTag(t.release());
+        boost::intrusive_ptr<ControlTag> t(new ExportAssetsTag(in, m));
+        m.addControlTag(t);
     }
 
 
diff --git a/libcore/swf/ImportAssetsTag.h b/libcore/swf/ImportAssetsTag.h
index 9eadae8..13d53e3 100644
--- a/libcore/swf/ImportAssetsTag.h
+++ b/libcore/swf/ImportAssetsTag.h
@@ -47,8 +47,8 @@ public:
     {
         assert(tag == SWF::IMPORTASSETS || tag == SWF::IMPORTASSETS2);
 
-        std::auto_ptr<ControlTag> p(new ImportAssetsTag(tag, in, m, r));
-        m.addControlTag(p.release());
+        boost::intrusive_ptr<ControlTag> p(new ImportAssetsTag(tag, in, m, r));
+        m.addControlTag(p);
     }
 
 
diff --git a/libcore/swf/PlaceObject2Tag.cpp b/libcore/swf/PlaceObject2Tag.cpp
index a552f12..a82bf4d 100644
--- a/libcore/swf/PlaceObject2Tag.cpp
+++ b/libcore/swf/PlaceObject2Tag.cpp
@@ -492,8 +492,7 @@ PlaceObject2Tag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     assert(tag == SWF::PLACEOBJECT || tag == SWF::PLACEOBJECT2 ||
             tag == SWF::PLACEOBJECT3);
 
-    // TODO: who owns and is going to remove this tag ?
-    PlaceObject2Tag* ch = new PlaceObject2Tag(m);
+    boost::intrusive_ptr<PlaceObject2Tag> ch(new PlaceObject2Tag(m));
     ch->read(in, tag);
 
     m.addControlTag(ch);
diff --git a/libcore/swf/RemoveObjectTag.cpp b/libcore/swf/RemoveObjectTag.cpp
index 8b950ab..fecbc2a 100644
--- a/libcore/swf/RemoveObjectTag.cpp
+++ b/libcore/swf/RemoveObjectTag.cpp
@@ -61,17 +61,17 @@ RemoveObjectTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
 {
     assert(tag == SWF::REMOVEOBJECT || tag == SWF::REMOVEOBJECT2);
 
-    std::auto_ptr<RemoveObjectTag> t ( new RemoveObjectTag );
+    boost::intrusive_ptr<RemoveObjectTag> t(new RemoveObjectTag);
     t->read(in, tag);
 
-    int depth = t->getDepth();
+    const int depth = t->getDepth();
 
     IF_VERBOSE_PARSE(
         log_parse(_("  remove_object_2(%d)"), depth);
     );
 
     // Ownership transferred to movie_definition
-    m.addControlTag(t.release());
+    m.addControlTag(t);
 }
 
 } // namespace gnash::SWF
diff --git a/libcore/swf/ScriptLimitsTag.h b/libcore/swf/ScriptLimitsTag.h
index f89070d..24213b3 100644
--- a/libcore/swf/ScriptLimitsTag.h
+++ b/libcore/swf/ScriptLimitsTag.h
@@ -49,8 +49,8 @@ public:
             const RunResources& /*r*/)
     {
         assert(tag = SWF::SCRIPTLIMITS);
-        std::auto_ptr<ScriptLimitsTag> s(new ScriptLimitsTag(in));
-        m.addControlTag(s.release());
+        boost::intrusive_ptr<ControlTag> s(new ScriptLimitsTag(in));
+        m.addControlTag(s);
     }
 
 private:
diff --git a/libcore/swf/SetBackgroundColorTag.h 
b/libcore/swf/SetBackgroundColorTag.h
index 248708a..7e60cb4 100644
--- a/libcore/swf/SetBackgroundColorTag.h
+++ b/libcore/swf/SetBackgroundColorTag.h
@@ -88,7 +88,7 @@ public:
                assert(tag == SWF::SETBACKGROUNDCOLOR); // 9
 
                // this one may throw, we'll let caller catch it
-               SetBackgroundColorTag* t = new SetBackgroundColorTag(in);
+               boost::intrusive_ptr<ControlTag> t(new 
SetBackgroundColorTag(in));
                m.addControlTag(t); // takes ownership
        }
 };
diff --git a/libcore/swf/StartSoundTag.cpp b/libcore/swf/StartSoundTag.cpp
index cec946b..90f6ac5 100644
--- a/libcore/swf/StartSoundTag.cpp
+++ b/libcore/swf/StartSoundTag.cpp
@@ -46,8 +46,8 @@ StartSoundTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     int sound_id = in.read_u16();
 
     sound_sample* sam = m.get_sound_sample(sound_id);
-    if ( ! sam ) // invalid id... nothing to do
-    {
+    if (!sam) {
+        // invalid id... nothing to do
         IF_VERBOSE_MALFORMED_SWF(
             // if there's no sound_handler we might have simply skipped
             // the definition of sound sample...
@@ -59,17 +59,19 @@ StartSoundTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
         return;
     }
 
+    IF_VERBOSE_PARSE(
+         log_parse(_("StartSound: id=%d"), sound_id);
+    );
+
     // NOTE: sound_id is the SWF-defined id,
     //       sam->m_sound_handler_id is the sound_handler-provided id
-    //
+    
     in.align(); // necessary?
-    StartSoundTag* sst = new StartSoundTag(in, sam->m_sound_handler_id);
 
-    IF_VERBOSE_PARSE (
-         log_parse(_("StartSound: id=%d"), sound_id);
-    );
+    boost::intrusive_ptr<ControlTag> sst(
+        new StartSoundTag(in, sam->m_sound_handler_id));
 
-    m.addControlTag(sst); // takes ownership
+    m.addControlTag(sst);
 }
 
 void
diff --git a/libcore/swf/StreamSoundBlockTag.cpp 
b/libcore/swf/StreamSoundBlockTag.cpp
index a21b6f9..0cddc77 100644
--- a/libcore/swf/StreamSoundBlockTag.cpp
+++ b/libcore/swf/StreamSoundBlockTag.cpp
@@ -19,13 +19,12 @@
 #include "StreamSoundBlockTag.h"
 #include "sound_handler.h" 
 #include "movie_root.h"
-#include "movie_definition.h" // for addControlTag
+#include "movie_definition.h"
 #include "MovieClip.h" // for execute
 #include "SoundInfo.h" // for loader
 #include "SWFStream.h"
 #include "log.h"
 #include "RunResources.h"
-#include "VM.h" // For getting movie_root. TODO: drop
 
 namespace gnash {
 namespace SWF {
@@ -34,9 +33,10 @@ void
 StreamSoundBlockTag::executeActions(MovieClip* m, DisplayList& /*dlist*/) const
 {
 
-    sound::sound_handler* handler = 
getRunResources(*getObject(m)).soundHandler(); 
-    if (handler)
-    {
+    sound::sound_handler* handler =
+        getRunResources(*getObject(m)).soundHandler(); 
+
+    if (handler) {
         // This makes it possible to stop only the stream when framejumping.
         m->setStreamSoundId(m_handler_id);
 
@@ -61,15 +61,14 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     }
 
     // Get the ID of the sound stream currently being loaded
-    int streamId = m.get_loading_sound_stream_id();
+    const int sId = m.get_loading_sound_stream_id();
 
     // Get the SoundInfo object that contains info about the sound stream.
     // Ownership of the object is in the soundhandler
-    media::SoundInfo* sinfo = handler->get_sound_info(streamId);
+    media::SoundInfo* sinfo = handler->get_sound_info(sId);
 
     // If there is no SoundInfo something is wrong...
-    if (!sinfo)
-    {
+    if (!sinfo) {
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror(_("Found SOUNDSTREAMBLOCK tag w/out preceding "
                 "SOUNDSTREAMHEAD"));
@@ -81,8 +80,7 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     unsigned int sampleCount = sinfo->getSampleCount();
 
     // MP3 format blocks have additional info
-    if (format == media::AUDIO_CODEC_MP3)
-    {
+    if (format == media::AUDIO_CODEC_MP3) {
         in.ensureBytes(4);
         // FIXME: use these values !
         unsigned int samplesCount = in.read_u16(); UNUSED(samplesCount);
@@ -91,8 +89,7 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     }
 
     const unsigned int dataLength = in.get_tag_end_position() - in.tell();
-    if ( ! dataLength )
-    {
+    if (!dataLength) {
         IF_VERBOSE_MALFORMED_SWF(
             LOG_ONCE(log_swferror("Empty SOUNDSTREAMBLOCK tag, seems common "
                     "waste of space"));
@@ -104,8 +101,7 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     const unsigned int bytesRead = in.read(reinterpret_cast<char*>(data),
             dataLength);
     
-    if (bytesRead < dataLength)
-    {
+    if (bytesRead < dataLength) {
         delete [] data;
         throw ParserException(_("Tag boundary reported past end of stream!"));
     }
@@ -115,12 +111,11 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     //
     // ownership of 'data' is transferred here
     sound::sound_handler::StreamBlockId blockId =
-        handler->addSoundBlock(data, dataLength, sampleCount, streamId);
+        handler->addSoundBlock(data, dataLength, sampleCount, sId);
 
-    // TODO: log_parse ?
+    boost::intrusive_ptr<ControlTag> s(new StreamSoundBlockTag(sId, blockId));
 
-    StreamSoundBlockTag* ssst = new StreamSoundBlockTag(streamId, blockId);
-    m.addControlTag(ssst); // ownership is transferred to movie_definition
+    m.addControlTag(s); 
 }
 
 } // namespace gnash::SWF
diff --git a/libcore/swf/SymbolClassTag.h b/libcore/swf/SymbolClassTag.h
index f571f32..4c3e73d 100644
--- a/libcore/swf/SymbolClassTag.h
+++ b/libcore/swf/SymbolClassTag.h
@@ -75,7 +75,7 @@ public:
                        log_parse("Symbol %u name %s, character %u", i, name, 
id);
                        );
             
-            SymbolClassTag* st = new SymbolClassTag(name);
+            boost::intrusive_ptr<SymbolClassTag> st(new SymbolClassTag(name));
                        
             if (id == 0) m.addControlTag(st);
             else {

http://git.savannah.gnu.org/cgit//commit/?id=e4101499661abdf3f8700932c7f5e2f33c20a86a


commit e4101499661abdf3f8700932c7f5e2f33c20a86a
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 16 12:57:59 2010 +0100

    Drop unneeded include.

diff --git a/libbase/smart_ptr.h b/libbase/smart_ptr.h
index 00f6a50..6557236 100644
--- a/libbase/smart_ptr.h
+++ b/libbase/smart_ptr.h
@@ -27,7 +27,6 @@
 #define SMART_PTR_H
 
 #include "ref_counted.h"
-#include <typeinfo>
 
 // TODO: drop all users of this macro, we _are_ using GC now
 #define GNASH_USE_GC 1

http://git.savannah.gnu.org/cgit//commit/?id=506f23ba4e88ff448a54e0ee96fb072c446d5369


commit 506f23ba4e88ff448a54e0ee96fb072c446d5369
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 16 12:20:26 2010 +0100

    Clean up on error.

diff --git a/libcore/swf/StreamSoundBlockTag.cpp 
b/libcore/swf/StreamSoundBlockTag.cpp
index 4ea5dab..a21b6f9 100644
--- a/libcore/swf/StreamSoundBlockTag.cpp
+++ b/libcore/swf/StreamSoundBlockTag.cpp
@@ -100,12 +100,13 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
         return;
     }
 
-    unsigned char *data = new unsigned char[dataLength];
+    unsigned char* data = new unsigned char[dataLength];
     const unsigned int bytesRead = in.read(reinterpret_cast<char*>(data),
             dataLength);
     
     if (bytesRead < dataLength)
     {
+        delete [] data;
         throw ParserException(_("Tag boundary reported past end of stream!"));
     }
 
@@ -113,7 +114,6 @@ StreamSoundBlockTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     // for later "start playing from this frame" events.
     //
     // ownership of 'data' is transferred here
-    //
     sound::sound_handler::StreamBlockId blockId =
         handler->addSoundBlock(data, dataLength, sampleCount, streamId);
 

-----------------------------------------------------------------------

Summary of changes:
 libbase/ref_counted.h                         |   13 +++-----
 libbase/smart_ptr.h                           |    1 -
 libcore/parser/SWFMovieDefinition.h           |    2 +-
 libcore/parser/movie_definition.h             |    6 +---
 libcore/parser/sprite_definition.h            |    2 +-
 libcore/swf/DefineSceneAndFrameLabelDataTag.h |    4 +-
 libcore/swf/DoABCTag.h                        |    2 +-
 libcore/swf/DoActionTag.h                     |    8 +++---
 libcore/swf/DoInitActionTag.h                 |   13 ++++-----
 libcore/swf/ExportAssetsTag.h                 |    4 +-
 libcore/swf/ImportAssetsTag.h                 |    4 +-
 libcore/swf/PlaceObject2Tag.cpp               |    3 +-
 libcore/swf/RemoveObjectTag.cpp               |    6 ++--
 libcore/swf/ScriptLimitsTag.h                 |    4 +-
 libcore/swf/SetBackgroundColorTag.h           |    2 +-
 libcore/swf/StartSoundTag.cpp                 |   18 +++++++-----
 libcore/swf/StreamSoundBlockTag.cpp           |   37 +++++++++++--------------
 libcore/swf/SymbolClassTag.h                  |    2 +-
 18 files changed, 59 insertions(+), 72 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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