csharp: Add some null checks.
Summary: - Check for nullness when getting stuff from C# to C - We should return null when wrapping a NULL pointer instead of throwing an exception Reviewers: felipealmeida, vitor.sousa, woohyun Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8580
This commit is contained in:
parent
df3b28b0ab
commit
e7e1d777f1
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -589,6 +589,12 @@ public class Globals
|
|||
/// <returns>The C# wrapper for this instance.</returns>
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue