From 9cdcb18c7d8d3802ec1513d0566be3b4fc24daec Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Fri, 23 Oct 2015 12:08:08 +0200
Subject: [PATCH] BUG: try to fix segfault when machine learning application
 are closed

---
 .../ApplicationEngine/src/otbWrapperApplicationRegistry.cxx   | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx
index b6ac088ab4..ea668936fe 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx
@@ -94,6 +94,10 @@ public:
   /** close all handles at program exit */
   ~ApplicationPrivateRegistry()
   {
+  // unregister all ITK factories, because some of them could have been
+  // registered by the shared libs we are about to close.
+  itk::ObjectFactoryBase::UnRegisterAllFactories();
+  // Close all opened shared libs
   AppHandleContainerType::iterator it;
   for (it = m_Container.begin() ; it != m_Container.end() ; ++it)
     {
-- 
GitLab