Fix assertion on kboard->kbd_queue and other such crashes.
authorKaroly Lorentey <lorentey@elte.hu>
Sun, 11 Sep 2005 09:34:22 +0000 (09:34 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Sun, 11 Sep 2005 09:34:22 +0000 (09:34 +0000)
* src/keyboard.c (pop_kboard): Set current_kboard to the kboard of the
  selected frame when the stored kboard object has been deleted before
  pop_kboard.
  (restore_kboard_configuration): Call pop_kboard only after setting up
  single_kboard mode.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-418

README.multi-tty
src/keyboard.c

index 931769e..ab77a70 100644 (file)
@@ -393,6 +393,10 @@ THINGS TO DO
 
 ** frames-on-display-list should also accept frames.
 
+** I smell something funny around pop_kboard's "deleted kboard" case.
+   Determine what are the circumstances of this case, and fix any
+   bug that comes to light.
+
 ** Consider the `tty-type' frame parameter and the `display-tty-type'
    function.  They serve the exact same purpose.  I think it may be
    a good idea to eliminate one of them, preferably `tty-type'.
index baf313c..522cfc3 100644 (file)
@@ -1138,8 +1138,23 @@ void
 pop_kboard ()
 {
 #ifdef MULTI_KBOARD
+  struct device *d;
   struct kboard_stack *p = kboard_stack;
-  current_kboard = p->kboard;
+  int ok = 0;
+  current_kboard = NULL;
+  for (d = device_list; d; d = d->next_device)
+    {
+      if (d->kboard == p->kboard)
+        {
+          current_kboard = p->kboard;
+          break;
+        }
+    }
+  if (current_kboard == NULL)
+    {
+      /* The display we remembered has been deleted.  */
+      current_kboard = FRAME_KBOARD (SELECTED_FRAME ());
+    }
   kboard_stack = p->next;
   xfree (p);
 #endif
@@ -1177,11 +1192,11 @@ static Lisp_Object
 restore_kboard_configuration (was_locked)
      Lisp_Object was_locked;
 {
-  pop_kboard ();
   if (NILP (was_locked))
     any_kboard_state ();
   else
     single_kboard_state ();
+  pop_kboard ();
   return Qnil;
 }
 \f