Skip to content

Commit

Permalink
[NUI] Fix some SVACE issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhao02 authored and hinohie committed Oct 25, 2023
1 parent 1673f02 commit 23fbd19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ internal struct cpSpaceDebugDrawOptions
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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ public void Visit(ElementNode node, INode parentNode)

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)
Expand Down
23 changes: 14 additions & 9 deletions src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,23 @@ public void BindTextureResources(List<Texture> textures)
{
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);
}
}
}
}
Expand Down

0 comments on commit 23fbd19

Please sign in to comment.