Ken,
The destruct order shouldn't matter. Do your observers also hold a reference to the subject? If so your subject should maybe broadcast a message to them letting them know it is going away and therefore no longer observable:
for i = 1 to alen( this.aObservers )
if ( IsObject( this.aObservers[i] ) )
this.aObservers[i].StopObserving( this )
this.aObservers[i] = .null.
endif
endfor
if ( IsObject( this.oSubject ) )
this.oSubject.Detach( this )
endif
if ( IsObject( roSubject ) )
roSubject.Detach( this )
endif
this.oSubject = .null.
this.StopObserving( .null. )
>I'd tried the detach method below in the subject object. I was calling the subject.detach from the observer.destroy. It seemed no matter what I did with the subject's zorder it always got destroyed first. I'm not using pemstatus() or getpem().
>
>lparameter cObserverName
>local cObserverName
>for x = 1 to alen(This.aObservers)
> if this.aObservers(x).Name = cObserverName
> this.aObservers(x) = .null.
> endif
>next
>
As it stands, I've duplicated the above code (without the conditional) in a method called DetachAll, and I'm calling it from the form.destroy per Nancy's suggestion. It works, but seems to break from the pattern as defined by G&H.