TSWreckerImpl.mesa
Michael Plass, January 13, 1984 4:23 pm
DIRECTORY TSObject, TSWrecker, UserProfile;
TSWreckerImpl: CEDAR PROGRAM IMPORTS UserProfile EXPORTS TSWrecker = BEGIN
toDestroyAtEndOfFile: PUBLIC REFNIL;
DestroyRef: PUBLIC PROCEDURE [ref: REF, preserve: LIST OF REF ANY] =
BEGIN
Don't destroy it if it is on the preserve list.
IF NOT wreckerEnabled THEN RETURN;
FOR l: LIST OF REF ANY ← preserve, l.rest UNTIL l = NIL DO
IF ref = l.first THEN RETURN;
ENDLOOP;
WITH ref SELECT FROM
itemList: TSObject.ItemList => {
exceptionList: LIST OF REF ANY ← itemList.exceptionList;
WHILE exceptionList # NIL DO
t: LIST OF REF ANY ← exceptionList;
exceptionList ← exceptionList.rest;
t.first ← NIL;
t.rest ← NIL;
ENDLOOP;
itemList.exceptionList ← NIL;
DestroyRef[itemList.tagList, preserve];
itemList.tagList ← NIL;
};
tagList: LIST OF TSObject.TagRec => {
WHILE tagList # NIL DO
t: LIST OF TSObject.TagRec ← tagList;
tagList ← tagList.rest;
t.rest ← NIL;
ENDLOOP;
};
box: TSObject.Box => {
WITH box^ SELECT FROM
listBox: TSObject.BoxRec.list => {DestroyRef[listBox.items, preserve]; listBox.items ← NIL};
ENDCASE => NULL;
};
ENDCASE => NULL;
END; 
wreckerEnabled: BOOLEAN ← UserProfile.Boolean["TSetter.WreckerEnabled", TRUE];
UserProfileChanged: UserProfile.ProfileChangedProc ~ {
wreckerEnabled ← UserProfile.Boolean["TSetter.WreckerEnabled", TRUE];
};
UserProfile.CallWhenProfileChanges[UserProfileChanged];
END.