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

Cleanup of raw nullptr checks with Ref #96292

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

AThousandShips
Copy link
Member

With optional second commit fully forbidding these comparisons, used to identify these cases, I'd say this should be integrated as we don't really permit checking against nullptr and it'd be good to simply enforce it, though the error messages can be a bit cryptic at times so leaving it open

@@ -1449,7 +1449,7 @@ void ScriptEditor::_menu_option(int p_option) {

case FILE_TOOL_RELOAD_SOFT: {
Ref<Script> scr = current->get_edited_resource();
if (scr == nullptr || scr.is_null()) {
if (scr.is_null()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

These cases were redunant

Copy link
Contributor

@Hilderin Hilderin left a comment

Choose a reason for hiding this comment

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

That should be very useful!! Everything looks good.

Using `is_valid/null` over checks with `nullptr` or `ERR_FAIL_NULL` etc.
@AThousandShips
Copy link
Member Author

If there's no issues with deleting the operators for future proofing I'll go ahead and squash (I'll keep the operators in godot-cpp for backwards compatibility, as we don't have any DISABLE_DEPRECATED there, and I'll leave a note to not copy it over)

@akien-mga
Copy link
Member

I'd agree with deleting the nullptr operators in principle, but this will break compatibility with C++ modules or forks and not just godot-cpp, and in a way that might irritate users, as they might not strive for the same consistency in their codebases.

So I think we need to keep them for compatibility. We can maybe keep them with #ifndef DISABLE_DEPRECATED, so we still have a way to remove them for updating the engine (and this should also be checked by CI, at least on the "Minimal template" build, so not covering the whole codebase).

@AThousandShips
Copy link
Member Author

I'll go ahead and split them off into a separate PR and look at perhaps adding a new define for stricter null-checks or something, as I think DISABLE_DEPRECATED might be too inappropriate for this, and we can work on a good general solution

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Sep 2, 2024
@akien-mga akien-mga merged commit d15de6f into godotengine:master Sep 3, 2024
19 checks passed
@akien-mga
Copy link
Member

Thanks!

@AThousandShips AThousandShips deleted the null_check_ref_fix branch September 3, 2024 14:21
@AThousandShips
Copy link
Member Author

Thank you!

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.

5 participants