View Full Version : Strange issue with setValue
drahkar
January 8th, 2010, 18:53
Could someone give me some thoughts on what the following would throw a C stack overflow error?
function onValueChanged()
local spectype = getValue();
setValue(spectype);
end
Foen
January 8th, 2010, 18:59
setValue() fires an onValueChanged event, which then calls setValue(), which then fires an onValueChanged event, which then calls setValue(), ... the loop continues until the FG engine falls over.
drahkar
January 8th, 2010, 18:59
.... Good point.
Moon Wizard
January 8th, 2010, 19:43
I had this problem when I originally created fields to synchronize with each other from different records.
You have to add in a local flag to avoid the cycle.
Based on your example:
local locked = false;
function onValueChanged()
if not locked then
locked = true;
local spectype = getValue();
setValue(spectype);
end
end
Cheers,
JPG
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.