diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh index c059dd9cbe..d8f03118e7 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh @@ -48,7 +48,7 @@ struct to_internal_field_convert_generator if (klass) { if (!as_generator( - indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n") + indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << "?.NativeHandle ?? System.IntPtr.Zero;\n") .generate(sink, std::make_tuple(field_name, field_name), context)) return false; } @@ -112,7 +112,7 @@ struct to_internal_field_convert_generator else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *") { if (!as_generator( - indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n" + indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << "?.NativeHandle ?? System.IntPtr.Zero;\n" ).generate(sink, std::make_tuple(field_name, field_name), context)) return false; } diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index f3696606d2..83d8fd53ca 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs @@ -589,6 +589,12 @@ public class Globals /// The C# wrapper for this instance. public static Efl.Eo.IWrapper CreateWrapperFor(System.IntPtr handle, bool shouldIncRef=true) { + + if (handle == IntPtr.Zero) + { + return null; + } + IntPtr eoKlass = efl_class_get(handle); if (eoKlass == IntPtr.Zero)