mono / VulkanSharp

Open source .NET binding for the Vulkan API
MIT License
538 stars 61 forks source link

Generator assumes non-null struct member IDisposables. #81

Open plynkus opened 5 years ago

plynkus commented 5 years ago

Observed: NREs fired during disposal of valid WriteDescriptorSet instances (some members null).

Current generated Dispose() for WriteDescriptorSet:

        override public void Dispose (bool disposing)
        {
            base.Dispose (disposing);
            if (!disposing)
                return;
            refImageInfo.Dispose ();
            refImageInfo = null;
            refBufferInfo.Dispose ();
            refBufferInfo = null;
            refTexelBufferView.Dispose ();
            refTexelBufferView = null;
        }

...but per the spec, null is valid for each (ignored, depending on the rest of the configuration).

Suggested fix (not locally tested here but seems pretty obvious) is to change the generator's disposal emits to, e.g., refImageInfo?.Dispose ();.