setProp and Lock messages
Mark Schonewille
m.schonewille at economy-x-talk.com
Sat Dec 3 13:21:50 EST 2011
Todd,
I don't think this is a problem because you can unlock messages right before setting the data of the datagrid and lock them again immediately thereafter.
unlock messages
set the dgData of grp x to bla
lock messages
The only problem I foresee is that you have a handler that runs recursively, e.g.
on foo
repeat with x = 1 to number of groups
delete grp 1
end repeat
send foo to me in 1 sec
end foo
This is a silly handler, but if you have something similar to this, then you might want to lock the messages while you create a group (e.g. a datagrid) dynamically, and use the group for some tasks before allowing it to be deleted. Again, this is a silly scenario, but it serves the purpose. Your solution would be:
lock messages
copy grp "My Datagrid" from stack "Some Stack" to stack "This Stack"
// next line won't work
set the dgData of grp "My Datagrid" of stack "This Stack" to bla
// do some things with the data grid here
unlock messages
// now the datagrid will be deleted
To solve this problem, you use a local variable instead of locking the messages:
local lAllowDeletion
on foo
if lAllowDeletion is not false then
repeat with x = 1 to number of groups
delete grp 1
end repeat
end if
send foo to me in 1 sec
end foo
And now you could set the data of the datagrid like this:
put false into lAllowDeletion
copy grp "My Datagrid" from stack "Some Stack" to stack "This Stack"
// next line WILL work
set the dgData of grp "My Datagrid" of stack "This Stack" to bla
// do some things with the data grid here
put true into lAllowDeletion
// now the datagrid will be deleted
Sometimes relying on lockMessages just may not be the right thing to do.
--
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 19:01, Todd Geist wrote:
> More on this…
>
> I just tested locking messages prior to calling a handler that eventually
> sets the dgData of a DataGrid. Of course no data is set into the Datagrid.
>
> Is this not a problem?
>
> Todd
More information about the use-livecode
mailing list