From 177c5ec709810c534b0bd8da4c1a1175d9b414d7 Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Wed, 30 Mar 2016 17:09:33 +0100
Subject: [PATCH] Guard against disabling a not-yet-active catalog.

---
 simgear/package/Root.cxx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/simgear/package/Root.cxx b/simgear/package/Root.cxx
index 7f2e8ea8..c158dbdd 100644
--- a/simgear/package/Root.cxx
+++ b/simgear/package/Root.cxx
@@ -532,8 +532,10 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason)
         }
 
         // and remove it from the active collection
-        d->catalogs.erase(catIt);
-    }
+        if (catIt != d->catalogs.end()) {
+            d->catalogs.erase(catIt);
+        }
+    } // of catalog has errors case
 
     if (d->refreshing.empty()) {
         d->fireRefreshStatus(CatalogRef(), Delegate::STATUS_REFRESHED);
-- 
2.39.5