From 99f238bbc09d7f06d97c074a8a0c9082b75f7474 Mon Sep 17 00:00:00 2001
From: Ansgar Philippsen <ansgar.philippsen@gmail.com>
Date: Fri, 4 Jan 2013 13:29:55 -0500
Subject: [PATCH] fixed XCS Editor update in buffered mode; added ForceUpdate
 just in case

---
 modules/mol/base/pymod/export_editors.cc | 4 +++-
 modules/mol/base/src/xcs_editor.cc       | 6 ++++++
 modules/mol/base/src/xcs_editor.hh       | 4 ++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/modules/mol/base/pymod/export_editors.cc b/modules/mol/base/pymod/export_editors.cc
index e204bbd2e..6dfe5e837 100644
--- a/modules/mol/base/pymod/export_editors.cc
+++ b/modules/mol/base/pymod/export_editors.cc
@@ -266,7 +266,9 @@ void export_Editors()
     .def("SetTransform", set_transform1)
     .def("SetTransform", set_transform2)
     .def("UpdateICS", &XCSEditor::UpdateICS)
-    .def("__exit__", &XCSEditor::UpdateICS)    
+    .def("ForceUpdate", &XCSEditor::ForceUpdate)
+    .def("__exit__", &XCSEditor::ForceUpdate)    
+    .def("__del__", &XCSEditor::ForceUpdate)    
   ;
   
   class_<ICSEditor, bases<EditorBase> >("ICSEditor", no_init)
diff --git a/modules/mol/base/src/xcs_editor.cc b/modules/mol/base/src/xcs_editor.cc
index 7bf68701d..4b793d33e 100644
--- a/modules/mol/base/src/xcs_editor.cc
+++ b/modules/mol/base/src/xcs_editor.cc
@@ -218,6 +218,12 @@ void XCSEditor::Update()
   }
 }
 
+void XCSEditor::ForceUpdate()
+{
+  ent_.Impl()->UpdateICSIfNeeded();
+  ent_.Impl()->UpdateOrganizerIfNeeded();
+}
+
 void XCSEditor::UpdateICS()
 {
   ent_.Impl()->UpdateICSIfNeeded();
diff --git a/modules/mol/base/src/xcs_editor.hh b/modules/mol/base/src/xcs_editor.hh
index e52d9e4c5..fc992d8c9 100644
--- a/modules/mol/base/src/xcs_editor.hh
+++ b/modules/mol/base/src/xcs_editor.hh
@@ -110,6 +110,10 @@ public:
   /// \brief immediately update internal coordinate system
   void UpdateICS();  
 
+  /// \brief force spatial organizer and ics update
+  /// workaround for delayed dtor call from Python garbage collection
+  void ForceUpdate();
+
 protected:
    XCSEditor(const EntityHandle& ent, EditMode mode);
    
-- 
GitLab