Fix #2171: crash when opening window
Merge remote-tracking branch 'upstream/master'