qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c
Date: Tue, 07 Jan 2014 14:34:17 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        14/01/07 14:34:17

Modified files:
        .              : qe.c 

Log message:
        fixed crash in recursive help popup

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.112&r2=1.113

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -b -r1.112 -r1.113
--- qe.c        6 Jan 2014 10:24:26 -0000       1.112
+++ qe.c        7 Jan 2014 14:34:17 -0000       1.113
@@ -5132,21 +5132,40 @@
 /* XXX: incorrect to save it. Should use a safer method */
 static EditState *popup_saved_active;
 
+/* Verify that window still exists, return argument or NULL */
+EditState *check_window(EditState *s)
+{
+    QEmacsState *qs = &qe_state;
+    EditState *e;
+
+    for (e = qs->first_window; e != NULL; e = e->next_window) {
+        if (e == s)
+            break;
+    }
+    return e;
+}
+
 /* less like mode */
 void do_less_exit(EditState *s)
 {
     QEmacsState *qs = s->qe_state;
     EditBuffer *b;
+    EditState *e;
 
-    /* CG: should verify that popup_saved_active still exists */
-    /* CG: This command crashes if not invoked from less popup mode */
-    if (popup_saved_active) {
-        qs->active_window = popup_saved_active;
+    /* CG: Should make buffer transient, free'd upon last window close? */
         b = s->b;
+    for (e = qs->first_window; e != NULL; e = e->next_window) {
+        if (e != s && e->b == b)
+            break;
+    }
         edit_close(s);
+    if (!e)
         eb_free(b);
+
+    qs->active_window = check_window(popup_saved_active);
+    popup_saved_active = NULL;
+
         do_refresh(qs->active_window);
-    }
 }
 
 /* show a popup on a readonly buffer */
@@ -5156,6 +5175,10 @@
     QEmacsState *qs = &qe_state;
     int w, h, w1, h1;
 
+    /* Prevent recursion */
+    if (qs->active_window && qs->active_window->b == b)
+        return;
+
     /* XXX: generic function to open popup ? */
     w1 = qs->screen->width;
     h1 = qs->screen->height - qs->status_height;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]