gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s... [relea


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s... [release_0_7_2]
Date: Tue, 07 Nov 2006 16:24:04 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         release_0_7_2
Changes by:     Sandro Santilli <strk>  06/11/07 16:24:04

Modified files:
        .              : ChangeLog 
        libbase        : ref_counted.h smart_ptr.h 
        server         : button_character_instance.cpp character.cpp 
                         character.h dlist.cpp generic_character.h 
                         impl.cpp mouse_button_state.h movie_root.cpp 
                         sprite_instance.cpp 
        server/asobj   : Key.cpp Key.h 

Log message:
                * libbase/ref_counted.h: drop support for weak proxies.
                * libbase/smart_ptr.h: drop all but smart_ptr
                * server/button_character_instance.cpp (on_button_event):
                  simplify access to our environment.
                * server/: character.{h,cpp}, generic_character.h, 
sprite_instance.cpp:
                  store our parent in a smart_ptr<> (rather then a dumb one)
                * server/impl.cpp: don't force refcount increment on newly
                  created movies (or we'll never get rid of them)
                * server/mouse_button_state.h: store active and topmost
                  entities in a smart_ptr<> (rather then weak_ptr<>); it
                  might introduce minor behavioural bugs, but it's safer.
                * server/movie_root.cpp: minor assertion checking
                * server/asobj/Key.{h,cpp}: store smart_ptr<> elements
                  in listeners vector (rather then weak_ptr<>).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.1412.2.108&r2=1.1412.2.109
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/ref_counted.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/smart_ptr.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.11&r2=1.11.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.10.2.1&r2=1.10.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.7.2.1&r2=1.7.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.23.2.1&r2=1.23.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.31.2.2&r2=1.31.2.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.13.2.1&r2=1.13.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.64.2.2&r2=1.64.2.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/mouse_button_state.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.2&r2=1.2.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.20.2.1&r2=1.20.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.69.2.5&r2=1.69.2.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.5.2.1&r2=1.5.2.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1412.2.108
retrieving revision 1.1412.2.109
diff -u -b -r1.1412.2.108 -r1.1412.2.109
--- ChangeLog   7 Nov 2006 13:11:17 -0000       1.1412.2.108
+++ ChangeLog   7 Nov 2006 16:24:03 -0000       1.1412.2.109
@@ -1,5 +1,22 @@
 2006-11-07 Sandro Santilli <address@hidden>
 
+        * libbase/ref_counted.h: drop support for weak proxies.
+        * libbase/smart_ptr.h: drop all but smart_ptr
+        * server/button_character_instance.cpp (on_button_event):
+          simplify access to our environment.
+        * server/: character.{h,cpp}, generic_character.h, sprite_instance.cpp:
+          store our parent in a smart_ptr<> (rather then a dumb one)
+        * server/impl.cpp: don't force refcount increment on newly
+          created movies (or we'll never get rid of them)
+        * server/mouse_button_state.h: store active and topmost
+          entities in a smart_ptr<> (rather then weak_ptr<>); it
+          might introduce minor behavioural bugs, but it's safer.
+        * server/movie_root.cpp: minor assertion checking
+        * server/asobj/Key.{h,cpp}: store smart_ptr<> elements
+          in listeners vector (rather then weak_ptr<>).
+
+2006-11-07 Sandro Santilli <address@hidden>
+
        * libbase/log.h: don't warn about ASCODING errors by default
        * server/sprite_instance.cpp (sprite_hit_test): warn
          only once about hitTest not being implemented.

Index: libbase/ref_counted.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/ref_counted.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- libbase/ref_counted.h       30 Oct 2006 14:28:47 -0000      1.1.2.1
+++ libbase/ref_counted.h       7 Nov 2006 16:24:03 -0000       1.1.2.2
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: ref_counted.h,v 1.1.2.1 2006/10/30 14:28:47 rsavoye Exp $ */
+/* $Id: ref_counted.h,v 1.1.2.2 2006/11/07 16:24:03 strk Exp $ */
 
 #ifndef GNASH_REF_COUNTED_H
 #define GNASH_REF_COUNTED_H
@@ -43,23 +43,20 @@
 {
 private:
        mutable int             m_ref_count;
-       mutable weak_proxy*     m_weak_proxy;
 public:
        ref_counted()
        :
-       m_ref_count(0),
-       m_weak_proxy(0)
+       m_ref_count(0)
        {
        }
+
        virtual ~ref_counted()
        {
        assert(m_ref_count == 0);
-       if (m_weak_proxy){
-               m_weak_proxy->notify_object_died();
-               m_weak_proxy->drop_ref();
-               }
        }
-       void    add_ref() const {
+
+       void    add_ref() const
+       {
        assert(m_ref_count >= 0);
        m_ref_count++;
        }
@@ -73,18 +70,6 @@
        }
 
        int     get_ref_count() const { return m_ref_count; }
-       weak_proxy*     get_weak_proxy() const {
-       
-       assert(m_ref_count > 0);        // By rights, somebody should be 
holding a ref to us.
-       if (m_weak_proxy == NULL)       // Host calls this to register a 
function for progress bar handling
-                                       // during loading movies.
-
-               {
-               m_weak_proxy = new weak_proxy;
-               m_weak_proxy->add_ref();
-               }
-       return m_weak_proxy;
-       }
 };
 
 } // namespace gnash

Index: libbase/smart_ptr.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/smart_ptr.h,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -b -r1.11 -r1.11.2.1
--- libbase/smart_ptr.h 24 Oct 2006 09:23:30 -0000      1.11
+++ libbase/smart_ptr.h 7 Nov 2006 16:24:03 -0000       1.11.2.1
@@ -9,7 +9,7 @@
 // although the nice thing about templates is that no particular
 // ref-counted class is mandated.
 
-/* $Id: smart_ptr.h,v 1.11 2006/10/24 09:23:30 strk Exp $ */
+/* $Id: smart_ptr.h,v 1.11.2.1 2006/11/07 16:24:03 strk Exp $ */
 
 #ifndef SMART_PTR_H
 #define SMART_PTR_H
@@ -56,10 +56,9 @@
                }
        }
 
