commit 692fd528c401e231db671c75f5ec057dbd1efba1
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Wed Nov 22 11:27:45 2017 +0100

    ref #6925 Set conversation and cdmEntitySession to null for dispose

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/e4/ReferencingObjectsViewE4.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/e4/ReferencingObjectsViewE4.java
index 79c7a2a2d..8f470bee2 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/e4/ReferencingObjectsViewE4.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/e4/ReferencingObjectsViewE4.java
@@ -461,6 +461,7 @@ public class ReferencingObjectsViewE4 extends AbstractCdmEditorPartE4 {
 	public void dispose() {
 	    if(conversation!=null){
 	        conversation.close();
+	        conversation = null;
 	    }
 	}
 
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/CdmAuthorityEditorE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/CdmAuthorityEditorE4.java
index 1da16a438..27fed16dc 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/CdmAuthorityEditorE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/e4/CdmAuthorityEditorE4.java
@@ -137,6 +137,7 @@ public class CdmAuthorityEditorE4 implements IConversationEnabled, IDirtyMarkabl
 	    if(conversation!=null){
 	        conversation.unregisterForDataStoreChanges(this);
 	        conversation.close();
+	        conversation = null;
 	    }
 		if(input!=null){
 		    input.getCdmEntitySession().dispose();
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyListEditorE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyListEditorE4.java
index 9cf7d0756..ae1fc1dd0 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyListEditorE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyListEditorE4.java
@@ -12,6 +12,7 @@ package eu.etaxonomy.taxeditor.editor.key.polytomous.e4;
 import java.util.List;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -240,6 +241,15 @@ public class PolytomousKeyListEditorE4 implements
         menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeylisteditor");
 	}
 
+
+    @PreDestroy
+    public void dispose() {
+        if(input!=null){
+            input.dispose();
+            input.getConversationHolder().close();
+        }
+    }
+
 	public int getTableItemCount() {
 	    if (viewer != null && viewer.getTable() != null) {
 	        return viewer.getTable().getItemCount();
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java
index 2326a4cf9..cea4e0270 100755
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java
@@ -765,9 +765,6 @@ public class ChecklistEditorE4 implements IPartContentHasFactualData, IConversat
      */
     @Override
     public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
-        conversation.clear();
-        conversation.close();
-        conversation = null;
     }
 
     private static final List<String> NODE_INIT_STRATEGY = Arrays.asList(new String[] { "descriptions", //$NON-NLS-1$
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
index b4c3f79c5..b379345d3 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
@@ -496,9 +496,11 @@ public class DerivateView implements IPartContentHasFactualData, IConversationEn
     public void dispose() {
         if(conversation!=null){
             conversation.close();
+            conversation = null;
         }
         if(cdmEntitySession != null) {
             cdmEntitySession.dispose();
+            cdmEntitySession = null;
         }
     }
 
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/CharacterEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/CharacterEditor.java
index c2c5dc2b3..a03c87666 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/CharacterEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/CharacterEditor.java
@@ -247,9 +247,11 @@ public class CharacterEditor
     public void dispose(){
         if(conversation!=null){
             conversation.close();
+            conversation = null;
         }
         if(cdmEntitySession != null) {
             cdmEntitySession.dispose();
+            cdmEntitySession = null;
         }
     }
 
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/AlignmentEditorE4.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/AlignmentEditorE4.java
index 35d38356f..63fa57358 100644
--- a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/AlignmentEditorE4.java
+++ b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/AlignmentEditorE4.java
@@ -376,12 +376,20 @@ public class AlignmentEditorE4 {
 
 
     @PreDestroy
-	public void dispose() {
-		Display.getCurrent().removeFilter(SWT.FocusIn, ACTION_UPDATER);
-		Display.getCurrent().removeFilter(SWT.FocusOut, ACTION_UPDATER);
-		CLIPBOARD.dispose();
+    public void dispose() {
+        Display.getCurrent().removeFilter(SWT.FocusIn, ACTION_UPDATER);
+        Display.getCurrent().removeFilter(SWT.FocusOut, ACTION_UPDATER);
+        CLIPBOARD.dispose();
         input.dispose();
-	}
+
+        if(conversationHolder!=null){
+            conversationHolder.close();
+            conversationHolder = null;
+        }
+        if(input!=null){
+            input.dispose();
+        }
+    }
 
 
 	private void updateStatusBar() {
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/PolytomousKeyViewPartE4.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/PolytomousKeyViewPartE4.java
index 7daade5ad..40f425519 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/PolytomousKeyViewPartE4.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/PolytomousKeyViewPartE4.java
@@ -249,9 +249,11 @@ ICdmChangeListener {
             conversation.unregisterForDataStoreChanges(this);
             conversation.close();
             CdmStore.getContextManager().removeContextListener(contextListener);
+            conversation = null;
         }
         if(cdmEntitySession != null) {
             cdmEntitySession.dispose();
+            cdmEntitySession = null;
         }
         ICdmDataChangeService currentDataChangeService = CdmApplicationState.getCurrentDataChangeService();
         if(currentDataChangeService!=null){
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
index 3849745c5..49f4ad005 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
@@ -292,7 +292,7 @@ public class TaxonNavigatorE4 implements
 	    viewer.setInput(new EmptyRoot());
 	}
 
-	public void restore(IMemento memento, IProgressMonitor monitor) {
+	private void restore(IMemento memento, IProgressMonitor monitor) {
 	    root = new Root(conversation);
 		if (memento == null) {
 		    viewer.setInput(root);
@@ -400,9 +400,11 @@ public class TaxonNavigatorE4 implements
 		dataChangeBehavior = null;
 		if (conversation != null) {
 			conversation.unregisterForDataStoreChanges(this);
+			conversation = null;
 		}
 		if(cdmEntitySession != null) {
 		    cdmEntitySession.dispose();
+		    cdmEntitySession = null;
 		}
 		if(CdmApplicationState.getCurrentDataChangeService() != null) {
 		    CdmApplicationState.getCurrentDataChangeService().unregister(this);
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/e4/SearchResultViewE4.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/e4/SearchResultViewE4.java
index 720cf5bdd..2921ed22b 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/e4/SearchResultViewE4.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/e4/SearchResultViewE4.java
@@ -290,6 +290,7 @@ public class SearchResultViewE4 implements IConversationEnabled{
 	public void dispose() {
 		if(conversation!=null){
 		    conversation.close();
+		    conversation = null;
 		}
 		if(searchJob != null) {
             searchJob.cancel();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/CdmEntitySessionInput.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/CdmEntitySessionInput.java
index f05bf4ffb..77cffd6c8 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/CdmEntitySessionInput.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/CdmEntitySessionInput.java
@@ -40,11 +40,14 @@ public abstract class CdmEntitySessionInput implements ICdmEntitySessionEnabled
     }
 
     public void bind() {
-        cdmEntitySession.bind();
+        if(cdmEntitySession!=null){
+            cdmEntitySession.bind();
+        }
     }
 
     public void dispose() {
         cdmEntitySession.dispose();
+        cdmEntitySession = null;
     }
 
     public abstract void merge();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java
index fcf5fa63f..ad9658409 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java
@@ -234,6 +234,7 @@ IPartContentHasDetails, IPartContentHasSupplementalData, IE4SavablePart, IContex
 	    if(conversation!=null){
 	        conversation.unregisterForDataStoreChanges(this);
 	        conversation.close();
+	        conversation = null;
 	    }
 	    if(input!=null){
 	        input.dispose();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
index a000baacf..3a3875357 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
@@ -209,9 +209,11 @@ public class FeatureTreeEditor implements ICdmEntitySessionEnabled, ModifyListen
 	public void dispose(){
         if(conversation!=null){
             conversation.close();
+            conversation = null;
         }
         if(cdmEntitySession != null) {
             cdmEntitySession.dispose();
+            cdmEntitySession = null;
         }
 	}
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java
index 0f41b3266..5c733796e 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java
@@ -55,6 +55,7 @@ public abstract class AbstractNewEntityWizard<T> extends Wizard implements
 
 		conversation.commit();
 		conversation.close();
+		conversation = null;
 		return true;
 	}
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
index 88d9904ed..f830ee7ad 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
@@ -213,6 +213,7 @@ public class EditFromSelectionWizard extends Wizard implements
         super.dispose();
         if(cdmEntitySession != null) {
             cdmEntitySession.dispose();
+            cdmEntitySession = null;
         }
         if(previousCdmEntitySession!=null){
             previousCdmEntitySession.bind();
