From 58b71ec1d122b13a051a5f1d4223c4794559fc47 Mon Sep 17 00:00:00 2001
From: Michele Alberti <michele.alberti@cea.fr>
Date: Wed, 15 Jul 2020 17:25:25 +0200
Subject: [PATCH] [ivette] Fix selection behavior on shutdown.

---
 ivette/src/frama-c/states.ts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ivette/src/frama-c/states.ts b/ivette/src/frama-c/states.ts
index d337a74dfd4..88301d9ac7e 100644
--- a/ivette/src/frama-c/states.ts
+++ b/ivette/src/frama-c/states.ts
@@ -676,7 +676,8 @@ function reducer(s: Selection, action: SelectionActions): Selection {
   }
 }
 
-const GlobalSelection = new GlobalStates.State<Selection>({
+/** The initial selection is empty. */
+const emptySelection = {
   current: undefined,
   history: {
     prevSelections: [],
@@ -686,7 +687,10 @@ const GlobalSelection = new GlobalStates.State<Selection>({
     index: 0,
     allSelections: [],
   },
-});
+};
+
+const GlobalSelection = new GlobalStates.State<Selection>(emptySelection);
+Server.onShutdown(() => GlobalSelection.setValue(emptySelection));
 
 /**
    Current selection.
-- 
GitLab