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

Editor: Fix remove_control_from_dock fails when dock is floating. #83512

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

zaevi
Copy link
Contributor

@zaevi zaevi commented Oct 17, 2023

Fixes #78878.

// If the dock is floating, close it first.
for (WindowWrapper *wrapper : floating_docks) {
if (p_control == wrapper->get_wrapped_control()) {
wrapper->set_window_enabled(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

set_window_enabled(false) will emit window_close_requested signal and the control will be back to editor's dock.

@zaevi
Copy link
Contributor Author

zaevi commented Oct 17, 2023

A quick reproduction for #78878:

@tool
extends EditorPlugin

var btn : Button

func _enter_tree():
	btn = Button.new()
	add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BL, btn)

func _exit_tree():
	if btn:
		remove_control_from_docks(btn) # 
		btn.queue_free()
		btn = null
  1. Enable the plugin and make it floating.
  2. Disable the plugin. remove_control_from_docks will fail and the floating window will stay. (this PR fixes)
  3. Close the floating window, causes crash.

@kitbdev
Copy link
Contributor

kitbdev commented Oct 18, 2023

Works as expected and code looks good.

@AThousandShips
Copy link
Member

I believe this matches roughly what I attempted for this, will do some testing of this when I'm able

@AThousandShips AThousandShips requested a review from a team October 18, 2023 15:24
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.

@akien-mga akien-mga merged commit 15955e5 into godotengine:master Oct 20, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

Crash "Control was not in dock." (edgecase)
5 participants