Script Editor Colors - Threading problem w/ Qt and Lua

So earlier this evening I wanted to see if I could possibly make some of the syntax highlighting animated in Roblox Studio’s script editor. I wrote a script that looks a bit like this:

while wait() do
	settings().Studio["Built-in Function Color"] = Color3.fromHSV((tick()/5)%1,1,1)
end

When I run this code from the command bar, Roblox Studio crashes.
I turned on the “Show QT warnings in output” Studio setting, and this is what I see in the output when the crash happens:

Oddly enough, if you just paste this line into the command bar and hold down enter to spam the command, the effect works as intended:

settings().Studio["Built-in Function Color"] = Color3.fromHSV((tick()/5)%1,1,1)

I suspect there is some sort of threading issue here, where Lua and Qt are trying to change stuff at the same time and they run into conflicts with each other.

While this isn’t technically a pressing issue, this crash can be replicated inside of a plugin, so a malicious user could crash Roblox Studio using this if they wanted to.

9 Likes

This was sadly the reason I removed on-click editor color packs from my plugin. :frowning:
Hopefully they figure out what’s going on.

My guess is that when it’s run from the commandline (a Qt UI thing) it’ll run in a “thread started with QThread”, until the moment it yields and gets moved to the regular taskscheduler.

Why exactly did you want to animate the editor colors?

because why not
¯\_(ツ)_/¯

I still don’t think it should be crashing.

4 Likes

We should have a fix for this in the next release. I’m used to seeing scripts like this now, I hope you’re happy.

3 Likes

On the bright side, we can also use this to create plugins that let developers quickly switch out themes!

4 Likes