Author: toshok
Date: 2007-10-09 15:13:20 -0400 (Tue, 09 Oct 2007)
New Revision: 87213
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/brush.cpp
trunk/moon/src/clock.cpp
trunk/moon/src/collection.cpp
trunk/moon/src/dependencyobject.cpp
trunk/moon/src/dependencyobject.h
trunk/moon/src/frameworkelement.cpp
trunk/moon/src/geometry.cpp
trunk/moon/src/media.cpp
trunk/moon/src/shape.cpp
trunk/moon/src/text.cpp
trunk/moon/src/transform.cpp
trunk/moon/src/trigger.cpp
trunk/moon/src/uielement.cpp
Log:
2007-10-09 Chris Toshok <[EMAIL PROTECTED]>
* clock.cpp, trigger.cpp, uielement.cpp, geometry.cpp, shape.cpp,
frameworkelement.cpp, transform.cpp, media.cpp, animation.cpp,
brush.cpp, text.cpp: s/Attachee/Attacher.
* dependencyobject.h: couple of Detach changes: 1) Add a DetachAll
call that is used at dtor time to call Detach on all
DependencyObject-subclassed Values, and 2) make NULL available in
detach as a wildcard - passing NULL for the property detaches all
properties that the current object might be watching on.
Also, correct a longstanding problem in terminology/api. if A's
code calls B->Attach (..., this), then A is the Attacher, not the
Attachee. Basically s/Attachee/Attacher in all places,
everywhere.
* dependencyobject.cpp: same changes as above. Also, change the
current_values hash table to key off the DependencyProperty, not
off the DependencyProperty name. This allows us to use a direct
hash, as opposed to a string hash.
* collection.cpp (dtor): make sure sure to detach from all the
list elements before we clear the list.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/ChangeLog 2007-10-09 19:13:20 UTC (rev 87213)
@@ -1,3 +1,28 @@
+2007-10-09 Chris Toshok <[EMAIL PROTECTED]>
+
+ * clock.cpp, trigger.cpp, uielement.cpp, geometry.cpp, shape.cpp,
+ frameworkelement.cpp, transform.cpp, media.cpp, animation.cpp,
+ brush.cpp, text.cpp: s/Attachee/Attacher.
+
+ * dependencyobject.h: couple of Detach changes: 1) Add a DetachAll
+ call that is used at dtor time to call Detach on all
+ DependencyObject-subclassed Values, and 2) make NULL available in
+ detach as a wildcard - passing NULL for the property detaches all
+ properties that the current object might be watching on.
+
+ Also, correct a longstanding problem in terminology/api. if A's
+ code calls B->Attach (..., this), then A is the Attacher, not the
+ Attachee. Basically s/Attachee/Attacher in all places,
+ everywhere.
+
+ * dependencyobject.cpp: same changes as above. Also, change the
+ current_values hash table to key off the DependencyProperty, not
+ off the DependencyProperty name. This allows us to use a direct
+ hash, as opposed to a string hash.
+
+ * collection.cpp (dtor): make sure sure to detach from all the
+ list elements before we clear the list.
+
2007-10-09 Jeffrey Stedfast <[EMAIL PROTECTED]>
* font.cpp (Layout): Only break words on ASCII lwsp, we should not
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/animation.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -1278,7 +1278,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -1407,7 +1407,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -1531,7 +1531,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
Modified: trunk/moon/src/brush.cpp
===================================================================
--- trunk/moon/src/brush.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/brush.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -137,7 +137,7 @@
// owners that they must repaint (all of our properties have
// a visible effect
//
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
//
@@ -167,7 +167,7 @@
return;
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
Color *
@@ -276,7 +276,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -284,7 +284,7 @@
{
// GeometryGroup only has one collection, so let's save the hash lookup
//if (col == GetValue
(GeometryGroup::ChildrenProperty)->AsGeometryCollection())
- NotifyAttacheesOfPropertyChange
(GradientBrush::GradientStopsProperty);
+ NotifyAttachersOfPropertyChange
(GradientBrush::GradientStopsProperty);
}
void
@@ -422,7 +422,7 @@
// owners that they must repaint (all of our properties have
// a visible effect
//
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
//
@@ -558,7 +558,7 @@
// owners that they must repaint (all of our properties have
// a visible effect
//
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
//
@@ -733,7 +733,7 @@
image->SetValue (MediaBase::SourceProperty, Value (source));
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
cairo_surface_t *image_brush_create_similar (cairo_t *cairo, int width, int
height)
@@ -1003,7 +1003,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -1013,7 +1013,7 @@
// We to changes in this MediaElement property so we
// can notify whoever is using us to paint that they
// need to redraw themselves.
- NotifyAttacheesOfPropertyChange (Brush::ChangedProperty);
+ NotifyAttachersOfPropertyChange (Brush::ChangedProperty);
}
TileBrush::OnSubPropertyChanged (prop, subprop);
@@ -1109,7 +1109,7 @@
void
VisualBrush::update_brush (EventObject *, gpointer, gpointer closure)
{
- ((VisualBrush*)closure)->NotifyAttacheesOfPropertyChange
(Brush::ChangedProperty);
+ ((VisualBrush*)closure)->NotifyAttachersOfPropertyChange
(Brush::ChangedProperty);
}
void
@@ -1126,7 +1126,7 @@
v->AddHandler (((UIElement*)v)->InvalidatedEvent, update_brush,
this);
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
Visual *
Modified: trunk/moon/src/clock.cpp
===================================================================
--- trunk/moon/src/clock.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/clock.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -959,7 +959,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
ClockGroup *
Modified: trunk/moon/src/collection.cpp
===================================================================
--- trunk/moon/src/collection.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/collection.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -54,6 +54,11 @@
Collection::~Collection ()
{
+ Collection::Node *n;
+
+ for (n = (Collection::Node *) list->First (); n; n = (Collection::Node
*) n->next)
+ n->obj->Detach (NULL, this);
+
list->Clear (true);
delete list;
}
Modified: trunk/moon/src/dependencyobject.cpp
===================================================================
--- trunk/moon/src/dependencyobject.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/dependencyobject.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -105,7 +105,7 @@
typedef struct {
DependencyObject *dob;
DependencyProperty *prop;
-} Attachee;
+} Attacher;
//
// Attaches the dependency object to the container on the given property.
@@ -113,7 +113,7 @@
void
DependencyObject::Attach (DependencyProperty *property, DependencyObject
*container)
{
- Attachee *att = new Attachee ();
+ Attacher *att = new Attacher ();
att->dob = container;
att->prop = property;
attached_list = g_slist_append (attached_list, att);
@@ -123,24 +123,44 @@
DependencyObject::Detach (DependencyProperty *property, DependencyObject
*container)
{
for (GSList *l = attached_list; l; l = l->next) {
- Attachee *att = (Attachee*)l->data;
+ Attacher *att = (Attacher*)l->data;
- if (att->dob == container && att->prop == property) {
+ if (att->dob == container && (property == NULL || att->prop ==
property)) {
attached_list = g_slist_remove_link (attached_list, l);
delete att;
- break;
}
}
}
-static bool attachees_notified;
+static void
+detach_depobj_values (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ DependencyObject *this_obj = (DependencyObject*)user_data;
+ //DependencyProperty *prop = (DependencyProperty*)key;
+ Value *v = (Value*)value;
+ if (v != NULL && v->GetKind() >= Type::DEPENDENCY_OBJECT &&
v->AsDependencyObject() != NULL) {
+ //printf ("detaching from property %s\n", prop->name);
+ v->AsDependencyObject()->Detach (NULL, this_obj);
+ }
+}
+
void
-DependencyObject::NotifyAttacheesOfPropertyChange (DependencyProperty
*subproperty)
+DependencyObject::DetachAll ()
{
- attachees_notified = true;
+ g_hash_table_foreach (current_values, detach_depobj_values, this);
+}
+
+static bool attachers_notified;
+
+void
+DependencyObject::NotifyAttachersOfPropertyChange (DependencyProperty
*subproperty)
+{
+ attachers_notified = true;
for (GSList *l = attached_list; l != NULL; l = l->next){
- Attachee *att = (Attachee*)l->data;
+ Attacher *att = (Attacher*)l->data;
att->dob->OnSubPropertyChanged (att->prop, subproperty);
}
@@ -163,7 +183,7 @@
}
}
- Value *current_value = (Value*)g_hash_table_lookup (current_values,
property->name);
+ Value *current_value = (Value*)g_hash_table_lookup (current_values,
property);
if (current_value != NULL && current_value->GetKind () >=
Type::DEPENDENCY_OBJECT) {
DependencyObject *current_as_dep =
current_value->AsDependencyObject ();
@@ -194,7 +214,7 @@
store = new Value (*value);
}
- g_hash_table_insert (current_values, property->name, store);
+ g_hash_table_insert (current_values, property, store);
if (value) {
if (value->GetKind () >= Type::DEPENDENCY_OBJECT){
@@ -205,12 +225,12 @@
}
}
- attachees_notified = false;
+ attachers_notified = false;
OnPropertyChanged (property);
- if (!attachees_notified)
- g_warning ("setting property %s::%s on object of type
%s didn't result in attachees being notified\n",
+ if (!attachers_notified)
+ g_warning ("setting property %s::%s on object of type
%s didn't result in attachers being notified\n",
Type::Find(property->type)->name,
property->name, Type::Find(GetObjectType())->name);
if (property->is_attached_property)
@@ -230,7 +250,7 @@
void *value = NULL;
bool found;
- found = g_hash_table_lookup_extended (current_values, property->name,
NULL, &value);
+ found = g_hash_table_lookup_extended (current_values, property, NULL,
&value);
if (found)
return (Value*)value;
@@ -243,7 +263,7 @@
{
Value *value = NULL;
- value = (Value *) g_hash_table_lookup (current_values, property->name);
+ value = (Value *) g_hash_table_lookup (current_values, property);
if (value != NULL)
return value;
@@ -284,14 +304,14 @@
dob->Detach (property, this);
}
- g_hash_table_remove (current_values, property->name);
+ g_hash_table_remove (current_values, property);
- attachees_notified = false;
+ attachers_notified = false;
OnPropertyChanged (property);
- if (!attachees_notified)
- g_warning ("setting property %s::%s on object of type %s didn't
result in attachees being notified\n",
+ if (!attachers_notified)
+ g_warning ("setting property %s::%s on object of type %s didn't
result in attachers being notified\n",
Type::Find(property->type)->name, property->name,
Type::Find(GetObjectType())->name);
if (property->is_attached_property)
@@ -326,7 +346,7 @@
DependencyObject::DependencyObject ()
{
- current_values = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
free_value);
+ current_values = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, free_value);
this->attached_list = NULL;
this->parent = NULL;
}
@@ -345,17 +365,19 @@
return Type::DEPENDENCY_OBJECT;
}
-void free_attachee (gpointer data, gpointer user_data)
+void free_attacher (gpointer data, gpointer user_data)
{
- Attachee* att = (Attachee*) data;
+ Attacher* att = (Attacher*) data;
delete att;
}
DependencyObject::~DependencyObject ()
{
+ DetachAll ();
+
g_hash_table_destroy (current_values);
if (attached_list != NULL) {
- g_slist_foreach (attached_list, free_attachee, NULL);
+ g_slist_foreach (attached_list, free_attacher, NULL);
g_slist_free (attached_list);
}
}
@@ -818,7 +840,7 @@
scope->RegisterName (v->AsString (), this);
}
- NotifyAttacheesOfPropertyChange (property);
+ NotifyAttachersOfPropertyChange (property);
}
void
Modified: trunk/moon/src/dependencyobject.h
===================================================================
--- trunk/moon/src/dependencyobject.h 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/dependencyobject.h 2007-10-09 19:13:20 UTC (rev 87213)
@@ -172,9 +172,11 @@
void Detach (DependencyProperty *property, DependencyObject *container);
protected:
- void NotifyAttacheesOfPropertyChange (DependencyProperty *property);
+ void NotifyAttachersOfPropertyChange (DependencyProperty *property);
void NotifyParentOfPropertyChange (DependencyProperty *property, bool
only_exact_type);
+ void DetachAll ();
+
private:
GHashTable *current_values;
GSList *attached_list;
Modified: trunk/moon/src/frameworkelement.cpp
===================================================================
--- trunk/moon/src/frameworkelement.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/frameworkelement.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -42,7 +42,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
bool
Modified: trunk/moon/src/geometry.cpp
===================================================================
--- trunk/moon/src/geometry.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/geometry.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -93,7 +93,7 @@
if ((prop->type != Type::GEOMETRY) && path)
moon_path_clear (path);
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
static void
@@ -279,13 +279,13 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
GeometryGroup::OnSubPropertyChanged (DependencyProperty *prop,
DependencyProperty *subprop)
{
- NotifyAttacheesOfPropertyChange (subprop);
+ NotifyAttachersOfPropertyChange (subprop);
}
void
@@ -293,7 +293,7 @@
{
// GeometryGroup only has one collection, so let's save the hash lookup
//if (col == GetValue
(GeometryGroup::ChildrenProperty)->AsGeometryCollection())
- NotifyAttacheesOfPropertyChange
(GeometryGroup::ChildrenProperty);
+ NotifyAttachersOfPropertyChange
(GeometryGroup::ChildrenProperty);
}
void
@@ -581,7 +581,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -589,7 +589,7 @@
{
// PathGeometry only has one collection, so let's save the hash lookup
//if (col == GetValue
(PathGeometry::FiguresProperty)->AsPathFigureCollection ())
- NotifyAttacheesOfPropertyChange (PathGeometry::FiguresProperty);
+ NotifyAttachersOfPropertyChange (PathGeometry::FiguresProperty);
}
// FIXME: we should cache the path in the group (i.e. a Build method) to avoid
@@ -821,7 +821,7 @@
if (path)
moon_path_clear (path);
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -831,7 +831,7 @@
moon_path_clear (path);
// PathFigure only has one collection, so let's save the hash lookup
//if (col == GetValue
(PathFigure::SegmentsProperty)->AsPathSegmentCollection())
- NotifyAttacheesOfPropertyChange (PathFigure::SegmentsProperty);
+ NotifyAttachersOfPropertyChange (PathFigure::SegmentsProperty);
}
void
@@ -929,7 +929,7 @@
return;
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
//
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/media.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -721,7 +721,7 @@
}
if (prop->type == Type::MEDIAELEMENT) {
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
} else {
// propagate to parent class
MediaBase::OnPropertyChanged (prop);
@@ -1410,7 +1410,7 @@
}
// we need to notify attachees if our DownloadProgress changed.
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
Image *
Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/shape.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -375,7 +375,7 @@
Invalidate ();
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -862,7 +862,7 @@
}
Invalidate ();
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
bool
@@ -1307,7 +1307,7 @@
}
Invalidate ();
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -1496,7 +1496,7 @@
}
Invalidate ();
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -1641,7 +1641,7 @@
InvalidatePathCache ();
FullInvalidate (false);
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/text.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -190,7 +190,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -199,7 +199,7 @@
if (prop == Inline::ForegroundProperty) {
// this isn't exactly what we want, I don't
// think... but it'll have to do.
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
}
@@ -313,7 +313,7 @@
return;
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
Run *
@@ -900,7 +900,7 @@
Invalidate ();
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -1769,7 +1769,7 @@
if (dirty)
UpdateBounds (true);
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
Glyphs *
Modified: trunk/moon/src/transform.cpp
===================================================================
--- trunk/moon/src/transform.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/transform.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -40,7 +40,7 @@
// of transform from C#, and in that case, we would only
// be slower.
//
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
@@ -427,14 +427,14 @@
need_update = true;
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
TransformGroup::OnSubPropertyChanged (DependencyProperty *prop,
DependencyProperty *subprop)
{
need_update = true;
- NotifyAttacheesOfPropertyChange (subprop);
+ NotifyAttachersOfPropertyChange (subprop);
}
void
@@ -473,7 +473,7 @@
void
TransformCollection::OnSubPropertyChanged (DependencyProperty *prop,
DependencyProperty *subprop)
{
- NotifyAttacheesOfPropertyChange (subprop);
+ NotifyAttachersOfPropertyChange (subprop);
}
void
Modified: trunk/moon/src/trigger.cpp
===================================================================
--- trunk/moon/src/trigger.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/trigger.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -37,7 +37,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
void
Modified: trunk/moon/src/uielement.cpp
===================================================================
--- trunk/moon/src/uielement.cpp 2007-10-09 19:07:35 UTC (rev 87212)
+++ trunk/moon/src/uielement.cpp 2007-10-09 19:13:20 UTC (rev 87213)
@@ -153,7 +153,7 @@
}
}
- NotifyAttacheesOfPropertyChange (prop);
+ NotifyAttachersOfPropertyChange (prop);
}
#if true
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches