[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s... |
Date: |
Tue, 07 Nov 2006 17:16:19 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/11/07 17:16:19
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 NetStream.cpp
Log message:
(Fwd port) - NOTE: could not test as head is not buildable for me now
* 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&r1=1.1547&r2=1.1548
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/ref_counted.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/smart_ptr.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&r1=1.68&r2=1.69
http://cvs.savannah.gnu.org/viewcvs/gnash/server/mouse_button_state.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.15&r2=1.16
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1547
retrieving revision 1.1548
diff -u -b -r1.1547 -r1.1548
--- ChangeLog 7 Nov 2006 16:51:29 -0000 1.1547
+++ ChangeLog 7 Nov 2006 17:16:18 -0000 1.1548
@@ -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.
@@ -11,7 +28,8 @@
* libbase\URL.cpp: #include <sys/param.h> removed for win32
* server\asobj\NetStream.cpp: a bit cleunup
-2006-11-06 Udo Giacomozzi <address@hidden>
+
+2006-11-07 Udo Giacomozzi <address@hidden>
* backend/render_handler.h, gui/gui.cpp, gui/gui.h:
Further described invalidated bounds
Index: libbase/ref_counted.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/ref_counted.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libbase/ref_counted.h 29 Oct 2006 18:34:11 -0000 1.2
+++ libbase/ref_counted.h 7 Nov 2006 17:16:18 -0000 1.3
@@ -17,7 +17,7 @@
//
//
-/* $Id: ref_counted.h,v 1.2 2006/10/29 18:34:11 rsavoye Exp $ */
+/* $Id: ref_counted.h,v 1.3 2006/11/07 17:16:18 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.12
diff -u -b -r1.11 -r1.12
--- libbase/smart_ptr.h 24 Oct 2006 09:23:30 -0000 1.11
+++ libbase/smart_ptr.h 7 Nov 2006 17:16:18 -0000 1.12
@@ -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.12 2006/11/07 17:16:18 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.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/button_character_instance.cpp 4 Nov 2006 14:29:30 -0000
1.13
+++ server/button_character_instance.cpp 7 Nov 2006 17:16:18 -0000
1.14
@@ -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];
@@ -481,9 +479,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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/character.cpp 3 Nov 2006 14:03:37 -0000 1.9
+++ server/character.cpp 7 Nov 2006 17:16:18 -0000 1.10
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.cpp,v 1.9 2006/11/03 14:03:37 strk Exp $ */
+/* $Id: character.cpp,v 1.10 2006/11/07 17:16:18 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.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/character.h 3 Nov 2006 14:03:37 -0000 1.25
+++ server/character.h 7 Nov 2006 17:16:18 -0000 1.26
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.h,v 1.25 2006/11/03 14:03:37 strk Exp $ */
+/* $Id: character.h,v 1.26 2006/11/07 17:16:18 strk Exp $ */
#ifndef GNASH_CHARACTER_H
#define GNASH_CHARACTER_H
@@ -80,7 +80,7 @@
bool m_visible;
- character* m_parent;
+ smart_ptr<character> m_parent;
/// Implement mouse-dragging for this movie.
void do_mouse_drag();
@@ -115,7 +115,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();
}
@@ -127,7 +127,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.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/dlist.cpp 3 Nov 2006 14:03:37 -0000 1.34
+++ server/dlist.cpp 7 Nov 2006 17:16:18 -0000 1.35
@@ -596,6 +596,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.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/generic_character.h 29 Oct 2006 18:34:11 -0000 1.14
+++ server/generic_character.h 7 Nov 2006 17:16:18 -0000 1.15
@@ -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.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- server/impl.cpp 4 Nov 2006 10:39:07 -0000 1.68
+++ server/impl.cpp 7 Nov 2006 17:16:18 -0000 1.69
@@ -18,7 +18,7 @@
//
//
-/* $Id: impl.cpp,v 1.68 2006/11/04 10:39:07 nihilus Exp $ */
+/* $Id: impl.cpp,v 1.69 2006/11/07 17:16:18 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -418,7 +418,7 @@
return NULL;
}
- ret->add_ref();
+ //ret->add_ref(); // would leak forever
return ret;
}
@@ -504,7 +504,8 @@
s_no_recurse_while_loading = false;
- m->add_ref();
+ //m->add_ref();
+ /
return m;
}
#endif
@@ -654,7 +655,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();
}
}
@@ -672,7 +673,7 @@
s_movie_library.add(cache_label, mov);
}
- mov->add_ref();
+ // mov->add_ref(); // let caller add the ref if needed
return mov;
}
@@ -685,7 +686,7 @@
if (m != NULL)
{
// Return cached movie instance.
- m->add_ref();
+ // m->add_ref(); // let caller increment refcount
return m.get_ptr();
}
}
@@ -704,7 +705,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.3
diff -u -b -r1.2 -r1.3
--- server/mouse_button_state.h 23 Oct 2006 13:31:57 -0000 1.2
+++ server/mouse_button_state.h 7 Nov 2006 17:16:18 -0000 1.3
@@ -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.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/movie_root.cpp 29 Oct 2006 18:34:11 -0000 1.22
+++ server/movie_root.cpp 7 Nov 2006 17:16:18 -0000 1.23
@@ -193,6 +193,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.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- server/sprite_instance.cpp 7 Nov 2006 16:51:29 -0000 1.76
+++ server/sprite_instance.cpp 7 Nov 2006 17:16:18 -0000 1.77
@@ -1078,8 +1078,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.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/Key.cpp 29 Oct 2006 18:34:12 -0000 1.2
+++ server/asobj/Key.cpp 7 Nov 2006 17:16:19 -0000 1.3
@@ -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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/asobj/Key.h 29 Oct 2006 18:34:12 -0000 1.6
+++ server/asobj/Key.h 7 Nov 2006 17:16:19 -0000 1.7
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: Key.h,v 1.6 2006/10/29 18:34:12 rsavoye Exp $ */
+/* $Id: Key.h,v 1.7 2006/11/07 17:16:19 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);
Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/asobj/NetStream.cpp 7 Nov 2006 16:38:38 -0000 1.15
+++ server/asobj/NetStream.cpp 7 Nov 2006 17:16:19 -0000 1.16
@@ -18,7 +18,7 @@
//
//
-/* $Id: NetStream.cpp,v 1.15 2006/11/07 16:38:38 alexeev Exp $ */
+/* $Id: NetStream.cpp,v 1.16 2006/11/07 17:16:19 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -62,7 +62,7 @@
m_yuv(NULL),
m_video_clock(0)
{
- m_thread.p = NULL;
+ //m_thread.p = NULL;
}
NetStream::~NetStream()
@@ -76,8 +76,9 @@
m_go = false;
// wait till thread is complete before main continues
- if (m_thread.p) pthread_join(m_thread, NULL);
- m_thread.p = NULL;
+ pthread_join(m_thread, NULL);
+ //if (m_thread.p) pthread_join(m_thread, NULL);
+ //m_thread.p = NULL;
sound_handler* s = get_sound_handler();
if (s)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s...,
Sandro Santilli <=