Browse Source
Fixes an issue that can cause Avalonia-based applications to crash. The GetMessage call in RunLoop() of WinUiCompositorConnection.cs has been updated to process the result of GetMessage, and terminate the message loop if a WM_QUIT message is received on the pump. (#17190 )
Presently the WM_QUIT message is ignored and the loop re-enters the GetMessage call, causing an unmanaged exception and process crash.
https://github.com/AvaloniaUI/Avalonia/issues/17188
pull/17201/head
Ryan Newington
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
10 additions and
2 deletions
src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositorConnection.cs
@ -161,12 +161,20 @@ internal class WinUiCompositorConnection : IRenderTimer, Win32.IWindowsSurfaceFa
return UnmanagedMethods . DefWindowProc ( hwnd , msg , w , l ) ;
} ) ;
UnmanagedMethods . SetTimer ( dw . Handle , IntPtr . Zero , 1 0 0 0 , null ) ;
while ( ! cts . IsCancellationRequested )
var result = 0 ;
while ( ! cts . IsCancellationRequested
& & ( result = UnmanagedMethods . GetMessage ( out var msg , IntPtr . Zero , 0 , 0 ) ) > 0 )
{
UnmanagedMethods . GetMessage ( out var msg , IntPtr . Zero , 0 , 0 ) ;
lock ( _ shared . SyncRoot )
UnmanagedMethods . DispatchMessage ( ref msg ) ;
}
if ( result < 0 )
{
Logger . TryGet ( LogEventLevel . Error , "WinUIComposition" )
? . Log ( this , "Unmanaged error in {0}. Error Code: {1}" , nameof ( RunLoop ) , Marshal . GetLastWin32Error ( ) ) ;
}
}
public static bool IsSupported ( )