godot icon indicating copy to clipboard operation
godot copied to clipboard

Theme editor immediately closing after opening any theme item or simply clicking on viewport

Open Chaosus opened this issue 2 years ago • 4 comments

Godot version

218bef90af2091afde3b1be816c87286c194a2a8

System information

Windows 11

Issue description

I think it's incorrect behaviour - clicking on theme items override or even a main viewport (regardless of 2D or 3D) immediately hides the theme editor.

theme_editor_closing

Steps to reproduce

Open and try to use the theme editor

Minimal reproduction project

TestTheme.zip

Chaosus avatar Jan 28 '23 19:01 Chaosus

I can confirm this on Linux X11. Looks like this bug got introduced between Beta14 and Beta15.

Sauermann avatar Jan 28 '23 21:01 Sauermann

CC @KoBeWi

akien-mga avatar Jan 29 '23 01:01 akien-mga

Just want to mention that it also automatically hides itself if you make any changes to the theme while it is set as the global (custom) theme in the project settings. It produces the following error every time: image

Anixias avatar Jan 29 '23 02:01 Anixias

When you click a stylebox, it gets edited instead of the Theme, hence the editor gets closed. I think there used to be some hack to prevent that. Not sure why does it close when clicking viewport though. It happens even if the Theme is being edited outside any node.

As for the error, _update_type_list() is called with a Timer and throws error if you click the stylebox too fast. To fix it we can stop the debounce timer when the Theme gets unassigned.

KoBeWi avatar Jan 29 '23 11:01 KoBeWi

I think there used to be some hack to prevent that.

It still exists, the theme editor reports that it handles subresources of the currently edited theme, see https://github.com/godotengine/godot/blob/master/editor/plugins/theme_editor_plugin.cpp#L3715

However, I guess it doesn't prevent the new "edit null" call from happening, which closes the editor.

YuriSizov avatar Jan 31 '23 14:01 YuriSizov

edit(null) is needed to free the resource. Otherwise once the editor edits a resource, it will never get unloaded.

Part of this issue can be fixed now, but for complete fix I think we need a better way to handle editor persistence. I'm thinking of something like close button in the Theme editor to allow unloading the resource. Then we could make the editor an editing owner, so it doesn't receive null and allows to edit the Theme without disturbing.

KoBeWi avatar Jan 31 '23 14:01 KoBeWi

So in the end all contextual editors will become persistent editors? 🤔 We "solved" the shader editor issues the same way, basically. I'm not sure this is a good direction, as it removes the perceived simplicity of Godot a bit. We also end up with a bunch of editors with their own open resource list this way, without any unified approach.

Overall, I think editing a subresource of a resource should not drop the context for the parent resource. Intuitively it doesn't make much sense. And that's where the root of the issue is.

YuriSizov avatar Jan 31 '23 14:01 YuriSizov

No, the editor would be not visible until you edit a resource. Then once you edit it, you'd need to close it manually.

Overall, I think editing a subresource of a resource should not drop the context for the parent resource.

The problem is that inspector is the "editing owner" of the Theme. Once you click StyleBox, the inspector will display it instead of the Theme, hence the editor is closed. For the Theme to keep being edited, the editor needs to be still used in some editing context.

KoBeWi avatar Jan 31 '23 14:01 KoBeWi

Link the similar problem (the case of bottom panel has inspector) https://github.com/godotengine/godot/issues/72262

TokageItLab avatar Jan 31 '23 19:01 TokageItLab

I forgot to mention it before, but there was a plan to use instanced inspectors directly inside of the theme editor for all resources, which would solve the usability problem introduced here. Though this was more of a nice-to-have and thus bumped to an unknown release in a future. I could work on it for 4.0 though, if it would solve this more pressing issue.

YuriSizov avatar Feb 03 '23 11:02 YuriSizov

I have this problem too, is there any workaround for this?

ababen1 avatar Feb 10 '23 12:02 ababen1

I can also confirm this issue. It occurs whenever pressing the + button to make a new override, and then when selecting an existing resource. (This is using a custom build I compiled today straight from master branch, running on Debian 11)

Edit: I can also confirm it occurs when removing an override using the bin icon.

SunderB avatar Feb 10 '23 21:02 SunderB

It seems deleting types also causes this issue, and even may crash in deleting the types most commonly the "Fonts" type. If I delete a default imported "Fonts" type from my themes it'll freeze and crash the Godot editor.

Spartan322 avatar Feb 11 '23 11:02 Spartan322

Crashing is tracked in another issue and should be fully fixed by https://github.com/godotengine/godot/pull/73098. The editor closing unexpectedly is partially addressed by that PR, but only for regular properties. For sub-resources it's a big inconvenience, but a proper solution has to wait for the next version, where I'll use embedded inspectors in the Theme editor and avoid using the main inspector for that. You can click the back button in the inspector to go back to the theme once you're done with a font or a stylebox.

YuriSizov avatar Feb 11 '23 13:02 YuriSizov

The theme editor does not close if you use the inspector for editing instead of the in-editor buttons. image

KoBeWi avatar Feb 11 '23 17:02 KoBeWi

Yeah, because I'm pretty sure I explicitly call the edit method of the main inspector, so it switches context. But your workaround is nice for those who are affected.

YuriSizov avatar Feb 11 '23 17:02 YuriSizov

I've found making the theme part of the properties for one of the Control nodes, and clicking/editing the theme from there, can be a temporary solution. Animation

illlustr avatar Feb 12 '23 20:02 illlustr