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

Fix error when closing Attach Node Script window #34478

Merged
merged 1 commit into from
Jan 2, 2020

Conversation

volzhs
Copy link
Contributor

@volzhs volzhs commented Dec 20, 2019

Fix #34471

@akien-mga akien-mga added this to the 3.2 milestone Dec 20, 2019
@@ -2616,7 +2616,7 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) {
}

script_create_dialog->connect("script_created", this, "_script_created");
script_create_dialog->connect("popup_hide", this, "_script_creation_closed");
script_create_dialog->connect("popup_hide", this, "_script_creation_closed", varray(), CONNECT_DEFERRED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could be CONNECT_ONESHOT, and then the disconnect can be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force pushed an amend that does that.

@akien-mga
Copy link
Member

I wonder if it's really needed to do these disconnects at all in the first place. popup_hide is only used here to disconnect the script_created signal, but do we need it disconnected?

The only reason I can think of would be that this ScriptCreateDialog instance is also reused in ScriptEditor, where it's connected but there never disconnected:

editor/plugins/script_editor_plugin.cpp
296:void ScriptEditor::_script_created(Ref<Script> p_script) {
3133:   ClassDB::bind_method("_script_created", &ScriptEditor::_script_created);
3415:   script_create_dialog->connect("script_created", this, "_script_created");

If it works seemlessly to re-connect the signal without having disconnected it first, then we could simply get rid of the disconnect callback.

@akien-mga
Copy link
Member

The only reason I can think of would be that this ScriptCreateDialog instance is also reused in ScriptEditor, where it's connected but there never disconnected:

Actually each class has a separate instance of ScriptCreateDialog, so there's no "reconnection" as I mentioned above. So maybe we can just connect the script_created signal in the constructor and then leave it be.

@akien-mga
Copy link
Member

Actually each class has a separate instance of ScriptCreateDialog, so there's no "reconnection" as I mentioned above. So maybe we can just connect the script_created signal in the constructor and then leave it be.

It seems that's what the code used to do, but it was changed in #30196 by @LikeLakers2 for the sake of editor plugins that call ScriptCreateDialog themselves. Not sure if that PR was the best approach, but it does make some sense so I guess for now we should just stick to making the popup_hide callback a oneshot.

@LikeLakers2
Copy link
Contributor

LikeLakers2 commented Dec 20, 2019

@akien-mga I don't remember it ever having multiple instances of ScriptCreateDialog when I searched through the code (although the last I checked was when I made #30738), whether for editor plugins or otherwise. All get_script_create_dialog()s would inevitably point towards SceneTreeDock's dialog. Or at least, that's how the code looked to me.

That said, I would recommend having multiple ScriptCreateDialog instances if we can code it that way, so long as doing so won't clash with the others. The only reason I haven't done it myself yet is because... I kinda felt it might make a mess of the code when all I wanted to do was fix a bug. Plus I didn't feel right doing that sort of big change just to fix a bug. So... :/

Also: If you want to revert my PR (i.e. if it's just easier to implement your own solution than work off of mine) please feel free to do so. Wouldn't bother me.

@akien-mga akien-mga merged commit dbf907e into godotengine:master Jan 2, 2020
@akien-mga
Copy link
Member

Thanks!

@volzhs volzhs deleted the error-script-create branch January 2, 2020 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempt to disconnect signal 'popup_hide' while in emission callback.
3 participants