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

Keep Variant type after zero() #84597

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,13 @@ void Variant::zero() {
break;

default:
Type prev_type = type;
this->clear();
if (type != prev_type) {
// clear() changes type to NIL, so it needs to be restored.
Copy link
Member

Choose a reason for hiding this comment

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

Might be slighter better to add a bool reset_type = true to clear() instead of doing it like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

_clear_internal() called by clear() will free the internal data, so it needs to be re-created.
The best solution would be probably reworking zero() to not use clear().

Callable::CallError ce;
Variant::construct(prev_type, *this, nullptr, 0, ce);
}
break;
}
}
Expand Down
Loading