Fix crash when resizing window