From dec96cfa45b442a827ec2543ef60ac405ac99e31 Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 19 Jun 2008 17:18:42 +0000 Subject: [PATCH] while abort() is really only useful for listeners (in all other cases we know the stack trace), it's better to use a separate function for it, as this can be used conditionally, as in: setlistener("/the/property", func(n) { if (n.getValue() < 0) # who's writing negative numbers to /the/property?! abort(); # let's check the backtrace ... }); --- src/Scripting/NasalSys.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index a37c40b35..7b9933627 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -347,6 +347,12 @@ static naRef f_srand(naContext c, naRef me, int argc, naRef* args) return naNum(0); } +static naRef f_abort(naContext c, naRef me, int argc, naRef* args) +{ + abort(); + return naNil(); +} + // Return an array listing of all files in a directory static naRef f_directory(naContext c, naRef me, int argc, naRef* args) { @@ -597,6 +603,7 @@ static struct { const char* name; naCFunction func; } funcs[] = { { "_interpolate", f_interpolate }, { "rand", f_rand }, { "srand", f_srand }, + { "abort", f_abort }, { "directory", f_directory }, { "parsexml", f_parsexml }, { "systime", f_systime }, @@ -1023,7 +1030,6 @@ void FGNasalListener::valueChanged(SGPropertyNode* node) if(_type < 2 && node != _node) return; // skip child events if(_type > 0 || changed(_node) || _first_call) call(node, naNum(0)); - if(_type == -1) abort(); _first_call = false; }