This repository was archived by the owner on Mar 30, 2019. It is now read-only.
Check for null reference before callback#1121
Open
TheFreezebug wants to merge 1 commit intosharpdx:masterfrom
Open
Check for null reference before callback#1121TheFreezebug wants to merge 1 commit intosharpdx:masterfrom
TheFreezebug wants to merge 1 commit intosharpdx:masterfrom
Conversation
During high-speed usage, callbacks will throw a null-reference error because the object has been deleted or collected before the callback can be executed on it. Add checks to see if the object is still valid.
h1cks
reviewed
Feb 18, 2019
| static private void OnVoiceProcessingPassStartImpl(IntPtr thisObject, int bytes) | ||
| { | ||
| var shadow = ToShadow<VoiceShadow>(thisObject); | ||
| if (shadow == null) |
There was a problem hiding this comment.
Coding style only comments.
Would you not use "If (Shadow != null)" and nest the logic?
Or would you also consider using and I have not tested this, so it might not be valid -
var callback = (VoiceCallback)shadow?.Callback;
callback?.OnVoiceProcessingPassStart(bytes);
only a passing question.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During high-speed usage, callbacks will throw a null-reference error because the object has been deleted or collected before the callback can be executed on it. Add checks to see if the object is still valid.