From bca0231dfc6d6166514a50515b3f67f2d17600a9 Mon Sep 17 00:00:00 2001
From: Athanasius <github@miggy.org>
Date: Mon, 11 Jan 2021 16:45:26 +0000
Subject: [PATCH] plugins/edsm: Avoid Tk event_generate() calls during shutdown

---
 plugins/edsm.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/plugins/edsm.py b/plugins/edsm.py
index 80c0077a..a77de879 100644
--- a/plugins/edsm.py
+++ b/plugins/edsm.py
@@ -598,8 +598,10 @@ def worker() -> None:
                             if not closing and e['event'] in ('StartUp', 'Location', 'FSDJump', 'CarrierJump'):
                                 # Update main window's system status
                                 this.lastlookup = r
-                                # calls update_status in main thread
-                                this.system_link.event_generate('<<EDSMStatus>>', when="tail")
+
+                                if not config.shutting_down():
+                                    # calls update_status in main thread
+                                    this.system_link.event_generate('<<EDSMStatus>>', when="tail")
 
                             if r['msgnum'] // 100 != 1:
                                 logger.warning(f'EDSM event with not-1xx status:\n{r["msgnum"]}\n{r["msg"]}\n'