Howto:Disable Nasal entirely: Difference between revisions

Jump to navigation Jump to search
m
→‎Patch: another sed run ... should probably use collapsible template
m (→‎Patch: find . -type f -name *.cxx -exec sed -i 's/(FGNasalSys\*) globals->get_subsystem("nasal")/globals->get_subsystem<FGNasalSys>()/g' {} \;)
m (→‎Patch: another sed run ... should probably use collapsible template)
Line 131: Line 131:


<syntaxhighlight lang="diff">diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx
<syntaxhighlight lang="diff">diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx
index 4faf23e..38c38b2 100644
index 4faf23e..aaca4b9 100644
--- a/src/AIModel/AIManager.cxx
--- a/src/AIModel/AIManager.cxx
+++ b/src/AIModel/AIManager.cxx
+++ b/src/AIModel/AIManager.cxx
Line 140: Line 140:
-            FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
-            FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+            FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+            FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+     if(!nasalSys) {  
+     if(!nasalSys) { // TODO: check this during reset when AI scenarios are still booting
+ NASAL_DISABLED("AI scenarios");
+ NASAL_DISABLED("load AI scenario");
+ return;
+ return;
+     }
+     }
Line 156: Line 156:
+        FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+        FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+        if(!nasalSys) {  
+        if(!nasalSys) {  
+ NASAL_DISABLED("AI scenarios");
+ NASAL_DISABLED("unload AI scenarios");
+ return;
+ return;
+     }
+     }
Line 163: Line 163:
         if (!_unloadScript.empty()) {
         if (!_unloadScript.empty()) {
diff --git a/src/GUI/CanvasWidget.cxx b/src/GUI/CanvasWidget.cxx
diff --git a/src/GUI/CanvasWidget.cxx b/src/GUI/CanvasWidget.cxx
index f68fe22..52ed2f4 100644
index f68fe22..c8dcc6a 100644
--- a/src/GUI/CanvasWidget.cxx
--- a/src/GUI/CanvasWidget.cxx
+++ b/src/GUI/CanvasWidget.cxx
+++ b/src/GUI/CanvasWidget.cxx
@@ -72,10 +72,13 @@ CanvasWidget::CanvasWidget( int x, int y,
@@ -71,11 +71,14 @@ CanvasWidget::CanvasWidget( int x, int y,
  if( !nasal )
     return;
     return;
   
   
  FGNasalSys *nas = dynamic_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
FGNasalSys *nas = dynamic_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
-  if( !nas )
-  if( !nas )
+  FGNasalSys *nas = globals->get_subsystem<FGNasalSys>();
+  if( !nas ) {
+  if( !nas ) {
     SG_LOG( SG_GENERAL,
     SG_LOG( SG_GENERAL,
Line 182: Line 184:
                           + cprops->getStringValue("name");
                           + cprops->getStringValue("name");
diff --git a/src/GUI/FGPUIDialog.cxx b/src/GUI/FGPUIDialog.cxx
diff --git a/src/GUI/FGPUIDialog.cxx b/src/GUI/FGPUIDialog.cxx
index 30cbef7..604fd18 100644
index 30cbef7..e9a0848 100644
--- a/src/GUI/FGPUIDialog.cxx
--- a/src/GUI/FGPUIDialog.cxx
+++ b/src/GUI/FGPUIDialog.cxx
+++ b/src/GUI/FGPUIDialog.cxx
@@ -672,7 +672,9 @@ FGPUIDialog::FGPUIDialog (SGPropertyNode *props) :
@@ -669,10 +669,12 @@ FGPUIDialog::FGPUIDialog (SGPropertyNode *props) :
             FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
        SGPropertyNode *open = nasal->getNode("open");
        if (open) {
             const char *s = open->getStringValue();
-            FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
+            FGNasalSys *nas = globals->get_subsystem<FGNasalSys>();
             if (nas)
             if (nas)
                 nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), props);
                 nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), props);
Line 195: Line 201:
     display(props);
     display(props);
  }
  }
@@ -684,7 +686,7 @@ FGPUIDialog::~FGPUIDialog ()
    _props->setIntValue("lastx", x);
    _props->setIntValue("lasty", y);
-    FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
+    FGNasalSys *nas = globals->get_subsystem<FGNasalSys>();
    if (nas) {
        if (_nasal_close) {
            const char *s = _nasal_close->getStringValue();
@@ -1055,8 +1057,12 @@ FGPUIDialog::makeObject (SGPropertyNode *props, int parentWidth, int parentHeigh
@@ -1055,8 +1057,12 @@ FGPUIDialog::makeObject (SGPropertyNode *props, int parentWidth, int parentHeigh
             obj->setBuffer(tsync->log());
             obj->setBuffer(tsync->log());
Line 210: Line 225:
         setupObject(obj, props);
         setupObject(obj, props);
diff --git a/src/GUI/FileDialog.cxx b/src/GUI/FileDialog.cxx
diff --git a/src/GUI/FileDialog.cxx b/src/GUI/FileDialog.cxx
index 2047898..d71d910 100644
index 2047898..1c091f8 100644
--- a/src/GUI/FileDialog.cxx
--- a/src/GUI/FileDialog.cxx
+++ b/src/GUI/FileDialog.cxx
+++ b/src/GUI/FileDialog.cxx
@@ -100,6 +100,10 @@ public:
@@ -99,15 +99,22 @@ public:
        func(f),
         object(obj)
         object(obj)
     {
     {
        FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
-        FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
+        FGNasalSys* sys = globals->get_subsystem<FGNasalSys>();
+        if(!sys) {
+        if(!sys) {
+ NASAL_DISABLED("FileDialog");
+ NASAL_DISABLED("FileDialog");
Line 224: Line 241:
         _gcKeys[1] = sys->gcSave(obj);
         _gcKeys[1] = sys->gcSave(obj);
     }
     }
@@ -107,7 +111,10 @@ public:
   
     virtual void onFileDialogDone(FGFileDialog* instance, const SGPath& aPath)
     virtual void onFileDialogDone(FGFileDialog* instance, const SGPath& aPath)
     {
     {
        FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
-        FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
-         
-         
+        FGNasalSys* sys = globals->get_subsystem<FGNasalSys>();
+        if(!sys) {
+        if(!sys) {
+ NASAL_DISABLED("FileDialog (done)");
+ NASAL_DISABLED("FileDialog (done)");
Line 236: Line 254:
         naRef args[1];
         naRef args[1];
         args[0] = nasal::to_nasal(ctx, aPath);
         args[0] = nasal::to_nasal(ctx, aPath);
@@ -119,6 +126,10 @@ public:
@@ -118,7 +125,11 @@ public:
   
     ~NasalCallback()
     ~NasalCallback()
     {
     {
        FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
-        FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
+        FGNasalSys* sys = globals->get_subsystem<FGNasalSys>();
+ if(!sys) {
+ if(!sys) {
+ NASAL_DISABLED("FileDialog");
+ NASAL_DISABLED("FileDialog");
Line 248: Line 268:
     }
     }
diff --git a/src/Input/FGEventInput.cxx b/src/Input/FGEventInput.cxx
diff --git a/src/Input/FGEventInput.cxx b/src/Input/FGEventInput.cxx
index 29bdc6e..7bbab09 100644
index 29bdc6e..2cd0844 100644
--- a/src/Input/FGEventInput.cxx
--- a/src/Input/FGEventInput.cxx
+++ b/src/Input/FGEventInput.cxx
+++ b/src/Input/FGEventInput.cxx
@@ -224,7 +224,7 @@ void FGButtonEvent::fire( FGEventData & eventData )
FGInputDevice::~FGInputDevice()
{
-  FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
+  FGNasalSys *nas = globals->get_subsystem<FGNasalSys>();
  if (nas && deviceNode ) {
    SGPropertyNode_ptr nasal = deviceNode->getNode("nasal");
    if( nasal ) {
@@ -236,6 +236,7 @@ FGInputDevice::~FGInputDevice()
@@ -236,6 +236,7 @@ FGInputDevice::~FGInputDevice()
     }
     }
Line 259: Line 288:
   
   
  void FGInputDevice::Configure( SGPropertyNode_ptr aDeviceNode )
  void FGInputDevice::Configure( SGPropertyNode_ptr aDeviceNode )
@@ -264,7 +265,7 @@ void FGInputDevice::Configure( SGPropertyNode_ptr aDeviceNode )
@@ -261,10 +262,10 @@ void FGInputDevice::Configure( SGPropertyNode_ptr aDeviceNode )
       FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
    SGPropertyNode_ptr open = nasal->getNode("open");
    if (open) {
       const string s = open->getStringValue();
-      FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
+      FGNasalSys *nas = globals->get_subsystem<FGNasalSys>();
       if (nas)
       if (nas)
         nas->createModule(nasalModule.c_str(), nasalModule.c_str(), s.c_str(), s.length(), deviceNode );
         nas->createModule(nasalModule.c_str(), nasalModule.c_str(), s.c_str(), s.length(), deviceNode );
Line 269: Line 302:
  }
  }
diff --git a/src/Input/FGJoystickInput.cxx b/src/Input/FGJoystickInput.cxx
diff --git a/src/Input/FGJoystickInput.cxx b/src/Input/FGJoystickInput.cxx
index 069e9d8..d6d3fd8 100644
index 069e9d8..046b8ce 100644
--- a/src/Input/FGJoystickInput.cxx
--- a/src/Input/FGJoystickInput.cxx
+++ b/src/Input/FGJoystickInput.cxx
+++ b/src/Input/FGJoystickInput.cxx
@@ -163,7 +163,7 @@ void FGJoystickInput::reinit() {
void FGJoystickInput::postinit()
{
-  FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
+  FGNasalSys *nasalsys = globals->get_subsystem<FGNasalSys>();
  SGPropertyNode_ptr js_nodes = fgGetNode("/input/joysticks");
  for (int i = 0; i < MAX_JOYSTICKS; i++) {
@@ -208,14 +208,16 @@ void FGJoystickInput::postinit()
@@ -208,14 +208,16 @@ void FGJoystickInput::postinit()
     std::ostringstream str;
     std::ostringstream str;
Line 291: Line 333:
     // Initialize the axes.
     // Initialize the axes.
diff --git a/src/Input/FGKeyboardInput.cxx b/src/Input/FGKeyboardInput.cxx
diff --git a/src/Input/FGKeyboardInput.cxx b/src/Input/FGKeyboardInput.cxx
index 8ff3d0a..004547e 100644
index 8ff3d0a..716bdcb 100644
--- a/src/Input/FGKeyboardInput.cxx
--- a/src/Input/FGKeyboardInput.cxx
+++ b/src/Input/FGKeyboardInput.cxx
+++ b/src/Input/FGKeyboardInput.cxx
@@ -109,11 +109,13 @@ void FGKeyboardInput::postinit()
@@ -108,12 +108,14 @@ void FGKeyboardInput::postinit()
    key_nodes = fgGetNode("/input/keyboard", true);
   }
   }
   
   
  FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
+  FGNasalSys *nasalsys = globals->get_subsystem<FGNasalSys>();
+  if(nasalsys) {
+  if(nasalsys) {
   PropertyList nasal = key_nodes->getChildren("nasal");
   PropertyList nasal = key_nodes->getChildren("nasal");
Line 328: Line 372:
  /**
  /**
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index 61d3425..b7fea20 100644
index 61d3425..1290087 100644
--- a/src/Main/fg_init.cxx
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -469,7 +469,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
      SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
      fgLoadProps("preferences.xml", globals->get_props());
      SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
-       
+   
      // do not load user settings when reset to default is requested, or if
      // told to explicitly ignore
      if (options->isOptionSet("restore-defaults") || options->isOptionSet("ignore-autosave"))
@@ -904,11 +904,19 @@ void fgPostInitSubsystems()
@@ -904,11 +904,19 @@ void fgPostInitSubsystems()
     // Initialize the Nasal interpreter.
     // Initialize the Nasal interpreter.
Line 352: Line 405:
     st.stamp();
     st.stamp();
     globals->get_subsystem_mgr()->postinit();
     globals->get_subsystem_mgr()->postinit();
@@ -1004,10 +1012,12 @@ void fgStartNewReset()
    SGSubsystemMgr* subsystemManger = globals->get_subsystem_mgr();
    // Nasal is manually inited in fgPostInit, ensure it's already shutdown
    // before other subsystems, so Nasal listeners don't fire during shutdown
-    SGSubsystem* nasal = subsystemManger->get_subsystem("nasal");
+    SGSubsystem* nasal = subsystemManger->get_subsystem<FGNasalSys>();
+    if(nasal) {
    nasal->shutdown();
    nasal->unbind();
    subsystemManger->remove("nasal");
+    } else NASAL_DISABLED("reset");
   
    subsystemManger->shutdown();
    subsystemManger->unbind();
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index 3c412ca..2292e3e 100644
index 3c412ca..2292e3e 100644
Line 365: Line 432:
   
   
diff --git a/src/Network/ATC-Main.cxx b/src/Network/ATC-Main.cxx
diff --git a/src/Network/ATC-Main.cxx b/src/Network/ATC-Main.cxx
index 6c0da9b..00cd91a 100644
index 6c0da9b..68e0436 100644
--- a/src/Network/ATC-Main.cxx
--- a/src/Network/ATC-Main.cxx
+++ b/src/Network/ATC-Main.cxx
+++ b/src/Network/ATC-Main.cxx
@@ -223,10 +223,12 @@ bool FGATCMain::process() {
@@ -222,11 +222,13 @@ bool FGATCMain::process() {
    // functionality from the interface than the ATC hardware can
     // directly provide.
     // directly provide.
   
   
    FGNasalSys *n = (FGNasalSys*)globals->get_subsystem("nasal");
-    FGNasalSys *n = (FGNasalSys*)globals->get_subsystem("nasal");
+    FGNasalSys *n = globals->get_subsystem<FGNasalSys>();
+    if(n) {
+    if(n) {
     bool result = n->parseAndRun( "atcsim.update()" );
     bool result = n->parseAndRun( "atcsim.update()" );

Navigation menu