From b38271f9ae01aa82931c801ea1048627f7581695 Mon Sep 17 00:00:00 2001
From: Automatic Release Builder <build@flightgear.org>
Date: Tue, 29 Sep 2020 17:44:36 +0100
Subject: [PATCH] Autopilot: don't warn on un-nmed APs

When no name is defined at all, suppress the 'duplicate name' warning.
---
 src/Autopilot/autopilot.cxx | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/Autopilot/autopilot.cxx b/src/Autopilot/autopilot.cxx
index d4a111b95..5f0014fb2 100644
--- a/src/Autopilot/autopilot.cxx
+++ b/src/Autopilot/autopilot.cxx
@@ -212,16 +212,23 @@ void Autopilot::add_component( Component * component, double updateInterval )
   if( component == NULL ) return;
 
   // check for duplicate name
-  std::string name = component->subsystemId();
-  for( unsigned i = 0; get_subsystem( name.c_str() ) != NULL; i++ ) {
+  const auto originalName = string{component->subsystemId()};
+  std::string name = originalName;
+  if (name.empty()) {
+    name = "unnamed_autopilot";
+  } 
+
+  for( unsigned int i = 0; get_subsystem( name) != nullptr; i++ ) {
       std::ostringstream buf;
       buf <<  component->subsystemId() << "_" << i;
       name = buf.str();
   }
-  if( name != component->subsystemId() )
-    SG_LOG( SG_AUTOPILOT, SG_DEV_WARN, "Duplicate autopilot component " << component->subsystemId() << ", renamed to " << name );
 
-  set_subsystem( name.c_str(), component, updateInterval );
+  if (!originalName.empty() && (name != originalName)) {
+    SG_LOG( SG_AUTOPILOT, SG_DEV_WARN, "Duplicate autopilot component " << originalName << ", renamed to " << name );
+  }
+
+  set_subsystem( name, component, updateInterval );
 }
 
 void Autopilot::update( double dt )