Index: TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java	(revision 3435)
@@ -925,7 +925,7 @@
 	
 	@Override
 	public boolean needToUpdateIndexes() {
-		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
+		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
 	}
 	
 	@Override
Index: TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java	(revision 3435)
@@ -801,7 +801,7 @@
 	
 	@Override
 	public boolean needToUpdateIndexes() {
-		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
+		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
 	}
 	
 	@Override
Index: TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java	(revision 3435)
@@ -1061,7 +1061,7 @@
 	
 	@Override
 	public boolean needToUpdateIndexes() {
-		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
+		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
 	}
 	
 	@Override
Index: TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java	(revision 3435)
@@ -1051,7 +1051,7 @@
 	
 	@Override
 	public boolean needToUpdateIndexes() {
-		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
+		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
 	}
 	
 	@Override
Index: TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java	(revision 3435)
@@ -48,10 +48,8 @@
 				return null;
 			}
 			
-			
-			
 			if (job.getState() == Status.OK_STATUS.getCode()) {
-				if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES)) {
+				if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE)) {
 					
 					JobHandler job2 = new JobHandler("Updating corpus editions and indexes", true) {
 						
@@ -60,7 +58,7 @@
 							this.runInit(monitor);
 							
 							try {
-								monitor.setTaskName("Updating corpus indexes and editions");
+								monitor.setTaskName("Updating corpus");
 								if (corpus != null && UpdateCorpus.update(corpus, KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)) != null) {
 									monitor.worked(50);
 									this.syncExec(new Runnable() {
Index: TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/preferences/KRAnnotationPreferencePage.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/preferences/KRAnnotationPreferencePage.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/preferences/KRAnnotationPreferencePage.java	(revision 3435)
@@ -28,6 +28,8 @@
 package org.txm.annotation.kr.rcp.preferences;
 
 import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.RowLayout;
@@ -52,6 +54,10 @@
 
 public class KRAnnotationPreferencePage extends TXMPreferencePage {
 	
+	private BooleanFieldEditor updateEditionField;
+	private BooleanFieldEditor updateCorpusField;
+	private Group updateGroup;
+
 	/**
 	 * Instantiates the preference page.
 	 */
@@ -68,8 +74,11 @@
 	public void createFieldEditors() {
 		this.addField(new BooleanFieldEditor(KRAnnotationPreferences.PRESERVE_ANNOTATIONS, "Preserve annotations between TXM sessions", this.getFieldEditorParent()));
 		
-		Group updateGroup = new Group(getFieldEditorParent(), SWT.NONE);
-		updateGroup.setText("Saving annotations");
+		updateCorpusField = new BooleanFieldEditor(KRAnnotationPreferences.UPDATE, "Update corpus after writing the annotations (warning the annotations won't be visible but saved in the XML-TXM files)" , this.getFieldEditorParent());
+		this.addField(updateCorpusField);
+		
+		updateGroup = new Group(getFieldEditorParent(), SWT.NONE);
+		updateGroup.setText("Update option");
 		GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, false);
 		gridData2.horizontalSpan = 3;
 		gridData2.verticalIndent = 10;
@@ -78,12 +87,21 @@
 		rlayout.marginHeight = 5;
 		updateGroup.setLayout(rlayout);
 		
-		this.addField(new BooleanFieldEditor(KRAnnotationPreferences.UPDATE_EDITION, "Update editions" , updateGroup));
-		this.addField(new BooleanFieldEditor(KRAnnotationPreferences.UPDATE_INDEXES, "Update CQP indexes (warning the annotations won't be visible but saved in the XML-TXM files)" , updateGroup));
+		updateEditionField = new BooleanFieldEditor(KRAnnotationPreferences.UPDATE_EDITION, "Update editions" , updateGroup);
+		this.addField(updateEditionField);
 	}
 	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+	 */
+	@Override
+	public void propertyChange(PropertyChangeEvent event) {
+		if (((FieldEditor) event.getSource()).getPreferenceName().equals(KRAnnotationPreferences.UPDATE)) {
+			updateEditionField.setEnabled(updateCorpusField.getBooleanValue(), updateGroup);
+		}
+	}
+	
 	/*
-	 * (non-Javadoc)
 	 * 
 	 * @see
 	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
Index: TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchWindowAdvisor.java
===================================================================
--- TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchWindowAdvisor.java	(revision 3434)
+++ TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchWindowAdvisor.java	(revision 3435)
@@ -27,11 +27,11 @@
 //
 package org.txm.rcp;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.e4.ui.model.application.ui.SideValue;
 import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
 import org.eclipse.e4.ui.model.application.ui.basic.MTrimElement;
@@ -209,9 +209,11 @@
 				}
 			}
 			mess.append("\n\nContinue and lost the unsaved annotations ");
-			return MessageDialog.openConfirm(this.getWindowConfigurer().getWindow().getShell(), "Some annotations are not saved", mess.toString());
-		} else {
-			return true;
+			if(!MessageDialog.openConfirm(this.getWindowConfigurer().getWindow().getShell(), "Some annotations are not saved", mess.toString())) {
+				return false;
+			}
 		}
+		
+		return true;
 	}
 }
Index: TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java
===================================================================
--- TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java	(revision 3434)
+++ TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java	(revision 3435)
@@ -35,6 +35,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.logging.Handler;
@@ -143,7 +144,7 @@
 	/**
 	 * initialization code done after the splash screen.
 	 *
-	 * @param configurer the configurer
+	 * @param configurer the RCP configurer
 	 */
 	@Override
 	public void initialize(IWorkbenchConfigurer configurer) {
@@ -234,6 +235,22 @@
 							return Status.CANCEL_STATUS;
 						}
 						
+						// CREATE THE CLOSE CONTROL FILE
+						if (new File("txm_was_not_closed_correctly.lock").exists()) { // the close control file was not deleted
+							
+							File checkupResultFile = new File("startup_diagnostic_"+Toolbox.dateformat.format(new Date())+".txt");
+							Toolbox.writeStartupCorporaDiagnostics(checkupResultFile);
+							this.syncExec(new Runnable() {
+								@Override
+								public void run() {
+									org.txm.rcp.handlers.files.EditFile.openfile(checkupResultFile);
+								}
+							});
+							
+							new File("txm_was_not_closed_correctly.lock").delete();
+						}
+						new File("txm_was_not_closed_correctly.lock").createNewFile();
+						
 						Log.info(TXMUIMessages.info_txmIsReady);
 						monitor.done();
 					}
@@ -522,6 +539,8 @@
 		Toolbox.shutdown();
 		
 		callStopScript();
+		
+		new File("txm_was_not_closed_correctly.lock").delete();
 	}
 	
 	/**
Index: TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/files/EditFile.java
===================================================================
--- TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/files/EditFile.java	(revision 3434)
+++ TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/files/EditFile.java	(revision 3435)
@@ -95,7 +95,7 @@
 			IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(file.toURI());
 
 			FileStoreEditorInput editorInput = new FileStoreEditorInput(fileOnLocalDisk);
-			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+			IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
 			IWorkbenchPage page = window.getActivePage();
 
 			String ID = null;
Index: TXM/trunk/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/preferences/KRAnnotationPreferences.java
===================================================================
--- TXM/trunk/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/preferences/KRAnnotationPreferences.java	(revision 3434)
+++ TXM/trunk/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/preferences/KRAnnotationPreferences.java	(revision 3435)
@@ -13,7 +13,7 @@
 	
 	public static final String UPDATE_EDITION = "udpate_edition";
 	
-	public static final String UPDATE_INDEXES = "udpate_indexes";
+	public static final String UPDATE = "udpate";
 	
 	public static final String PRESERVE_ANNOTATIONS = "reset_temporary_annotations_when leaving_txm";
 	
@@ -36,7 +36,7 @@
 		super.initializeDefaultPreferences();
 		Preferences preferences = this.getDefaultPreferencesNode();
 		preferences.putBoolean(UPDATE_EDITION, true);
-		preferences.putBoolean(UPDATE_INDEXES, true);
+		preferences.putBoolean(UPDATE, true);
 		preferences.putBoolean(PRESERVE_ANNOTATIONS, false);
 	}
 }
Index: TXM/trunk/org.txm.core/src/java/org/txm/Toolbox.java
===================================================================
--- TXM/trunk/org.txm.core/src/java/org/txm/Toolbox.java	(revision 3434)
+++ TXM/trunk/org.txm.core/src/java/org/txm/Toolbox.java	(revision 3435)
@@ -47,6 +47,9 @@
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.core.internal.registry.osgi.OSGIUtils;
 import org.eclipse.core.internal.resources.Project;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -70,6 +73,7 @@
 import org.txm.utils.LogMonitor;
 import org.txm.utils.OSDetector;
 import org.txm.utils.io.FileCopy;
+import org.txm.utils.io.IOUtils;
 import org.txm.utils.logger.Log;
 
 /**
@@ -829,4 +833,77 @@
 	public static String getConfigurationDirectory() {
 		return OSGIUtils.getDefault().getConfigurationLocation().getURL().toString().substring(5);
 	}
+
+	public static void writeStartupCorporaDiagnostics(File checkupResultFile) {
+		
+		Log.warning(NLS.bind("TXM was not correctly closed, see the report in the ''{0}'' file", checkupResultFile.getAbsolutePath()));
+		
+		StringBuilder builder = new StringBuilder();
+		
+		IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
+		IProject corporaDirectory = rcpWorkspace.getRoot().getProject("corpora");
+		
+		if (!corporaDirectory.exists()) {
+			builder.append("No 'corpora' not found in workspace.");
+			return;
+		}
+		IProject projects[] = rcpWorkspace.getRoot().getProjects();
+		
+		for (IProject rcpProject : projects) {
+
+			if (rcpProject.equals(corporaDirectory)) continue;
+			
+			String s1 = rcpProject.getLocationURI().toString();
+			String s2 = corporaDirectory.getLocationURI().toString();
+			
+			if (!s1.startsWith(s2)) {
+				builder.append("RCP Project: "+rcpProject.getName()+" not in the corpora.\n\n");
+				continue;
+			}
+			
+			org.txm.objects.Project project = Toolbox.workspace.getProject(rcpProject.getName().toUpperCase());
+		
+			if (project == null) {
+				builder.append("Corpus Project: "+rcpProject.getName()+" not found.\n\n");
+				continue;
+			}
+			
+			File indexes = new File(project.getProjectDirectory(), "data/"+project.getName());
+			if (indexes.exists()) {
+				if (indexes.listFiles().length == 0) {
+					builder.append(" no CQP data files in directory: "+indexes.getAbsolutePath());
+					builder.append("\n");
+				}
+			} else {
+				builder.append(" no CQP data directory: "+indexes.getAbsolutePath());
+				builder.append("\n");
+			}
+			
+			builder.append("Project: "+project.getName()+" at "+project.getProjectDirectory());
+			builder.append("\n");
+			builder.append(" creation: "+project.getCreationDate());
+			builder.append("\n");
+			builder.append(" update: "+project.getLastComputingDate());
+			builder.append("\n");
+			builder.append(" 'default' edition: "+project.getEditionDefinition("default"));
+			builder.append("\n");
+			builder.append(" 'facs' edition: "+project.getEditionDefinition("facs"));
+			builder.append("\n");
+			builder.append(" 'preferences': "+TXMPreferences.dumpToString(project.getParametersNodePath()));
+			builder.append("\n");
+			
+			builder.append(" Results: ");
+			builder.append("\n");
+			for (TXMResult result : project.getDeepChildren()) {
+				builder.append("  "+result.getName()+" ("+result.getResultType()+"): "+result.getSimpleDetails());
+				builder.append("\n");
+				builder.append("  'preferences': "+TXMPreferences.dumpToString(result.getParametersNodePath()));
+				builder.append("\n");
+			}
+			builder.append("\n");
+		}
+		
+		IOUtils.write(checkupResultFile, builder.toString());
+		
+	}
 }
