[Redbutton-devel] SF.net SVN: redbutton: [236] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-03-01 17:26:43
|
Revision: 236
http://svn.sourceforge.net/redbutton/?rev=236&view=rev
Author: skilvington
Date: 2007-03-01 09:26:41 -0800 (Thu, 01 Mar 2007)
Log Message:
-----------
don't let timers go off after their GroupClass has been deleted
Modified Paths:
--------------
redbutton-browser/trunk/ApplicationClass.c
redbutton-browser/trunk/GroupClass.c
redbutton-browser/trunk/GroupClass.h
redbutton-browser/trunk/MHEGTimer.h
redbutton-browser/trunk/SceneClass.c
redbutton-browser/trunk/add_instance_vars.conf
Modified: redbutton-browser/trunk/ApplicationClass.c
===================================================================
--- redbutton-browser/trunk/ApplicationClass.c 2007-03-01 15:50:35 UTC (rev 235)
+++ redbutton-browser/trunk/ApplicationClass.c 2007-03-01 17:26:41 UTC (rev 236)
@@ -45,6 +45,7 @@
/* GroupClass */
v->GroupCachePriority = t->original_group_cache_priority;
v->Timers = NULL;
+ v->removed_timers = NULL;
/* ApplicationClass */
v->LockCount = 0;
@@ -58,7 +59,7 @@
void
free_ApplicationClassInstanceVars(ApplicationClassInstanceVars *v)
{
- GroupClass_freeTimers(&v->Timers);
+ GroupClass_freeTimers(&v->Timers, &v->removed_timers);
LIST_FREE(&v->DisplayStack, RootClassPtr, safe_free);
@@ -586,7 +587,7 @@
{
verbose("ApplicationClass: %s; SetTimer", ExternalReference_name(&t->rootClass.inst.ref));
- GroupClass_SetTimer(&t->rootClass.inst.ref, &t->inst.Timers, &t->inst.start_time, params, caller_gid);
+ GroupClass_SetTimer(&t->rootClass.inst.ref, &t->inst.Timers, &t->inst.removed_timers, &t->inst.start_time, params, caller_gid);
return;
}
Modified: redbutton-browser/trunk/GroupClass.c
===================================================================
--- redbutton-browser/trunk/GroupClass.c 2007-03-01 15:50:35 UTC (rev 235)
+++ redbutton-browser/trunk/GroupClass.c 2007-03-01 17:26:41 UTC (rev 236)
@@ -12,11 +12,12 @@
#include "ExternalReference.h"
void
-GroupClass_SetTimer(ExternalReference *ref, LIST_OF(Timer) **timer_list, struct timeval *start_time,
- SetTimer *params, OctetString *caller_gid)
+GroupClass_SetTimer(ExternalReference *ref, LIST_OF(Timer) **timer_list, LIST_OF(MHEGTimer) **removed_timers,
+ struct timeval *start_time, SetTimer *params, OctetString *caller_gid)
{
int id;
LIST_TYPE(Timer) *timer;
+ LIST_TYPE(MHEGTimer) *old_timer;
int value;
bool absolute;
int interval;
@@ -51,6 +52,13 @@
if(interval < 0)
interval = 0;
timer->item.position = value;
+ /*
+ * don't want timers going off after the GroupClass has been deleted
+ * so, remember the old mheg_id
+ */
+ old_timer = safe_malloc(sizeof(LIST_TYPE(MHEGTimer)));
+ old_timer->item = timer->item.mheg_id;
+ LIST_APPEND(removed_timers, old_timer);
/* update its mheg_id */
timer->item.mheg_id = MHEGTimer_addGroupClassTimer(interval, ref, timer->item.id, timer_list);
}
@@ -87,6 +95,10 @@
/* no new timer value => remove the timer */
if(timer != NULL)
{
+ /* remember the old mheg_id */
+ old_timer = safe_malloc(sizeof(LIST_TYPE(MHEGTimer)));
+ old_timer->item = timer->item.mheg_id;
+ LIST_APPEND(removed_timers, old_timer);
/* removing a timer does not surpress events from the previous timer */
LIST_REMOVE(timer_list, timer);
safe_free(timer);
@@ -129,9 +141,10 @@
}
void
-GroupClass_freeTimers(LIST_OF(Timer) **timer_list)
+GroupClass_freeTimers(LIST_OF(Timer) **timer_list, LIST_OF(MHEGTimer) **removed_timers)
{
LIST_TYPE(Timer) *timer = *timer_list;
+ LIST_TYPE(MHEGTimer) *old_timer = *removed_timers;
while(timer)
{
@@ -141,6 +154,15 @@
LIST_FREE(timer_list, Timer, safe_free);
+ /* remove the timers that have been updated or removed */
+ while(old_timer)
+ {
+ MHEGTimer_removeGroupClassTimer(old_timer->item);
+ old_timer = old_timer->next;
+ }
+
+ LIST_FREE(removed_timers, MHEGTimer, safe_free);
+
return;
}
Modified: redbutton-browser/trunk/GroupClass.h
===================================================================
--- redbutton-browser/trunk/GroupClass.h 2007-03-01 15:50:35 UTC (rev 235)
+++ redbutton-browser/trunk/GroupClass.h 2007-03-01 17:26:41 UTC (rev 236)
@@ -9,10 +9,10 @@
#include "ISO13522-MHEG-5.h"
-void GroupClass_SetTimer(ExternalReference *, LIST_OF(Timer) **, struct timeval *, SetTimer *, OctetString *);
+void GroupClass_SetTimer(ExternalReference *, LIST_OF(Timer) **, LIST_OF(MHEGTimer) **, struct timeval *, SetTimer *, OctetString *);
void GroupClass_timerFired(ExternalReference *, int, MHEGTimer, LIST_OF(Timer) **);
-void GroupClass_freeTimers(LIST_OF(Timer) **);
+void GroupClass_freeTimers(LIST_OF(Timer) **, LIST_OF(MHEGTimer) **);
#endif /* __GROUPCLASS_H__ */
Modified: redbutton-browser/trunk/MHEGTimer.h
===================================================================
--- redbutton-browser/trunk/MHEGTimer.h 2007-03-01 15:50:35 UTC (rev 235)
+++ redbutton-browser/trunk/MHEGTimer.h 2007-03-01 17:26:41 UTC (rev 236)
@@ -10,6 +10,8 @@
typedef XtIntervalId MHEGTimer;
+DEFINE_LIST_OF(MHEGTimer);
+
MHEGTimer MHEGTimer_addGroupClassTimer(unsigned int, ExternalReference *, int, void *);
void MHEGTimer_removeGroupClassTimer(MHEGTimer);
Modified: redbutton-browser/trunk/SceneClass.c
===================================================================
--- redbutton-browser/trunk/SceneClass.c 2007-03-01 15:50:35 UTC (rev 235)
+++ redbutton-browser/trunk/SceneClass.c 2007-03-01 17:26:41 UTC (rev 236)
@@ -23,6 +23,7 @@
/* GroupClass */
v->GroupCachePriority = t->original_group_cache_priority;
v->Timers = NULL;
+ v->removed_timers = NULL;
v->next_clone = FIRST_CLONED_OBJ_NUM;
@@ -32,7 +33,7 @@
void
free_SceneClassInstanceVars(SceneClassInstanceVars *v)
{
- GroupClass_freeTimers(&v->Timers);
+ GroupClass_freeTimers(&v->Timers, &v->removed_timers);
return;
}
@@ -210,7 +211,7 @@
{
verbose("SceneClass: %s; SetTimer", ExternalReference_name(&t->rootClass.inst.ref));
- GroupClass_SetTimer(&t->rootClass.inst.ref, &t->inst.Timers, &t->inst.start_time, params, caller_gid);
+ GroupClass_SetTimer(&t->rootClass.inst.ref, &t->inst.Timers, &t->inst.removed_timers, &t->inst.start_time, params, caller_gid);
return;
}
Modified: redbutton-browser/trunk/add_instance_vars.conf
===================================================================
--- redbutton-browser/trunk/add_instance_vars.conf 2007-03-01 15:50:35 UTC (rev 235)
+++ redbutton-browser/trunk/add_instance_vars.conf 2007-03-01 17:26:41 UTC (rev 236)
@@ -40,7 +40,8 @@
/* inherited from GroupClass */
unsigned int GroupCachePriority;
LIST_OF(Timer) *Timers;
- /* we add this */
+ /* we add these */
+ LIST_OF(MHEGTimer) *removed_timers;
struct timeval start_time;
/* ApplicationClass */
unsigned int LockCount;
@@ -56,7 +57,8 @@
/* inherited from GroupClass */
unsigned int GroupCachePriority;
LIST_OF(Timer) *Timers;
- /* we add this */
+ /* we add these */
+ LIST_OF(MHEGTimer) *removed_timers;
struct timeval start_time;
/* we add where to start searching for unused object numbers for clones */
unsigned int next_clone;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|