Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Check for null reference before callback #1121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TheFreezebug
Copy link

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.

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.
@@ -64,50 +64,80 @@ public VoiceVtbl()
static private void OnVoiceProcessingPassStartImpl(IntPtr thisObject, int bytes)
{
var shadow = ToShadow<VoiceShadow>(thisObject);
if (shadow == null)
Copy link

@h1cks h1cks Feb 18, 2019

Choose a reason for hiding this comment

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

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants