Comment 19 for bug 941337

Revision history for this message
Ronny Lorenz (raumzeit) wrote :

Yes I agree.
I also think that the wrapper should know best what its going to do on stop(). I will implement this feature. However, once the stop() method of the wrapper is called should all Control instances be removed then or just be deactivated, i.e. stopped? Because we somehow should indicate that the wrapper has no active control instances stored anymore, which I would like to do by setting the __length attribute to 0 or even -1. But this would conflict with the current implementation where __length=0 makes the wrapper to behave like an ordinary control while __length > 0 exposes a list of controls.
I thought that actually we dont need to keep an original copy of a control. Wrapper length extension may also result in copying the last (or any other) already stored control since after deepcopy the new control is initialized to its defaults anyway. We then ensure that there is always at least one control instance in the list after setting the __length attribute to any positive integer value >= 0. (I am open for debate on this one, since storing a copy of the original control and using this as a template has the same effect, however, the original control should be stopped since it serves no function but beeing a template for active controls)

Calling the stop() method of the wrapper could then stop all controls, remove them from the internal control list of the wrapper and thus make the wrapper unusable until eternity.
On the other hand we could be so kind that on stop() all but the very last control are stopped and removed. Then the last control is just stopped and the __length attribute of the wrapper is set to -1 indicating no active controls. All wrapper methods should check for this new __length setting and respond appropriately. If a user then re-sets the length attribute because he/she decided to not give up on using the wrapped controls, re-initialization can take place to make the wrapper usable again. Since the stop() method may be callable by inline scripts of the user I prefer this way. On stop() of the entire Script instance all stored wrappers will be stopped and deleted in the hope that at some time later the garbage collector will get rid of them and thus the last remaining inactive controls.

I suggest that I make an implementation of this latter feature. Anyone disagreeing?