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

Revert invalid PopupMenu breaking change from #61102 #61181

Merged
merged 1 commit into from
May 19, 2022

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga added this to the 3.5 milestone May 19, 2022
@akien-mga akien-mga requested a review from timothyqiu May 19, 2022 08:04
@akien-mga akien-mga requested a review from a team as a code owner May 19, 2022 08:04
Copy link
Member

@timothyqiu timothyqiu left a comment

Choose a reason for hiding this comment

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

I also spotted a documentation error.

<method name="get_selected_id" qualifiers="const">
<return type="int" />
<description>
Returns the ID of the selected item, or [code]-1[/code] if no item is selected.
</description>

The special return value is not changed on 3.x

int OptionButton::get_selected_id() const {
int idx = get_selected();
if (idx < 0) {
return 0;
}

@akien-mga
Copy link
Member Author

Hm maybe we should actually do that tiny compat breakage for 3.5, it feels more like a bugfix than an arbitrary behavior change. Since currently there would be no way to differentiate between "item 0 selected" and "no item selected".

@timothyqiu
Copy link
Member

timothyqiu commented May 19, 2022

@akien-mga It's the ID of that item, not index.

When using the default ID (passing -1 to the parameter), the auto assigned ID starts from 1. selected / get_selected() returns -1 if nothing selected. It's kind of a more suitable way to check if anything is selected.

But yeah, -1 will never be a valid ID. So it's either the doc or the implementation that should be changed :P

@okla
Copy link

okla commented May 19, 2022

I also spotted a documentation error.

<method name="get_selected_id" qualifiers="const">
<return type="int" />
<description>
Returns the ID of the selected item, or [code]-1[/code] if no item is selected.
</description>

The special return value is not changed on 3.x

int OptionButton::get_selected_id() const {
int idx = get_selected();
if (idx < 0) {
return 0;
}

Looks like I've missed get_selected_id() change in backport commit. It should contain only return get_item_id(current); now. So the documentation is right, code is wrong.

@okla
Copy link

okla commented May 19, 2022

Maybe backport #54647 instead of reverting?

Edit: or better not, since it depends on another PR...

@okla
Copy link

okla commented May 19, 2022

I also spotted a documentation error.

<method name="get_selected_id" qualifiers="const">
<return type="int" />
<description>
Returns the ID of the selected item, or [code]-1[/code] if no item is selected.
</description>

The special return value is not changed on 3.x

int OptionButton::get_selected_id() const {
int idx = get_selected();
if (idx < 0) {
return 0;
}

Looks like I've missed get_selected_id() change in backport commit. It should contain only return get_item_id(current); now. So the documentation is right, code is wrong.

Corresponding change is here #61185

@akien-mga
Copy link
Member Author

Maybe backport #54647 instead of reverting?

It seems to build upon #54533... the rabbit hole starts getting deep :) I prefer that we only backport what users actively need in their 3.x projects, not general API consistency improvements done in 4.0 while breaking compat.

@okla
Copy link

okla commented May 19, 2022

Maybe backport #54647 instead of reverting?

It seems to build upon #54533... the rabbit hole starts getting deep :) I prefer that we only backport what users actively need in their 3.x projects, not general API consistency improvements done in 4.0 while breaking compat.

Yeah, I've already edited my message)

@akien-mga akien-mga merged commit 6f6c5b7 into godotengine:3.x May 19, 2022
@akien-mga akien-mga deleted the 3.x-fix-PopupMenu-regression branch May 19, 2022 09:55
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.

3 participants