- struct command_builder *command_builder =
- XCOMMAND_BUILDER (XCONSOLE (console)->command_builder);
-
- reset_key_echo (command_builder, clear_echo_area_p);
+ if (!NILP (console))
+ {
+ /* console is nil if we just deleted the console as a result of C-x 5
+ 0. Unfortunately things are currently in a messy situation where
+ some stuff is console-local and other stuff isn't, so we need to
+ do everything that's not console-local. */
+ struct command_builder *command_builder =
+ XCOMMAND_BUILDER (XCONSOLE (console)->command_builder);
+
+ reset_key_echo (command_builder, clear_echo_area_p);
+ reset_current_events (command_builder);
+ }
+ else
+ reset_key_echo (0, clear_echo_area_p);