Fix NPEs when accessing getScriptProject() or getCurrentProject()

Fix NPEs when accessing getScriptProject() or getCurrentProject() from non UI thread.