From f883d68d11d0049a59e6a6340f7f224428f14417 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 14 Aug 2020 02:02:32 -0700 Subject: [PATCH] Fix hang caused by SendMessage call in EditorWindowCapture --- .../Scripts/Helpers/EditorWindowCapture.cs | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Runtime/Scripts/Helpers/EditorWindowCapture.cs b/Runtime/Scripts/Helpers/EditorWindowCapture.cs index cff9b84d0..254de3f34 100644 --- a/Runtime/Scripts/Helpers/EditorWindowCapture.cs +++ b/Runtime/Scripts/Helpers/EditorWindowCapture.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Reflection; using UnityEditor; using UnityEngine; @@ -35,10 +34,6 @@ sealed class EditorWindowCapture : MonoBehaviour MethodInfo m_GrabPixels; Rect m_ScaledRect; -#if UNITY_EDITOR_WIN - readonly List m_CancelDialogThreads = new List(); -#endif - /// /// RenderTexture that represents the captured Editor Window /// Updated frequently, when capture is enabled @@ -105,15 +100,6 @@ void OnDisable() { if (m_Window) m_Window.Close(); - -#if UNITY_EDITOR_WIN - foreach (var cancelDialogThread in m_CancelDialogThreads) - { - cancelDialogThread.Abort(); - } - - m_CancelDialogThreads.Clear(); -#endif } void Update() @@ -178,11 +164,9 @@ public void SendEvent(Transform rayOrigin, Transform workspace, EventType type) const int HWND_BROADCAST = 0xffff; const int WM_CANCELMODE = 0x001F; var hwnd = new IntPtr(HWND_BROADCAST); - SendMessage(hwnd, WM_CANCELMODE, 0, IntPtr.Zero); + PostMessage(hwnd, WM_CANCELMODE, 0, IntPtr.Zero); }); - m_CancelDialogThreads.Add(thread); - thread.Start(); } #endif @@ -196,7 +180,7 @@ public void SendEvent(Transform rayOrigin, Transform workspace, EventType type) #if UNITY_EDITOR_WIN [DllImport("User32.dll")] - public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, IntPtr lParam); + public static extern int PostMessage(IntPtr hWnd, int uMsg, int wParam, IntPtr lParam); #endif } #else