private IntPtr ToPointer()
{
IntPtr drawOptionsPtr = NativeInterop.AllocStructure<cpSpaceDebugDrawOptions>();
- try
+ if (Marshal.SizeOf(typeof(cpSpaceDebugDrawOptions)) == 0)
{
- Marshal.StructureToPtr<cpSpaceDebugDrawOptions>(this, drawOptionsPtr, false);
+ throw new ArgumentNullException("The size of type cpSpaceDebugDrawOptions should not be 0.");
}
- catch (Exception exception)
- {
- Tizen.Log.Fatal("NUI", "[Error] got exception during Marshal.StructureToPtr, this should not occur, message : " + exception.Message);
- }
-
+
+ Marshal.StructureToPtr<cpSpaceDebugDrawOptions>(this, drawOptionsPtr, false);
+
return drawOptionsPtr;
}
Values[node] = value;
}
-
- if (value != null && value is BindableObject)
- NameScope.SetNameScope(value as BindableObject, node.Namescope);
+ var bindableObject = value as BindableObject;
+ if (bindableObject != null)
+ NameScope.SetNameScope(bindableObject, node.Namescope);
}
public void Visit(RootNode node, INode parentNode)
{
unsafe
{
- if (textures != null && sizeof(IntPtr) * textures.Count > 0)
+
+ if (textures != null)
{
- IntPtr unmanagedPointer = Marshal.AllocHGlobal(checked(sizeof(IntPtr) * textures.Count));
- IntPtr[] texturesArray = new IntPtr[textures.Count];
- for (int i = 0; i < textures.Count; i++)
+ int intptrBytes = checked(sizeof(IntPtr) * textures.Count);
+ if (intptrBytes>0)
{
- texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
- }
- System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);
+ IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
+ IntPtr[] texturesArray = new IntPtr[textures.Count];
+ for (int i = 0; i < textures.Count; i++)
+ {
+ texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
+ }
+ System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);
- Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count);
- Marshal.FreeHGlobal(unmanagedPointer);
+ Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count);
+ Marshal.FreeHGlobal(unmanagedPointer);
+ }
}
}
}