fix NullPointerException

fix NullPointerException on no window is active