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 internal CONNECT_INHERITED being saved in PackedScene & Make Local #81737

Merged

Conversation

Mickeon
Copy link
Contributor

@Mickeon Mickeon commented Sep 16, 2023

Fixes #75801.

The title is pretty self-explanatory.
Tested with the attached project. The issue fixes itself after resaving the scene.

It would be nice to receive feedback from KoBeWi because judging by the cause, it seems like I have a tendency to overlooking things.

@Mickeon
Copy link
Contributor Author

Mickeon commented Sep 16, 2023

As a bit of a side note, there seems to be a regression from #81221 where the PopupMenu isn't updated properly, causing some options to be entirely disabled because of that early return.

void ConnectionsDock::_slot_menu_about_to_popup() {
TreeItem *item = tree->get_selected();
if (!item || _get_item_type(*item) != TREE_ITEM_TYPE_CONNECTION) {
return;
}
bool connection_is_inherited = item->has_meta("_inherited_connection");
slot_menu->set_item_disabled(slot_menu->get_item_index(SLOT_MENU_EDIT), connection_is_inherited);
slot_menu->set_item_disabled(slot_menu->get_item_index(SLOT_MENU_DISCONNECT), connection_is_inherited);
}

Worth keeping that in mind when testing.

@KoBeWi
Copy link
Member

KoBeWi commented Sep 16, 2023

As a bit of a side note, there seems to be a regression

I think it should be fixed first, because the popup is broken right now.
As for the PR, it only fixes saving the flag, but you can make new instance and make it local and run into the same issue (until you reload the scene).

@Mickeon
Copy link
Contributor Author

Mickeon commented Sep 16, 2023

Unsure how to handle this, then. "Sanitizing" the input when the scene is made local may make sense, but having it work seamlessly with UndoRedo looks to be overly verbose. Sanitizing it in set_scene_file_path() also seems to make sense to me, but it's a whole new step to an otherwise simple method. Perhaps the usage of a flag included among the rest has been a mistake all along, if it needs to be discarded half the time...

@Mickeon
Copy link
Contributor Author

Mickeon commented Sep 16, 2023

I opened a PR about the aforementioned issue. #81750. Let's see. One thing at the time.

@Mickeon Mickeon force-pushed the fix-connection-inherited-packed-scene branch from 58fbee2 to a9c4bb9 Compare September 16, 2023 23:34
@Mickeon Mickeon requested a review from a team as a code owner September 16, 2023 23:34
@Mickeon Mickeon changed the title Fix internal CONNECT_INHERITED being saved in PackedScene Fix internal CONNECT_INHERITED being saved in PackedScene & Make Local Sep 16, 2023
@Mickeon Mickeon force-pushed the fix-connection-inherited-packed-scene branch from a9c4bb9 to 0053211 Compare September 16, 2023 23:37
@Mickeon
Copy link
Contributor Author

Mickeon commented Sep 16, 2023

This PR has been updated with an (admittedly) shoddy solution to prevent Local Scene from ever keeping CONNECT_INHERITED. The problem now is that I'm unsure how to go about using UndoRedo here, as dealing with the Node dock like this feels like unexplored territory.

@Mickeon
Copy link
Contributor Author

Mickeon commented Sep 18, 2023

I apologise. This PR has been closed on accident because GitHub's links are silly like that.

@@ -1077,6 +1078,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
undo_redo->add_do_method(node, "set_scene_file_path", "");
undo_redo->add_undo_method(node, "set_scene_file_path", node->get_scene_file_path());
_node_replace_owner(node, node, root);
_node_strip_signal_inheritance(node);
NodeDock::get_singleton()->set_node(node); // Refresh.
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there is better way to refresh it.

Copy link
Contributor Author

@Mickeon Mickeon Oct 3, 2023

Choose a reason for hiding this comment

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

I wondered too, but it didn't seem like it because all of the "refreshing" logic is inside the set_node method. It would require moving it out...

Maybe NodeDock::restore_last_valid_node would work just the same? In hindsight, I don't see why not.

Copy link
Member

Choose a reason for hiding this comment

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

It's probably fine for now, but if we ever decide to add early return to set_node() it will stop working.
Though my biggest concern would be that this method is not used outside editor node, so either the dock is not refreshed by anything else or there is a better way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was about to go with the change, but I'll keep set_node() then. The lack of an early return is unexpected though, yeah.

The NodeDock has a pretty simple bunch of methods. None of them are like restore_last_valid_node() or set_node(), so they seem like the closest thing to a refresh?

@KoBeWi
Copy link
Member

KoBeWi commented Oct 3, 2023

I think your new method should be recursive.

@Mickeon Mickeon force-pushed the fix-connection-inherited-packed-scene branch from 0053211 to 021d92f Compare October 3, 2023 13:04
@Mickeon
Copy link
Contributor Author

Mickeon commented Oct 3, 2023

Pushed to use make the connection stripping recursive.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

There are still some problems (like undo not restoring the flag), but at least it fixes the issue, which is more important.

@akien-mga akien-mga changed the title Fix internal CONNECT_INHERITED being saved in PackedScene & Make Local Fix internal CONNECT_INHERITED being saved in PackedScene & Make Local Oct 24, 2023
@akien-mga akien-mga merged commit f41e07b into godotengine:master Oct 24, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@Mickeon Mickeon deleted the fix-connection-inherited-packed-scene branch December 30, 2023 11:10
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.

Can't disconnect a connection after making an instance local
4 participants