Browse Source

Clarified the handling of dtor calls when abstract classes are involved.

Thanks to tritao for his remarks.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/256/merge
Dimitar Dobrev 10 years ago
parent
commit
176262c700
  1. 9
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

9
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -513,7 +513,10 @@ namespace CppSharp.Generators.CSharp @@ -513,7 +513,10 @@ namespace CppSharp.Generators.CSharp
return;
if (method.IsProxy ||
(method.IsVirtual && !method.IsOperator && !(method.IsDestructor && @class.IsAbstract)))
(method.IsVirtual && !method.IsOperator &&
// virtual destructors in abstract classes may lack a pointer in the v-table
// so they have to be called by symbol and therefore not ignored
!(method.IsDestructor && @class.IsAbstract)))
return;
functions.Add(method);
@ -1700,7 +1703,11 @@ namespace CppSharp.Generators.CSharp @@ -1700,7 +1703,11 @@ namespace CppSharp.Generators.CSharp
var baseDtor = @class.BaseClass == null ? null :
@class.BaseClass.Destructors.FirstOrDefault(d => !d.IsVirtual);
if (ShouldGenerateClassNativeField(@class) || (dtor != null && baseDtor != null) ||
// virtual destructors in abstract classes may lack a pointer in the v-table
// so they have to be called by symbol; thus we need an explicit Dispose override
@class.IsAbstract ||
// if the base type is abstract and the current type not,
// we need the regular v-table call so we have to override Dispose again
(!@class.IsAbstractImpl && @class.BaseClass != null && @class.BaseClass.IsAbstract))
GenerateDisposeMethods(@class);
}

Loading…
Cancel
Save