Author: fejj
Date: 2007-12-03 18:24:02 -0500 (Mon, 03 Dec 2007)
New Revision: 90607
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/clock.cpp
Log:
2007-12-03 Jeffrey Stedfast <[EMAIL PROTECTED]>
* clock.cpp (RaiseEnqueuedEvents): Optimized a bit by not
iterating thru the list 6 times :)
(ClockGroup::RaiseAccumulatedEvents): Make a copy of the
child_clocks list here too, or we end up corrupting memory.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-12-03 22:45:44 UTC (rev 90606)
+++ trunk/moon/src/ChangeLog 2007-12-03 23:24:02 UTC (rev 90607)
@@ -2,6 +2,8 @@
* clock.cpp (RaiseEnqueuedEvents): Optimized a bit by not
iterating thru the list 6 times :)
+ (ClockGroup::RaiseAccumulatedEvents): Make a copy of the
+ child_clocks list here too, or we end up corrupting memory.
2007-12-03 Larry Ewing <[EMAIL PROTECTED]>
Modified: trunk/moon/src/clock.cpp
===================================================================
--- trunk/moon/src/clock.cpp 2007-12-03 22:45:44 UTC (rev 90606)
+++ trunk/moon/src/clock.cpp 2007-12-03 23:24:02 UTC (rev 90607)
@@ -49,6 +49,12 @@
extern guint32 moonlight_flags;
+struct ClockNode {
+ ClockNode *next;
+ Clock *clock;
+};
+
+
TimeSpan
get_now (void)
{
@@ -380,11 +386,6 @@
last_global_time = current_global_time;
}
-typedef struct ClockNode {
- struct ClockNode *next;
- Clock *clock;
-} ClockNode;
-
void
TimeManager::RaiseEnqueuedEvents ()
{
@@ -1087,15 +1088,33 @@
void
ClockGroup::RaiseAccumulatedEvents ()
{
+ ClockNode *list, *tail, *next;
+ GList *n;
+
/* raise our events */
this->Clock::RaiseAccumulatedEvents ();
-
- /* now cause our children to raise theirs*/
- GList *copy = g_list_copy (child_clocks);
- for (GList *l = copy; l; l = l->next)
- ((Clock*)l->data)->RaiseAccumulatedEvents ();
- g_list_free (copy);
-
+
+ /* now cause our children to raise theirs */
+ list = NULL;
+ tail = (ClockNode *) &list;
+
+ for (n = child_clocks; n != NULL; n = n->next) {
+ tail->next = g_new (ClockNode, 1);
+ tail = tail->next;
+
+ tail->clock = (Clock *) n->data;
+ tail->clock->ref ();
+ tail->next = NULL;
+ }
+
+ while (list != NULL) {
+ list->clock->RaiseAccumulatedEvents ();
+ list->clock->unref ();
+ next = list->next;
+ g_free (list);
+ list = next;
+ }
+
if (GetHasStarted() && state == Clock::Stopped && !emitted_complete) {
Emit (CompletedEvent);
emitted_complete = true;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches