Skip to content

Commit

Permalink
Fix hang caused by SendMessage call in EditorWindowCapture
Browse files Browse the repository at this point in the history
  • Loading branch information
mtschoen committed Aug 14, 2020
1 parent 928fbc4 commit f883d68
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions Runtime/Scripts/Helpers/EditorWindowCapture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -35,10 +34,6 @@ sealed class EditorWindowCapture : MonoBehaviour
MethodInfo m_GrabPixels;
Rect m_ScaledRect;

#if UNITY_EDITOR_WIN
readonly List<Thread> m_CancelDialogThreads = new List<Thread>();
#endif

/// <summary>
/// RenderTexture that represents the captured Editor Window
/// Updated frequently, when capture is enabled
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f883d68

Please sign in to comment.