-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in OnLostKeyboardFocus #460
Comments
Sorry to add, it is in CefSharp.Wpf project. |
@sycsoft Can you clarify what you mean by the following?
Just a little nitpick, the code you provided as an example can be simplified as if (managedCefBrowserAdapter == null || managedCefBrowserAdapter.IsDisposed))
return; |
Possibly even provide a sample demonstrating the problem your having? Under a typical |
I tried, but unfortunately, I put this control into a complex WPF UI framework, I cannot reproduce it in simple demo, maybe I did not catch the point where it happens, but anyway I fix it by invoke Keyboard.ClearFocus() before dispose the browser, thanks. |
@sycsoft Can you apply this change locally and see if that resolves your problem in a generic sense? I'd happily see the events unhooked when we start disposing the control. |
I think I got the reason, seems when disposing, we dispose disposable objects then remove hook, but I checked "managedCefBrowserAdapter" will be disposed before remove hook, so this make it still possible to still send event before remove hook, I put the remove hook prior of clear disposable objects, it fixed my issue, but I am not sure if it will cause other issue, I think you will take care of this:).
|
Fix for this has been merged into |
In all place where you used "managedCefBrowserAdapter", you need do check like below:
if (!(managedCefBrowserAdapter != null && !managedCefBrowserAdapter.IsDisposed))
return;
This is because, in WPF, if I put the UI in a another thread, the event will still happen after disposed, so "managedCefBrowserAdapter" will become null or disposed.
private void OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
managedCefBrowserAdapter.SendFocusEvent(false);
}
The text was updated successfully, but these errors were encountered: