From 11f591261eebf05568bfc2a7db898e47f14c4dad Mon Sep 17 00:00:00 2001
From: Edward d'Auvergne <edward@nmr-relax.com>
Date: Wed, 21 Mar 2018 10:21:45 +0100
Subject: [PATCH] FGNasalSys::setTimer: Timer names now identify the file and
 line number.

This identifies the function for the callback and allows for better debugging of
the sim and real time SGTimerQueues in the event manager.
---
 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 93b65491e..741d76a4f 100644
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
@@ -1373,13 +1373,19 @@ void FGNasalSys::setTimer(naContext c, int argc, naRef* args)
 
     bool simtime = (argc > 2 && naTrue(args[2])) ? false : true;
 
+    // A unique name for the timer based on the file name and line number of the function.
+    std::string name = "NasalTimer-";
+    name.append(naStr_data(naGetSourceFile(c, 0)));
+    name.append(":");
+    name.append(std::to_string(naGetLine(c, 0)));
+
     // Generate and register a C++ timer handler
     NasalTimer* t = new NasalTimer;
     t->handler = handler;
     t->gcKey = gcSave(handler);
     t->nasal = this;
 
-    globals->get_event_mgr()->addEvent("NasalTimer",
+    globals->get_event_mgr()->addEvent(name,
                                        t, &NasalTimer::timerExpired,
                                        delta.num, simtime);
 }