File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ class CallCancelled(Exception):
6565_isPumpPending = False
6666
6767_hasShutdownBeenTriggered = False
68+ _has_doShutdownCompleted = False
6869_shuttingDownFlagLock = threading .Lock ()
6970
7071
@@ -297,12 +298,14 @@ def _doShutdown(newNVDA: Optional[NewNVDAInstance]):
297298 _closeAllWindows ()
298299 if newNVDA is not None :
299300 _startNewInstance (newNVDA )
301+ global _has_doShutdownCompleted
302+ _has_doShutdownCompleted = True
300303
301304
302305def triggerNVDAExit (newNVDA : Optional [NewNVDAInstance ] = None ) -> bool :
303306 """
304307 Used to safely exit NVDA. If a new instance is required to start after exit, queue one by specifying
305- instance information with `newNVDA`.
308+ instance information with `newNVDA`. Waits until _doShutdown has completed.
306309 @return: True if this is the first call to trigger the exit, and the shutdown event was queued.
307310 """
308311 import queueHandler
@@ -313,6 +316,9 @@ def triggerNVDAExit(newNVDA: Optional[NewNVDAInstance] = None) -> bool:
313316 queueHandler .queueFunction (queueHandler .eventQueue , _doShutdown , newNVDA )
314317 _hasShutdownBeenTriggered = True
315318 log .debug ("_doShutdown has been queued" )
319+ while not _has_doShutdownCompleted :
320+ time .sleep (0.1 )
321+ log .debug ("_doShutdown has completed" )
316322 return True
317323 else :
318324 log .debug ("NVDA has already been triggered to exit safely." )
You can’t perform that action at this time.
0 commit comments