Improvement in Broadcast Behavior
Broadcast Command
When an object receives a message via a broadcast, the message is supposed to be resolved or ignored. We implemented this behavior by:
- Temporarily setting the object's
delegation_modetono_delegate_no_error. - Sending the message.
- Restoring the
delegation_mode.
While this did prevent broadcasted messages from delegating messages it did not understand, it had the unfortunate side effect of changing the object's delegation mode for all other child messages sent to the object as part of the message's normal processing.
Property Integer piSomeProperty 100
Object oObj1 is a form
Procedure Foo
Get piSomeProperty to iVar // since this needs to delegate we will have problems
Send SomeOtherMessage iVar // if this needs to delegate we will have problems
End_Procedure
End_Object
Object oObj2 is a form
Procedure Foo
Get piSomeProperty to iVar // Since this needs to delegate we will have problems
Send SomeOtherMessage iVar // if this needs to delegate we will have problems
End_Procedure
End_Object
Broadcast Send Foo
For example, assume the message Foo is broadcast to these objects. In both objects, the piSomeProperty is supposed to be resolved via delegation. Since delegation_mode will be set to no_delegate_no_error, the message will be ignored. Therefore, the variable value will be wrong, and your faulty program will run as if nothing is wrong.
This has been the standard broadcast behavior since DataFlex 3.0 was released, and many developers have mentioned over the years that this behavior is not what they expect. In particular, it is extremely difficult to debug when you expect a message to delegate but instead get no delegation and no error—there is no way to know you have a problem.
This has now been changed so that the object's delegation_mode is never modified during a broadcast. Instead, delegation is temporarily turned off only at the broadcast call level. This means that the broadcasted message will still ignore a non-understood message (which is good), but all messages sent within a broadcast call will delegate as needed (which is also good). Any messages sent during delegation will still delegate according to the original delegation_mode of the object.
We do not expect that this will negatively affect any existing programs, as the old behavior was not something that you would ever want to take specific advantage of. The only possible effect might occur if your program is currently not working properly, and somehow your program bug was neutralized by the old broadcast behavior—this is very unlikely.