setProp and Lock messages

Todd Geist todd at geistinteractive.com
Sat Dec 3 10:29:48 CST 2011


Hi Mark

I see in the documentation and lessons that setProp and getProp handlers
will fail if messages are locked

Doesn't this present a problem if you are using Custom Props with setProp
to store state for example. If somewhere in your code you lock messages and
then try to store state, it will fail won't it?

Thanks

Todd


On Sat, Dec 3, 2011 at 8:16 AM, Mark Schonewille <
m.schonewille at economy-x-talk.com> wrote:

> Hi Todd,
>
> I don't quite understand your question. Surely, it is a good idea to use
> getProp and setProp handlers. You just need to make sure not to get trapped
> in a loop, but this applies to all messages. Sometimes, there is a danger
> that setting a property calls the setProp handler again, but locking
> messages prevents this from happening. A correct handler may look like this:
>
> setProp cProp x
>  lock messages
>  set the cProp of the target to compress(x)
> end cProp
>
> getProp cProp
>  lock messages
>  return decompress(the cProp of the target)
> end cProp
>
> You need to lock messages if the target is an object on a card and the
> handler is at card or script level, or if the target is the card and the
> script is at stack level for instance.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
> KvK: 50277553
>
> Become our partner in sales http://qery.us/1bq Start selling Color
> Converter today. 20% commission!
>
> On 3 dec 2011, at 17:04, Todd Geist wrote:
>
> > Hello,
> >
> > I understand that SetProp and GetProp handlers are messages and if Lock
> > messages is on then these will not work.  But clearly people use GetProp
> > and SetProp handlers. I see them used a lot in CustomControls. I assume
> the
> > DataGrid uses them when you "set dgData of "….
> >
> > So I am looking for clarification. When is it bad idea to use GetProp and
> > SetProp handlers?
> >
> > Thanks
> >
> > Todd
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Todd Geist


(805) 419-9382


More information about the use-livecode mailing list