From d252740307a659ab85e6b4dda0837bf902823707 Mon Sep 17 00:00:00 2001
From: Automatic Release Builder <build@flightgear.org>
Date: Mon, 5 Oct 2020 14:23:40 +0100
Subject: [PATCH] Adjust for changed SGXMLSound API

Detect bool return value from init(), use this to allow calmer
failures. Requires corresponding SG commit.
---
 src/Sound/fg_fx.cxx | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx
index 9f688cd8d..fb90d2e66 100644
--- a/src/Sound/fg_fx.cxx
+++ b/src/Sound/fg_fx.cxx
@@ -139,15 +139,17 @@ FGFX::init()
     node = root.getNode("fx");
     if(node) {
         for (int i = 0; i < node->nChildren(); ++i) {
-            SGXmlSound *soundfx = new SGXmlSound();
+            std::unique_ptr<SGXmlSound> soundfx{new SGXmlSound};
   
             try {
-                soundfx->init( _props, node->getChild(i), this, _avionics,
+                bool ok = soundfx->init( _props, node->getChild(i), this, _avionics,
                                path.dir() );
-                _sound.push_back( soundfx );
+                if (ok) {
+                    // take the pointer out of the unique ptr so it's not deleted
+                    _sound.push_back( soundfx.release() );
+                }
             } catch ( sg_exception &e ) {
                 SG_LOG(SG_SOUND, SG_ALERT, e.getFormattedMessage());
-                delete soundfx;
             }
         }
     }