From a5802a916f29157360991a9f19ec57e12566d7d7 Mon Sep 17 00:00:00 2001 From: teach310 Date: Mon, 30 Oct 2023 22:56:50 +0900 Subject: [PATCH] remove throw on callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit コールバックでcontext変えるまえにエラー投げるとUnityがクラッシュするため。 DidDiscoverCharacteristicsはCharacteristicが見つからなかった場合も呼ばれて空が渡される仕様なためそもそもthrowすべきでない。 他はおそらく空なことはないため異常だとは思うが、空の配列が渡った先でthrowする必要性は感じなかったためそのまま削除 --- .../Runtime/SafeNativePeripheralHandle.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs index 17a9596..8eeace4 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs @@ -69,11 +69,6 @@ static INativePeripheralDelegate GetDelegate(IntPtr peripheralPtr) internal static void DidDiscoverServices(IntPtr peripheralPtr, IntPtr commaSeparatedServiceUUIDsPtr, int errorCode) { string commaSeparatedServiceUUIDs = Marshal.PtrToStringUTF8(commaSeparatedServiceUUIDsPtr); - if (string.IsNullOrEmpty(commaSeparatedServiceUUIDs)) - { - throw new ArgumentException("commaSeparatedServiceUUIDs is null or empty."); - } - GetDelegate(peripheralPtr)?.DidDiscoverServices( commaSeparatedServiceUUIDs.Split(','), CBError.CreateOrNullFromCode(errorCode) @@ -84,11 +79,6 @@ internal static void DidDiscoverServices(IntPtr peripheralPtr, IntPtr commaSepar internal static void DidDiscoverCharacteristics(IntPtr peripheralPtr, IntPtr serviceUUIDPtr, IntPtr commaSeparatedCharacteristicUUIDsPtr, int errorCode) { string commaSeparatedCharacteristicUUIDs = Marshal.PtrToStringUTF8(commaSeparatedCharacteristicUUIDsPtr); - if (string.IsNullOrEmpty(commaSeparatedCharacteristicUUIDs)) - { - throw new ArgumentException("commaSeparatedCharacteristicUUIDs is null or empty."); - } - GetDelegate(peripheralPtr)?.DidDiscoverCharacteristics( Marshal.PtrToStringUTF8(serviceUUIDPtr), commaSeparatedCharacteristicUUIDs.Split(','), @@ -156,11 +146,6 @@ internal static void DidUpdateName(IntPtr peripheralPtr) internal static void DidModifyServices(IntPtr peripheralPtr, IntPtr commaSeparatedServiceUUIDsPtr) { string commaSeparatedServiceUUIDs = Marshal.PtrToStringUTF8(commaSeparatedServiceUUIDsPtr); - if (string.IsNullOrEmpty(commaSeparatedServiceUUIDs)) - { - throw new ArgumentException("commaSeparatedServiceUUIDs is null or empty."); - } - GetDelegate(peripheralPtr)?.DidModifyServices( commaSeparatedServiceUUIDs.Split(',') );