-//     operator bool() const { return m_ptr != NULL; }
+       //operator bool() const { return m_ptr != NULL; }
        void    operator=(const smart_ptr<T>& s) { set_ref(s.m_ptr); }
        void    operator=(T* ptr) { set_ref(ptr); }
-//     void    operator=(const weak_ptr<T>& w);
        T*      operator->() const { assert(m_ptr); return m_ptr; }
        const T& operator*() const { assert(m_ptr); return *m_ptr; }
        T& operator*() { assert(m_ptr); return *m_ptr; }
@@ -89,294 +88,9 @@
                }
        }
 
-//     friend weak_ptr;
-
-       T*      m_ptr;
-};
-
-
-/// Helper for making objects that can have weak_ptr's.
-class DSOLOCAL weak_proxy
-{
-public:
-       weak_proxy()
-               :
-               m_ref_count(0),
-               m_alive(true)
-       {
-       }
-
-       /// weak_ptr's call this to determine if their pointer is valid or not.
-       bool    is_alive() const { return m_alive; }
-
-       /// Only the actual object should call this.
-       void    notify_object_died() { m_alive = false; }
-
-       void    add_ref()
-       {
-               assert(m_ref_count >= 0);
-               m_ref_count++;
-       }
-       void    drop_ref()
-       {
-               assert(m_ref_count > 0);
-
-               m_ref_count--;
-               if (m_ref_count == 0)
-               {
-                       // Now we die.
-                       delete this;
-               }
-       }
-
-private:
-       // Don't use these.
-       weak_proxy(const weak_proxy& /*w*/) { assert(0); }
-       void    operator=(const weak_proxy& /*w*/) { assert(0); }
-
-       int     m_ref_count;
-       bool    m_alive;
-};
-
-
-/// A weak pointer points at an object, but the object may be deleted
-/// at any time, in which case the weak pointer automatically becomes
-/// NULL.  The only way to use a weak pointer is by converting it to a
-/// strong pointer (i.e. for temporary use).
-///
-/// The class pointed to must have a "weak_proxy* get_weak_proxy()" method.
-///
-/// Usage idiom:
-///
-/// if (smart_ptr<my_type> ptr = m_weak_ptr_to_my_type) { ... use 
ptr->whatever() safely in here ... }
-///
-template<class T>
-class DSOEXPORT weak_ptr
-{
-public:
-       weak_ptr()
-               :
-               m_ptr(0)
-       {
-       }
-
-       weak_ptr(T* ptr)
-               :
-               m_ptr(0)
-       {
-               operator=(ptr);
-       }
-
-       weak_ptr(const smart_ptr<T>& ptr)
-       {
-               operator=(ptr.get_ptr());
-       }
-       
-       ~weak_ptr()
-       {
-       }
-       
-       // Default constructor and assignment from weak_ptr<T> are OK.
-
-       void    operator=(T* ptr)
-       {
-               m_ptr = ptr;
-               if (m_ptr)
-               {
-                       m_proxy = m_ptr->get_weak_proxy();
-                       assert(m_proxy != NULL);
-                       assert(m_proxy->is_alive());
-               }
-               else
-               {
-                       m_proxy = NULL;
-               }
-       }
-
-       void    operator=(const smart_ptr<T>& ptr) { operator=(ptr.get_ptr()); }
-
-       // Conversion to smart_ptr.
-       operator smart_ptr<T>() const
-       {
-               check_proxy();
-               return smart_ptr<T>(m_ptr);
-       }
-
-       bool    operator==(T* ptr) const { check_proxy(); return m_ptr == ptr; }
-       bool    operator==(const smart_ptr<T>& ptr) const { check_proxy(); 
return m_ptr == ptr.get_ptr(); }
-
-       bool    operator!=(const smart_ptr<T>& ptr) const { check_proxy(); 
return m_ptr != ptr.get_ptr(); }
-
-private:
-       void check_proxy() const
-       // Set m_ptr to NULL if the object died.
-       {
-               if (m_ptr)
-               {
-                       assert(m_proxy != NULL);
-                       if (m_proxy->is_alive() == false)
-                       {
-                               // Underlying object went away.
-                               m_proxy = NULL;
-                               m_ptr = NULL;
-                       }
-               }
-       }
-
-       mutable smart_ptr<weak_proxy>   m_proxy;
-       mutable T*      m_ptr;
-};
-
-
-
-/// \brief noref_ptr Pointer without ref counting
-/// noref_ptr does not count references; the pointer is deleted when the object
-/// goes out of scope.
-//
-// TODO: noref_ptr<classname> ptr = new classname(); currently throws a 
compiler
-//       error. Figure out why, and fix it!
-//
-// XXX:  When a function returns (by reference) a noref_ptr, if we choose to
-//       assign it like so:
-//         noref_ptr<classname> ptr = someclass.get_classname_norefptr();
-//       Does that mean the ownership of ptr.m_ptr will transfer to ptr?
-
-template<class T>
-    class DSOEXPORT noref_ptr
-{
-  public:
-    noref_ptr(T* ptr)
-    : m_ptr(ptr)
-    {
-    }
-
-    noref_ptr()
-    : m_ptr(NULL)
-    {
-    }
-
-    noref_ptr(noref_ptr<T>& s)
-    : m_ptr(s.disown())
-    {
-    }
-
-    ~noref_ptr()
-    {
-        delete m_ptr;
-    }
-
-    noref_ptr<T>&
-    disown()
-    {
-        T* tmp = m_ptr;
-        m_ptr  = NULL;
-
-        return tmp;
-    }
-
-    // Transfers "ownwership" of anoter pointer to |this|.
-    noref_ptr<T>&
-    operator=(noref_ptr<T>& s)
-    {
-        delete m_ptr;
-        m_ptr = s.m_ptr;
-
-        return s.disown();
-    }
-
-    noref_ptr<T>&
-    operator=(T* ptr)
-    {
-        delete m_ptr;
-        m_ptr = ptr;
-        return m_ptr;
-    }
-
-    T*
-    operator->() const
-    {
-        assert(m_ptr);
-        return m_ptr;
-    }
-    
-    operator T*() const
-    {
-        return operator->();
-    }
-
-    T*
-    get_ptr() const
-    {
-        return operator->();
-    }
-
-    bool
-    operator==(const noref_ptr<T>& p) const
-    {
-        return m_ptr == p.m_ptr;
-    }
-
-    bool
-    operator!=(const smart_ptr<T>& p) const
-    {
-        return m_ptr != p.m_ptr;
-    }
-
-    bool
-    operator==(T* p) const 
-    {
-        return m_ptr == p;
-    }
-
-    bool
-    operator!=(T* p) const
-    {
-        return m_ptr != p;
-    }
-
-  private:
     T*  m_ptr;
 };
 
