Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code editor: deleting folder containing scripts does not auto-close scripts. Batch closing them later causes errors. #75068

Open
hsandt opened this issue Mar 18, 2023 · 0 comments

Comments

@hsandt
Copy link
Contributor

hsandt commented Mar 18, 2023

Godot version

v4.0.stable.official [92bee43]

System information

Linux Ubuntu 22.04 with Unity desktop

Issue description

Deleting a script open in the code editor auto-closes it, even if it has unsaved changes. This works as expected when directly selecting and deleting one or multiple scripts.

When deleting a folder containing open scripts, however, the auto-close does not work as expected. Instead, the deleted scripts remain open in the Code editor, and their name is changed to "Uns[unsaved]" with the dirty symbol "(*)".

Godot 4 0 - Delete folder with opened scripts leaves scripts unsaved

Furthermore, if you try to Close All or Close Other Tabs to batch close such leftover files, then press either Discard, Cancel or Save, you can encounter one of the three following errors:

Error 1:

After the first Discard/Cancel/Save, you may see:

Signal 'visibility_changed' is already connected to given callable 'ScriptEditor::_queue_close_tabs' in that object.

If you selected Discard or Save, the file is closed (it is never saved). The second file will be renamed just "unsaved".

You can then Discard/Cancel/Save again, but if whatever you choose, it will stop the batch operation there.

In other words, you can close at most 2 files.

Here is a GIF focused on the batch close stopping after two files:

Godot 4 0 - Close other tabs on unsaved deleted scripts stops suddenly after visibility_changed and viewport errors

Error 2

Sometimes, instead of Error 1, batch close works, but you'll see a repeated error (one per file). For 5 files (total, saved or unsaved deleted):

scene/gui/tab_bar.cpp:597 - Index p_current = 4 is out of bounds (get_tab_count() = 4).
scene/gui/tab_bar.cpp:597 - Index p_current = 3 is out of bounds (get_tab_count() = 3).
scene/gui/tab_bar.cpp:597 - Index p_current = 2 is out of bounds (get_tab_count() = 2).
scene/gui/tab_bar.cpp:597 - Index p_current = 1 is out of bounds (get_tab_count() = 1).
scene/gui/tab_bar.cpp:597 - Index p_current = 0 is out of bounds (get_tab_count() = 0).

Error 3:

Often, after Error 1 or Error 2, you'll also see this:

Can't make active a Viewport that is already active.
Can't make active a Viewport that is already active.

Of course, fixing the first issue should fix the later errors. However, if there are other ways to make unsaved deleted files appear, then the errors on batch close should be fixed too.

(one technique to have extra safety is to fix the later errors first, then fix the first bug at the end)

Steps to reproduce

  1. Open the Script editor and open new_script and all its numbered variants under new folder
  2. Delete new folder

Main bug: the scripts deleted together with the new folder are not auto-closed. Instead, they remain open in the Code editor, and their name is changed to "Uns[unsaved]" with the dirty symbol "(*)"

Then to trigger side-effect errors:

  1. Right-click or File > Close All or Close Other Tabs
  2. In popup, select Discard/Cancel/Save (Discard shows better how files don't all close, and Save shows better how files don't save)
  3. See Error 1 or Error 2 + optionally Error 3
  4. If you see Error 1, you have a second popup. Select Discard/Cancel/Save again.
  5. Note that there is no further popup, so we could not close all the files.

Minimal reproduction project

v4.0 - Close other tabs with deleted scripts fails.zip

@hsandt hsandt changed the title Code editor: deleting folder containing scripts does not auto-close scripts. Closing them later causes errors. Code editor: deleting folder containing scripts does not auto-close scripts. Batch closing them later causes errors. Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants