Skip to content

Commit ca0d74f

Browse files
authored
Merge a30fc5b into fed2c63
2 parents fed2c63 + a30fc5b commit ca0d74f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

source/core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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

302305
def 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.")

0 commit comments

Comments
 (0)