-// Example ref_counted class:
-// 
-#if 0
-ref_counted
-{
-       mutable int     m_ref_count
-       mutable weak_proxy* m_weak_proxy;
-
-       ref_counted()
-               :
-               m_ref_count(0),
-               m_weak_proxy(0)
-       {
-       }
-
-       // @@ usual ref-counted stuff here for add_ref() and drop_ref()
-
-       virtual ~ref_counted()
-       {
-               assert(m_ref_count == 0);
-               if (m_weak_proxy)
-               {
-                       m_weak_proxy->notify_object_died();
-                       m_weak_proxy->drop_ref();
-                       m_weak_proxy = NULL;
-               }
-       }
-
-       weak_proxy* get_weak_proxy() const
-       {
-               if (m_weak_proxy == NULL)
-               {
-                       m_weak_proxy = new weak_proxy;
-                       m_weak_proxy->add_ref();
-               }
-       }
-};
-#endif // 0
-
 
 #endif // SMART_PTR_H
 

Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -b -r1.10.2.1 -r1.10.2.2
--- server/button_character_instance.cpp        4 Nov 2006 00:55:38 -0000       
1.10.2.1
+++ server/button_character_instance.cpp        7 Nov 2006 16:24:04 -0000       
1.10.2.2
@@ -158,8 +158,6 @@
        int r, r_num =  m_def->m_button_records.size();
        m_record_character.resize(r_num);
 
