Fix possible crash when checking for available undo/redo