From a4db439cf8be3cf836c2ab5f7d2373409b624900 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <seth@kipro-pcb.com>
Date: Thu, 16 Dec 2021 14:26:27 -0800
Subject: [PATCH] Move quitting flag to manager quit

The flag is to protect against the frame going out of scope with the
references intact.  This shouldn't be in CloseProject because we close
the project without removing the frame.  Instead, placing it in OnExit
gets set correctly when closing the whole project manager

Fixes https://gitlab.com/kicad/code/kicad/issues/10018
---
 kicad/kicad_manager_frame.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp
index c2f71efd5c..246abed524 100644
--- a/kicad/kicad_manager_frame.cpp
+++ b/kicad/kicad_manager_frame.cpp
@@ -394,6 +394,7 @@ void KICAD_MANAGER_FRAME::doCloseWindow()
 #endif
 
     m_leftWin->Show( false );
+    Pgm().m_Quitting = true;
 
     Destroy();
 
@@ -435,8 +436,6 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
 
     m_leftWin->EmptyTreePrj();
 
-    Pgm().m_Quitting = true;
-
     return true;
 }