fix crash when clicking a window