2727import addonHandler
2828import extensionPoints
2929import garbageHandler
30+ import NVDAState
3031
3132
3233# inform those who want to know that NVDA has finished starting up.
@@ -160,7 +161,7 @@ def restartUnsafely():
160161 except ValueError :
161162 pass
162163 options = []
163- if globalVars . runningAsSource :
164+ if NVDAState . isRunningAsSource () :
164165 options .append (os .path .basename (sys .argv [0 ]))
165166 _startNewInstance (NewNVDAInstance (
166167 sys .executable ,
@@ -172,7 +173,7 @@ def restartUnsafely():
172173def restart (disableAddons = False , debugLogging = False ):
173174 """Restarts NVDA by starting a new copy."""
174175 if globalVars .appArgs .launcher :
175- globalVars . exitCode = 3
176+ NVDAState . _setExitCode ( 3 )
176177 if not triggerNVDAExit ():
177178 log .error ("NVDA already in process of exiting, this indicates a logic error." )
178179 return
@@ -185,7 +186,7 @@ def restart(disableAddons=False, debugLogging=False):
185186 except ValueError :
186187 pass
187188 options = []
188- if globalVars . runningAsSource :
189+ if NVDAState . isRunningAsSource () :
189190 options .append (os .path .basename (sys .argv [0 ]))
190191 if disableAddons :
191192 options .append ('--disable-addons' )
@@ -483,8 +484,9 @@ def main():
483484 import mathPres
484485 log .debug ("Initializing MathPlayer" )
485486 mathPres .initialize ()
486- if not globalVars .appArgs .minimal and (time .time ()- globalVars .startTime )> 5 :
487- log .debugWarning ("Slow starting core (%.2f sec)" % (time .time ()- globalVars .startTime ))
487+ timeSinceStart = time .time () - NVDAState .getStartTime ()
488+ if not globalVars .appArgs .minimal and timeSinceStart > 5 :
489+ log .debugWarning ("Slow starting core (%.2f sec)" % timeSinceStart )
488490 # Translators: This is spoken when NVDA is starting.
489491 speech .speakMessage (_ ("Loading NVDA. Please wait..." ))
490492 import wx
@@ -673,7 +675,7 @@ def handlePowerStatusChange(self):
673675 # initialize wxpython localization support
674676 wxLocaleObj = wx .Locale ()
675677 wxLang = getWxLangOrNone ()
676- if not globalVars . runningAsSource :
678+ if not NVDAState . isRunningAsSource () :
677679 wxLocaleObj .AddCatalogLookupPathPrefix (os .path .join (globalVars .appDir , "locale" ))
678680 if wxLang :
679681 try :
@@ -835,9 +837,10 @@ def _doPostNvdaStartupAction():
835837 config .saveOnExit ()
836838
837839 try :
838- if globalVars .focusObject and hasattr (globalVars .focusObject ,"event_loseFocus" ):
840+ focusObject = api .getFocusObject ()
841+ if focusObject and hasattr (focusObject , "event_loseFocus" ):
839842 log .debug ("calling lose focus on object with focus" )
840- globalVars . focusObject .event_loseFocus ()
843+ focusObject .event_loseFocus ()
841844 except :
842845 log .exception ("Lose focus error" )
843846 try :
0 commit comments