Skip to content

Commit

Permalink
[NUI][AT-SPI] Detach NUIViewAccessible in View.Dispose()
Browse files Browse the repository at this point in the history
The application may crash if the View is disposed but the Accessibility
infrastructure calls one of the View methods. Detaching the
NUIViewAccessible proxy object in View.Dispose() should prevent that.
  • Loading branch information
Artur Świgoń authored and jaehyun0cho committed Oct 30, 2023
1 parent 75a3e9a commit f3d47ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ private AccessibilityDelegate()

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_SetAccessibilityDelegate")]
public static extern IntPtr DaliAccessibilitySetAccessibilityDelegate(IntPtr arg1_accessibilityDelegate, uint arg2_accessibilityDelegateSize);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_DetachAccessibleObject")]
public static extern void DaliAccessibilityDetachAccessibleObject(HandleRef arg1_control);
}
}
}
3 changes: 3 additions & 0 deletions src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ protected override void Dispose(bool disposing)

internalName = null;

Interop.ControlDevel.DaliAccessibilityDetachAccessibleObject(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();

if (disposing == false)
{
if (IsNativeHandleInvalid() || SwigCMemOwn == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static View GetViewFromRefObject(IntPtr refObjectPtr)

if (view is null)
{
NUILog.Error($"RefObject 0x{refObjectPtr:x} is not a View");
throw new ArgumentException($"RefObject 0x{refObjectPtr:x} is not a View", nameof(refObjectPtr));
}

return view;
Expand All @@ -70,9 +70,7 @@ private static T GetInterfaceFromRefObject<T>(IntPtr refObjectPtr)
return atspiInterface;
}

NUILog.Error($"RefObject 0x{refObjectPtr:x} is not a {typeof(T).FullName}");

return default(T);
throw new ArgumentException($"RefObject 0x{refObjectPtr:x} is not a {typeof(T).FullName}", nameof(refObjectPtr));
}

private static IntPtr DuplicateString(string value)
Expand Down Expand Up @@ -113,8 +111,6 @@ private static void InitializeAccessibilityDelegateAccessibleInterface()
private static ulong AccessibilityCalculateStatesWrapper(IntPtr self, ulong initialStates)
{
View view = GetViewFromRefObject(self);
if (view == null)
return 0UL;

ulong bitMask = 0UL;

Expand Down

0 comments on commit f3d47ed

Please sign in to comment.