Skip to content

Commit

Permalink
[NUI] the exception occuring is replaced with an error log
Browse files Browse the repository at this point in the history
Because there is no guide for the application and because the application using this API will immediately crash if an exception occurs.
  • Loading branch information
dongsug-song committed Dec 11, 2024
1 parent 0a40bda commit fe4bba6
Showing 1 changed file with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ private static View GetViewFromRefObject(IntPtr refObjectPtr)

if (view is null)
{
throw new ArgumentException($"RefObject 0x{refObjectPtr:x} is not a View", nameof(refObjectPtr));
// There is no guidance for exception handling in the application layer.
// Therefore, it is necessary to modify the code to display error messages to the user instead of exceptions occurring.
Tizen.Log.Error("NUI", $"RefObject 0x{refObjectPtr:x} is not a View nameof{refObjectPtr}");
}

return view;
Expand All @@ -65,6 +67,7 @@ private static View GetViewFromRefObject(IntPtr refObjectPtr)
private static T GetInterfaceFromRefObject<T>(IntPtr refObjectPtr)
{
var view = GetViewFromRefObject(refObjectPtr);
if (view == null) { return default(T); }

// NUIViewAccessible::CallMethod<T> checks whether a given interface is implemented
// before jumping to managed code, so this condition should always be true.
Expand Down Expand Up @@ -114,6 +117,7 @@ private static void InitializeAccessibilityDelegateAccessibleInterface()
private static ulong AccessibilityCalculateStatesWrapper(IntPtr self, ulong initialStates)
{
View view = GetViewFromRefObject(self);
if (view == null) { return 0; }

ulong bitMask = 0UL;

Expand All @@ -130,6 +134,7 @@ private static ulong AccessibilityCalculateStatesWrapper(IntPtr self, ulong init
private static void AccessibilityGetAttributes(IntPtr self, Interop.ControlDevel.AccessibilityDelegate.AccessibilityGetAttributesCallback callback, IntPtr userData)
{
var view = GetViewFromRefObject(self);
if (view == null) { return ; }
var attributes = view.AccessibilityAttributes;
var classKey = "class";

Expand All @@ -151,14 +156,19 @@ private static void AccessibilityGetAttributes(IntPtr self, Interop.ControlDevel

private static IntPtr AccessibilityGetDescriptionWrapper(IntPtr self)
{
string description = GetViewFromRefObject(self).AccessibilityGetDescription();
View view = GetViewFromRefObject(self);
if (view == null) { return IntPtr.Zero;}

string description = view.AccessibilityGetDescription();

return DuplicateString(description);
}

private static uint AccessibilityGetInterfaces(IntPtr self)
{
View view = GetViewFromRefObject(self);
if (view == null) { return 0; }

uint flags = 0U;

if (view is IAtspiEditableText)
Expand Down Expand Up @@ -196,7 +206,10 @@ private static uint AccessibilityGetInterfaces(IntPtr self)

private static IntPtr AccessibilityGetNameWrapper(IntPtr self)
{
string name = GetViewFromRefObject(self).AccessibilityGetName();
View view = GetViewFromRefObject(self);
if (view == null) { return IntPtr.Zero; }

string name = view.AccessibilityGetName();

return DuplicateString(name);
}
Expand All @@ -216,18 +229,26 @@ private static void InitializeAccessibilityDelegateActionInterface()

private static bool AccessibilityDoActionWrapper(IntPtr self, IntPtr name)
{
return GetViewFromRefObject(self).AccessibilityDoAction(Marshal.PtrToStringAnsi(name));
View view = GetViewFromRefObject(self);
if (view == null) { return false; }

return view.AccessibilityDoAction(Marshal.PtrToStringAnsi(name));
}

private static int AccessibilityGetActionCountWrapper(IntPtr self)
{
return GetViewFromRefObject(self).AccessibilityGetActionCount();
View view = GetViewFromRefObject(self);
if (view == null) { return 0; }

return view.AccessibilityGetActionCount();
}

private static IntPtr AccessibilityGetActionNameWrapper(IntPtr self, int index)
{
string name = GetViewFromRefObject(self).AccessibilityGetActionName(index);

View view = GetViewFromRefObject(self);
if (view == null) { return IntPtr.Zero; }

string name = view.AccessibilityGetActionName(index);
return DuplicateString(name);
}

Expand All @@ -244,7 +265,10 @@ private static void InitializeAccessibilityDelegateComponentInterface()

private static bool AccessibilityIsScrollableWrapper(IntPtr self)
{
return GetViewFromRefObject(self).AccessibilityIsScrollable();
View view = GetViewFromRefObject(self);
if (view == null) { return false; }

return view.AccessibilityIsScrollable();
}

//
Expand Down Expand Up @@ -678,6 +702,8 @@ private static double AccessibilityGetMinimumIncrementWrapper(IntPtr self)
private static IntPtr AccessibilityGetValueTextWrapper(IntPtr self)
{
var view = GetViewFromRefObject(self);
if (view == null) { return IntPtr.Zero; }

var value = GetInterfaceFromRefObject<IAtspiValue>(self);
string text;

Expand Down Expand Up @@ -721,6 +747,7 @@ private static void InitializeAccessibilityDelegateTizenExtensions()
private static bool AccessibilityScrollToChildWrapper(IntPtr self, IntPtr child)
{
View view = GetViewFromRefObject(self);
if (view == null) { return false; }

return view.AccessibilityScrollToChild(view.GetInstanceSafely<View>(child));
}
Expand Down

0 comments on commit fe4bba6

Please sign in to comment.