Fix 'Open Scripts Externally' crashing studio.

Closes #369.
This commit is contained in:
Lucien Greathouse
2021-04-23 16:59:59 -04:00
parent 3dcb14013b
commit 532d170585
2 changed files with 16 additions and 5 deletions

View File

@@ -4,9 +4,11 @@
* Added the `gameId` and `placeId` optional properties to project files.
* When connecting from the Rojo Roblox Studio plugin, Rojo will set the game and place ID of the current place to these values, if set.
* This is equivalent to running `game:SetUniverseId(...)` and `game:SetPlaceId(...)` from the command bar in Studio.
* Fixed `Name` and `Parent` properties being allowed in Rojo projects. ([#413](pr-413))
* Added "EXPERIMENTAL!" label to two-way sync toggle in Rojo's Roblox Studio plugin.
* Fixed `Name` and `Parent` properties being allowed in Rojo projects. ([#413][pr-413])
* Fixed "Open Scripts Externally" feature crashing Studio ([#369][issue-369])
[issue-369]: https://github.com/rojo-rbx/rojo/issues/369
[pr-413]: https://github.com/rojo-rbx/rojo/pull/413
## [7.0.0-alpha.3][7.0.0-alpha.3] (February 19, 2021)

View File

@@ -1,4 +1,5 @@
local StudioService = game:GetService("StudioService")
local RunService = game:GetService("RunService")
local Log = require(script.Parent.Parent.Log)
local Fmt = require(script.Parent.Parent.Fmt)
@@ -161,10 +162,18 @@ function ServeSession:__onActiveScriptChanged(activeScript)
Log.debug("Trying to open script {} externally...", activeScript)
-- Force-close the script inside Studio
local existingParent = activeScript.Parent
activeScript.Parent = nil
activeScript.Parent = existingParent
-- Force-close the script inside Studio... with a small delay in the middle
-- to prevent Studio from crashing.
spawn(function()
local existingParent = activeScript.Parent
activeScript.Parent = nil
for i = 1, 3 do
RunService.Heartbeat:Wait()
end
activeScript.Parent = existingParent
end)
-- Notify the Rojo server to open this script
self.__apiContext:open(scriptId)