-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 dock visibility issues #84122
Fix dock visibility issues #84122
Conversation
a11d1b2
to
43ede54
Compare
Since this fixes a crash, should it be for 4.2? |
Can you please open an issue for the crash part, I don't see it reported in the linked issue, a crash is serious enough to track actively Especially clear steps to replicate the crash so we can confirm it is fixed |
But note also that we're in the late stage of the 4.2 cycle and focus right now is on bugs introduced in 4.2 and fixing them so 4.2 introduces as few new bugs as possible, and as some of this behaviour goes back to 4.0 it's lower priority right now, marked for cherry picking for 4.2 so it can be added to it for 4.2.1 if it doesn't meet the deadline |
Made an issue for the crash: #84125 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't reproduce #66834 to confirm, but everything else seems alright.
// Get the tab properties before they get erased by the child removal. | ||
String tab_title = p_from->get_tab_title(p_from_index); | ||
Ref<Texture2D> tab_icon = p_from->get_tab_icon(p_from_index); | ||
Ref<Texture2D> tab_button_icon = p_from->get_tab_button_icon(p_from_index); | ||
bool tab_disabled = p_from->is_tab_disabled(p_from_index); | ||
bool tab_hidden = p_from->is_tab_hidden(p_from_index); | ||
Variant tab_metadata = p_from->get_tab_metadata(p_from_index); | ||
int tab_icon_max_width = p_from->get_tab_bar()->get_tab_icon_max_width(p_from_index); | ||
|
||
Control *moving_tabc = p_from->get_tab_control(p_from_index); | ||
p_from->remove_child(moving_tabc); | ||
add_child(moving_tabc, true); | ||
|
||
set_tab_title(get_tab_count() - 1, tab_title); | ||
set_tab_icon(get_tab_count() - 1, tab_icon); | ||
set_tab_disabled(get_tab_count() - 1, tab_disabled); | ||
set_tab_metadata(get_tab_count() - 1, tab_metadata); | ||
|
||
if (p_to_index < 0 || p_to_index > get_tab_count() - 1) { | ||
p_to_index = get_tab_count() - 1; | ||
} | ||
move_child(moving_tabc, get_tab_control(p_to_index)->get_index(false)); | ||
|
||
set_tab_title(p_to_index, tab_title); | ||
set_tab_icon(p_to_index, tab_icon); | ||
set_tab_button_icon(p_to_index, tab_button_icon); | ||
set_tab_disabled(p_to_index, tab_disabled); | ||
set_tab_hidden(p_to_index, tab_hidden); | ||
set_tab_metadata(p_to_index, tab_metadata); | ||
get_tab_bar()->set_tab_icon_max_width(p_to_index, tab_icon_max_width); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really maintainable. I think we should create a method in TabBar
that returns a copy of the entire Tab
struct for one tab and add API to TabContainer
which can fetch it and apply it to one of its tabs. It doesn't need to be exposed to scripting, just public for internal use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, this is not a requirement for this PR, but with the number of things we need to keep track of, it's a bigger concern now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good refactoring. I'm not sure about the workaround for the crash. There are no other reports of it, it seems, and this is not a proper fix. So maybe it's not urgent to fix in 4.2 (so the entire PR can be pushed to 4.3, with maybe a cherry-pick later).
I added some reproduction steps on #66834 I only found the crash since I was extracting all dock logic from |
Since this PR is pretty much ready (just too late for 4.2), I think that we should merge it first, and then discuss your other PR built on top of this. |
43ede54
to
82ecff1
Compare
82ecff1
to
a267446
Compare
rebased, changed workaround comment to FIXME, and used set_visible |
Thanks! |
Cherry-picked for 4.2.2. |
Fix dock visibility for Editor Features and distraction free mode.
Updated
TabContainer
'smove_tab_from_tab_container
to preserve all tab data.The crash fix is a workaround, ideally it wouldn't have to close all floating docks. I am working on a different pr that should fix this in the future.
There were 4 separate implementations to update the dock slots visibility:
update_dock_slots_visibility()
,_update_dock_containers()
, in_load_docks_from_config()
, and_dock_tab_changed()
(removed the lines affecting bottom docks for this one, see #39177).I have consolidated them all in
update_dock_slots_visibility()
.