-       movie_definition* movie_def = 
parent->get_root_movie()->get_movie_definition();
-
        for (r = 0; r < r_num; r++)
        {
                button_record& bdef = m_def->m_button_records[r];
@@ -472,9 +470,7 @@
                        {
                                action_buffer* ab = 
m_def->m_button_actions[i].m_actions[j];
                                assert(ab);
-                               sprite_instance* si = 
dynamic_cast<sprite_instance*>(get_parent());
-                               assert(si);
-                               ActionExec exec(*ab, si->get_environment());
+                               ActionExec exec(*ab, get_environment());
                                exec();
                                
                                //get_parent()->add_action_buffer(ab);

Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -b -r1.7.2.1 -r1.7.2.2
--- server/character.cpp        30 Oct 2006 14:28:49 -0000      1.7.2.1
+++ server/character.cpp        7 Nov 2006 16:24:04 -0000       1.7.2.2
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.cpp,v 1.7.2.1 2006/10/30 14:28:49 rsavoye Exp $ */
+/* $Id: character.cpp,v 1.7.2.2 2006/11/07 16:24:04 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -58,7 +58,7 @@
                    world_mat.transform_by_inverse(&local_mouse, world_mouse);
 
                    matrix      parent_world_mat;
-                   if (m_parent)
+                   if (m_parent != NULL)
                        {
                            parent_world_mat = m_parent->get_world_matrix();
                        }
@@ -84,7 +84,7 @@
 character::get_world_matrix() const
 {
        matrix m;
-       if (m_parent)
+       if (m_parent != NULL)
        {
            m = m_parent->get_world_matrix();
        }
@@ -97,7 +97,7 @@
 character::get_world_cxform() const
 {
        cxform  m;
-       if (m_parent)
+       if (m_parent != NULL)
        {
            m = m_parent->get_world_cxform();
        }
@@ -109,19 +109,24 @@
 void
 character::get_drag_state(drag_state* st)
 {
-       assert(m_parent);
+       assert(m_parent != NULL);
+       assert(m_parent->get_ref_count() > 0);
        m_parent->get_drag_state(st);
 }
 
 sprite_instance*
 character::get_root_movie()
 {
+       assert(m_parent != NULL);
+       assert(m_parent->get_ref_count() > 0);
        return m_parent->get_root_movie();
 }
 
 void
 character::get_mouse_state(int* x, int* y, int* buttons)
 {
+       assert(m_parent != NULL);
+       assert(m_parent->get_ref_count() > 0);
        get_parent()->get_mouse_state(x, y, buttons);
 }
 

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.23.2.1
retrieving revision 1.23.2.2
diff -u -b -r1.23.2.1 -r1.23.2.2
--- server/character.h  30 Oct 2006 14:28:49 -0000      1.23.2.1
+++ server/character.h  7 Nov 2006 16:24:04 -0000       1.23.2.2
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.h,v 1.23.2.1 2006/10/30 14:28:49 rsavoye Exp $ */
+/* $Id: character.h,v 1.23.2.2 2006/11/07 16:24:04 strk Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -67,7 +67,7 @@
 
        bool m_visible;
 
-       character* m_parent;
+       smart_ptr<character> m_parent;
 
        /// Implement mouse-dragging for this movie.
        void do_mouse_drag();
@@ -102,7 +102,7 @@
                // sprite_instance must override this
                // and any other character will have
                // a parent!
-               assert(m_parent);
+               assert(m_parent != NULL);
                return m_parent->get_environment();
        }
 
@@ -114,7 +114,7 @@
        /// the character has no parent.
        character* get_parent() const
        {
-                       return m_parent;
+                       return m_parent.get_ptr();
        }
 
     // for extern movie

Index: server/dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.31.2.2
retrieving revision 1.31.2.3
diff -u -b -r1.31.2.2 -r1.31.2.3
--- server/dlist.cpp    31 Oct 2006 12:54:46 -0000      1.31.2.2
+++ server/dlist.cpp    7 Nov 2006 16:24:04 -0000       1.31.2.3
@@ -591,6 +591,7 @@
                it != endIt; ++it)
        {
     DisplayItem& dobj = *it;
+    assert(dobj->get_ref_count() > 0);
     dobj->get_invalidated_bounds(bounds, force);
        }
        

Index: server/generic_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/generic_character.h,v
retrieving revision 1.13.2.1
retrieving revision 1.13.2.2
diff -u -b -r1.13.2.1 -r1.13.2.2
--- server/generic_character.h  30 Oct 2006 14:28:49 -0000      1.13.2.1
+++ server/generic_character.h  7 Nov 2006 16:24:04 -0000       1.13.2.2
@@ -58,7 +58,7 @@
        }
 
        virtual bool can_handle_mouse_event()   {
-               assert(m_parent);
+               assert(m_parent != NULL);
                return m_parent->can_handle_mouse_event();
        }
 

Index: server/impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/impl.cpp,v
retrieving revision 1.64.2.2
retrieving revision 1.64.2.3
diff -u -b -r1.64.2.2 -r1.64.2.3
--- server/impl.cpp     4 Nov 2006 01:31:44 -0000       1.64.2.2
+++ server/impl.cpp     7 Nov 2006 16:24:04 -0000       1.64.2.3
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: impl.cpp,v 1.64.2.2 2006/11/04 01:31:44 strk Exp $ */
+/* $Id: impl.cpp,v 1.64.2.3 2006/11/07 16:24:04 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -421,7 +421,7 @@
                return NULL;
        }
 
-       ret->add_ref();
+       //ret->add_ref(); // would leak forever
 
        return ret;
 }
@@ -507,7 +507,8 @@
 
     s_no_recurse_while_loading = false;
 
-    m->add_ref();
+    //m->add_ref();
+    /
     return m;
 }
 #endif
@@ -657,7 +658,7 @@
            {
                log_msg(" movie already in library");
                // Return cached movie.
-               m->add_ref();
+               // m->add_ref(); let caller add the ref, if needed
                return m.get_ptr();
            }
     }
@@ -675,7 +676,7 @@
            s_movie_library.add(cache_label, mov);
        }
 
-    mov->add_ref();
+    // mov->add_ref(); // let caller add the ref if needed
     return mov;
 }
 
@@ -688,7 +689,7 @@
        if (m != NULL)
            {
                // Return cached movie instance.
-               m->add_ref();
+               // m->add_ref(); // let caller increment refcount
                return m.get_ptr();
            }
     }
@@ -707,7 +708,7 @@
            s_movie_library_inst.add(md, mov);
        }
 
-    mov->add_ref();
+    // mov->add_ref(); // let caller increment refcount
     return mov;
 }
 

Index: server/mouse_button_state.h
===================================================================
RCS file: /sources/gnash/gnash/server/mouse_button_state.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- server/mouse_button_state.h 23 Oct 2006 13:31:57 -0000      1.2
+++ server/mouse_button_state.h 7 Nov 2006 16:24:04 -0000       1.2.2.1
@@ -27,10 +27,10 @@
 public:
 
        /// entity that currently owns the mouse pointer
-       weak_ptr<movie> m_active_entity;
+       smart_ptr<movie>        m_active_entity;
 
        /// what's underneath the mouse right now
-       weak_ptr<movie> m_topmost_entity;
+       smart_ptr<movie>        m_topmost_entity;
 
        /// previous state of mouse button
        bool    m_mouse_button_state_last;      

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.20.2.1
retrieving revision 1.20.2.2
diff -u -b -r1.20.2.1 -r1.20.2.2
--- server/movie_root.cpp       30 Oct 2006 14:28:49 -0000      1.20.2.1
+++ server/movie_root.cpp       7 Nov 2006 16:24:04 -0000       1.20.2.2
@@ -192,6 +192,7 @@
                                // onDragOut
                                if (active_entity != NULL)
                                {
+                                       assert(active_entity->get_ref_count() > 
1); // we are NOT the only object holder !
                                        
active_entity->on_button_event(event_id::DRAG_OUT);
                                        // TODO: have on_button_event return
                                        //       wheter the action must trigger

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.69.2.5
retrieving revision 1.69.2.6
diff -u -b -r1.69.2.5 -r1.69.2.6
--- server/sprite_instance.cpp  7 Nov 2006 13:11:17 -0000       1.69.2.5
+++ server/sprite_instance.cpp  7 Nov 2006 16:24:04 -0000       1.69.2.6
@@ -991,8 +991,8 @@
                }
                else
                {
-                       assert(dynamic_cast<as_object*>(m_parent));
-                       val->set_as_object(static_cast<as_object*>(m_parent));
+                       assert(dynamic_cast<as_object*>(get_parent()));
+                       
val->set_as_object(static_cast<as_object*>(get_parent()));
                        return true;
                }
        }

Index: server/asobj/Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- server/asobj/Key.cpp        30 Oct 2006 14:28:49 -0000      1.1.2.1
+++ server/asobj/Key.cpp        7 Nov 2006 16:24:04 -0000       1.1.2.2
@@ -178,7 +178,7 @@
 key_as_object::notify_listeners(const tu_stringi& funcname)
 {
     // Notify listeners.
-    for (std::vector<weak_ptr<as_object> >::iterator iter = 
m_listeners.begin();
+    for (std::vector<smart_ptr<as_object> >::iterator iter = 
m_listeners.begin();
          iter != m_listeners.end(); ++iter) {
       if (*iter == NULL)
         continue;
@@ -191,46 +191,14 @@
     }
 }
 
-#if 0
-// XXXbjacques
-//   Well, I think cleanup_listeners() is a bad idea for several reasons:
-//   1) Since m_listeners is a vector of weak pointers, it is no way guaranteed
-//      that m_listeners won't be "dirty" immediately after cleanup_listeners()
-//      is called. Any users of m_listeners will have to NULL check pointers
-//      (and add a ref) retrieved from m_listeners anyway.
-//   2) std::vector.erase() is a potentially expensive operation.
-//   3) std::vector.erase() does no reallocation. We gain no memory by doing
-//      this.
-//   4) Thread safety may be an issue (due to the change of m_listeners.size(),
-//      as a result of std::vector.erase()). We really, really should be using
-//      iterators instead of size()/indicing to iterate these vectors, though.
-
-void
-key_as_object::cleanup_listeners()
-{
-           for (int i = m_listeners.size() - 1; i >= 0; i--)
-               {
-                   if (m_listeners[i] == NULL)
-                       {
-                           m_listeners.erase(m_listeners.begin() + i);
-                       }
-               }
-}
-
-#endif
-
 void
 key_as_object::add_listener(as_object* listener)
 {
-#if 0
-//XXXbjacques: see comment above
-           cleanup_listeners();
-#endif
 
     // Should we bother doing this every time someone calls add_listener(),
     // or should we perhaps skip this check and use unique later?
-    std::vector<weak_ptr<as_object> >::const_iterator end = m_listeners.end();
-    for (std::vector<weak_ptr<as_object> >::iterator iter = 
m_listeners.begin();
+    std::vector<smart_ptr<as_object> >::const_iterator end = m_listeners.end();
+    for (std::vector<smart_ptr<as_object> >::iterator iter = 
m_listeners.begin();
          iter != end; ++iter) {
       if (*iter == NULL) {
         // Already in the list.
@@ -244,12 +212,8 @@
 void
 key_as_object::remove_listener(as_object* listener)
 {
-#if 0
-XXXbjacques: see above comment
-           cleanup_listeners();
-#endif
 
-  for (std::vector<weak_ptr<as_object> >::iterator iter = m_listeners.begin(); 
iter != m_listeners.end(); )
+  for (std::vector<smart_ptr<as_object> >::iterator iter = 
m_listeners.begin(); iter != m_listeners.end(); )
        {
     if (*iter == listener)
                {

Index: server/asobj/Key.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.h,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -b -r1.5.2.1 -r1.5.2.2
--- server/asobj/Key.h  30 Oct 2006 14:28:49 -0000      1.5.2.1
+++ server/asobj/Key.h  7 Nov 2006 16:24:04 -0000       1.5.2.2
@@ -16,7 +16,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: Key.h,v 1.5.2.1 2006/10/30 14:28:49 rsavoye Exp $ */
+/* $Id: Key.h,v 1.5.2.2 2006/11/07 16:24:04 strk Exp $ */
 
 #ifndef __KEY_H__
 #define __KEY_H__
@@ -95,7 +95,7 @@
 
 private:
        uint8_t m_keymap[key::KEYCOUNT / 8 + 1];        // bit-array
-       std::vector<weak_ptr<as_object> >       m_listeners;
+       std::vector<smart_ptr<as_object> >      m_listeners;
        int     m_last_key_pressed;
 
        void notify_listeners(const tu_stringi& funcname);




reply via email to

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