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

Sync Script Changes Does Not Resume After Error in Code is Fixed #28111

Open
BridgetNichols opened this issue Apr 17, 2019 · 3 comments
Open

Comments

@BridgetNichols
Copy link

Godot version:
3.1

OS/device including version:
Mac OS Sierra 10.12.6

Issue description:

When sync script changes is turned on from the debug menu, it works as expected. However, if their is a bug in the code, execution is paused. This is what should happen, but afterwards execution should be resumed. Instead the user has to manually resume execution after fixing the bug. I realized this while watching GDQuest's video. I have linked to the part in the video where he explains this issue basically explaining everything I have already written.

I tried to fix this issue myself, as I feel it shouldn't be too hard to implement, but I've never contributed to a project this big, and I simply can not figure out where the code is that is doing this. If anybody might be able to point me in the right direction I might be able to try and fix this issue. Otherwise, here's a minor issue that may be worth taking a look at.

Steps to reproduce:
Create a test scene and attach a script to the root node. Write a small program in the script such as:

func _process(delta):
     print("test")

Make sure that sync script changes is checked in the debug drop down menu in the top left corner of the editor, and then run the scene. Go back into the editor and create a bug in the code such as:

func _process(delta):
     print("test

This will pause execution as expected. Now fix the error in the code. Execution will not be resumed after fixing the error.

Minimal reproduction project:

Sync Script Changes Issue.zip

@bojidar-bg
Copy link
Contributor

Does manually pressing the "continue" button allow execution to continue untroubled?

@BridgetNichols
Copy link
Author

Yes it does, but I feel that it should resume automatically after the bug is fixed as sync script changes is supposed to make making script changes on the go, smooth. Having to manually press the resume button after fixing a bug, although a small task, really makes the whole process a lot less smooth.

@bojidar-bg
Copy link
Contributor

There are two possible approaches to fixing this problem:

  1. Making the editor resume execution right after syncing changes to scripts.
  2. Do not sync scripts changes if there is a compile-time error in the script.

Here are some locations around the code which might be useful:

  • You can check around here if the script that was saved has errors
    if (!pending_auto_reload && auto_reload_running_scripts) {
    call_deferred("_live_auto_reload_running_scripts");
    pending_auto_reload = true;
    }
  • You can interpret the "reload_scripts" command as "continue" here (maybe even checking if it is a parse error)
    } else if (command == "reload_scripts") {
    reload_all_scripts = true;
  • You can try to not reload scripts with parse errors around here
    for (List<Ref<GDScript> >::Element *E = scripts.front(); E; E = E->next()) {
    print_verbose("GDScript: Reloading: " + E->get()->get_path());
    E->get()->load_source_code(E->get()->get_path());
    E->get()->reload(true);
    }

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