Index: lisp/files.el =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/files.el,v retrieving revision 1.27.2.19 diff -u -r1.27.2.19 files.el --- lisp/files.el 2000/03/17 17:34:44 1.27.2.19 +++ lisp/files.el 2000/03/19 14:06:13 @@ -977,7 +977,7 @@ (setq buf (create-file-buffer filename)) ;; Catch various signals, such as QUIT, and kill the buffer ;; in that case. -; (condition-case data + (condition-case data (progn (set-buffer-major-mode buf) (set-buffer buf) @@ -1026,9 +1026,9 @@ nil (after-find-file error (not nowarn)) (setq buf (current-buffer)))) -; (t -; (kill-buffer buf) -; (signal (car data) (cdr data)))) + (t + (kill-buffer buf) + (signal (car data) (cdr data)))) )) buf))) Index: src/glyphs-msw.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-msw.c,v retrieving revision 1.21.2.51 diff -u -r1.21.2.51 glyphs-msw.c --- src/glyphs-msw.c 2000/03/17 17:34:40 1.21.2.51 +++ src/glyphs-msw.c 2000/03/19 14:06:25 @@ -2431,7 +2431,7 @@ Lisp_Object pointer_fg, Lisp_Object pointer_bg, int dest_mask, Lisp_Object domain) { - /* this function can call lisp */ + /* This function can call lisp */ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); HWND wnd; int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback @@ -2677,6 +2677,7 @@ Lisp_Object pointer_fg, Lisp_Object pointer_bg, int dest_mask, Lisp_Object domain) { + /* This function can call lisp */ Lisp_Object rest; HWND wnd; int i = 0, selected = 0; @@ -2697,7 +2698,6 @@ pointer_bg, dest_mask, domain, WC_TABCONTROL, /* borders don't suit tabs so well */ flags, 0); - wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); /* add items to the tab */ LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) @@ -2714,24 +2714,33 @@ static void mswindows_tab_control_update (Lisp_Object image_instance) { + /* This function can GC if IN_REDISPLAY is false. */ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) { HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); - int i = 0; + int i = 0, selected = 0; Lisp_Object rest; /* delete the pre-existing items */ SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); + /* Pick up the items we recorded earlier. We do this here so + that the callbacks get set up with the new items. */ + IMAGE_INSTANCE_WIDGET_ITEMS (ii) = + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii); + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil; /* add items to the tab */ LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) { add_tab_item (image_instance, wnd, XCAR (rest), IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), i); + if (gui_item_selected_p (XCAR (rest))) + selected = i; i++; } + SendMessage (wnd, TCM_SETCURSEL, selected, 0); } } Index: src/glyphs-widget.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/Attic/glyphs-widget.c,v retrieving revision 1.1.2.31 diff -u -r1.1.2.31 glyphs-widget.c --- src/glyphs-widget.c 2000/02/23 22:29:40 1.1.2.31 +++ src/glyphs-widget.c 2000/03/19 14:06:29 @@ -506,6 +506,7 @@ IMAGE_INSTANCE_WIDGET_PROPS (ii) = Qnil; SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Qnil); IMAGE_INSTANCE_WIDGET_ITEMS (ii) = allocate_gui_item (); + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil; IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = Qnil; IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = Qnil; IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 1; @@ -790,12 +791,16 @@ if (EQ (prop, Q_items)) { Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance); - check_valid_item_list_1 (val); - IMAGE_INSTANCE_WIDGET_ITEMS (ii) = - Fcons (XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)), - parse_gui_item_tree_children (val)); + check_valid_item_list_1 (val); + /* Don't set the actual items since we might decide not to use + the new ones (because nothing has really changed). If we did + set them and didn't use them then we would get into whole + heaps of trouble when the old items get GC'd. */ + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = + Fcons (XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)), + parse_gui_item_tree_children (val)); IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1; return Qt; Index: src/glyphs-x.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-x.c,v retrieving revision 1.49.2.60 diff -u -r1.49.2.60 glyphs-x.c --- src/glyphs-x.c 2000/03/16 11:21:51 1.49.2.60 +++ src/glyphs-x.c 2000/03/19 14:06:38 @@ -2189,6 +2189,12 @@ need to update most other things after the items have changed.*/ if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) { + /* Pick up the items we recorded earlier. We do this here so + that the callbacks get set up with the new items. */ + IMAGE_INSTANCE_WIDGET_ITEMS (p) = + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p); + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p) = Qnil; + wv = gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (p)); wv->change = STRUCTURAL_CHANGE; Index: src/glyphs.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs.c,v retrieving revision 1.23.2.57 diff -u -r1.23.2.57 glyphs.c --- src/glyphs.c 2000/03/16 11:21:52 1.23.2.57 +++ src/glyphs.c 2000/03/19 14:06:52 @@ -139,6 +139,7 @@ EXFUN (Fimage_instance_type, 1); EXFUN (Fglyph_type, 1); +EXFUN (Fnext_window, 4); /**************************************************************************** @@ -661,6 +662,7 @@ mark_object (IMAGE_INSTANCE_WIDGET_PROPS (i)); mark_object (IMAGE_INSTANCE_WIDGET_FACE (i)); mark_object (IMAGE_INSTANCE_WIDGET_ITEMS (i)); + mark_object (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (i)); mark_object (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (i)); mark_object (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (i)); case IMAGE_SUBWINDOW: @@ -978,10 +980,16 @@ case IMAGE_WIDGET: case IMAGE_LAYOUT: + /* We need the hash to be equivalent to what should be + displayed. */ hash = HASH4 (hash, LISP_HASH (IMAGE_INSTANCE_WIDGET_TYPE (i)), full_list_hash (IMAGE_INSTANCE_WIDGET_PROPS (i), depth + 1), - full_list_hash (IMAGE_INSTANCE_WIDGET_ITEMS (i), depth + 1)); + full_list_hash + (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (i)) + ? IMAGE_INSTANCE_WIDGET_ITEMS (i) + : IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (i), + depth + 1)); case IMAGE_SUBWINDOW: hash = HASH2 (hash, (int) IMAGE_INSTANCE_SUBWINDOW_ID (i)); break; @@ -2776,6 +2784,17 @@ Lisp_Object pointer_fg = Qnil; Lisp_Object pointer_bg = Qnil; + if (dest_mask & (IMAGE_SUBWINDOW_MASK + | IMAGE_WIDGET_MASK + | IMAGE_TEXT_MASK)) + { + if (!WINDOWP (domain)) + signal_simple_error ("Can't instantiate text or subwindow outside a window", + instantiator); + else if (MINI_WINDOW_P (XWINDOW (domain))) + domain = Fnext_window (domain, Qnil, Qnil, Qnil); + } + if (pointerp) { pointer_fg = FACE_FOREGROUND (Vpointer_face, domain); @@ -2831,9 +2850,6 @@ | IMAGE_WIDGET_MASK | IMAGE_TEXT_MASK)) { - if (!WINDOWP (domain)) - signal_simple_error ("Can't instantiate text or subwindow outside a window", - instantiator); instance = Fgethash (instantiator, XWINDOW (domain)->subwindow_instance_cache, Qunbound); @@ -2869,13 +2885,11 @@ cache. */ if (image_instance_type_to_mask (XIMAGE_INSTANCE_TYPE (instance)) & - (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK)) + (IMAGE_SUBWINDOW_MASK + | IMAGE_WIDGET_MASK + | IMAGE_TEXT_MASK )) { - if (!WINDOWP (domain)) - signal_simple_error ("Can't instantiate subwindow outside a window", - instantiator); - - Fsetcdr (XCDR (locative), XWINDOW (domain)->subwindow_instance_cache ); + Fsetcdr (XCDR (locative), XWINDOW (domain)->subwindow_instance_cache); } unbind_to (speccount, Qnil); } @@ -4384,6 +4398,7 @@ } } } + return Qnil; } /* remove a subwindow from its frame */ Index: src/glyphs.h =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs.h,v retrieving revision 1.18.2.42 diff -u -r1.18.2.42 glyphs.h --- src/glyphs.h 2000/03/17 17:34:41 1.18.2.42 +++ src/glyphs.h 2000/03/19 14:06:55 @@ -544,6 +544,7 @@ Lisp_Object type; Lisp_Object props; /* properties or border*/ Lisp_Object items; /* a list of gui_items or children */ + Lisp_Object pending_items; /* gui_items that should be displayed */ Lisp_Object width; /* dynamic width spec. */ Lisp_Object height; /* dynamic height spec. */ /* Change flags to augment dirty. */ @@ -662,6 +663,8 @@ !NILP (IMAGE_INSTANCE_FACE (i)) ? IMAGE_INSTANCE_FACE (i) : \ Vwidget_face) #define IMAGE_INSTANCE_WIDGET_ITEMS(i) ((i)->u.subwindow.items) +#define IMAGE_INSTANCE_WIDGET_PENDING_ITEMS(i) \ + ((i)->u.subwindow.pending_items) #define IMAGE_INSTANCE_WIDGET_ITEM(i) \ (CONSP (IMAGE_INSTANCE_WIDGET_ITEMS (i)) ? \ XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (i)) : \ @@ -757,6 +760,8 @@ IMAGE_INSTANCE_WIDGET_ITEM (XIMAGE_INSTANCE (i)) #define XIMAGE_INSTANCE_WIDGET_ITEMS(i) \ IMAGE_INSTANCE_WIDGET_ITEMS (XIMAGE_INSTANCE (i)) +#define XIMAGE_INSTANCE_WIDGET_PENDING_ITEMS(i) \ + IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (XIMAGE_INSTANCE (i)) #define XIMAGE_INSTANCE_WIDGET_TEXT(i) \ IMAGE_INSTANCE_WIDGET_TEXT (XIMAGE_INSTANCE (i)) Index: src/gui.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/gui.c,v retrieving revision 1.10.2.22 diff -u -r1.10.2.22 gui.c --- src/gui.c 2000/03/16 11:21:54 1.10.2.22 +++ src/gui.c 2000/03/19 14:06:57 @@ -599,6 +599,10 @@ parse_gui_item_tree_item (Lisp_Object entry) { Lisp_Object ret = entry; + struct gcpro gcpro1; + + GCPRO1 (ret); + if (VECTORP (entry)) { ret = gui_parse_item_keywords_no_errors (entry); @@ -610,18 +614,20 @@ else signal_simple_error ("item must be a vector or a string", entry); - return ret; + RETURN_UNGCPRO (ret); } Lisp_Object parse_gui_item_tree_children (Lisp_Object list) { - Lisp_Object rest, ret = Qnil; + Lisp_Object rest, ret = Qnil, sub = Qnil; + struct gcpro gcpro1, gcpro2; + + GCPRO2 (ret, sub); CHECK_CONS (list); /* recursively add items to the tree view */ LIST_LOOP (rest, list) { - Lisp_Object sub; if (CONSP (XCAR (rest))) sub = parse_gui_item_tree_list (XCAR (rest)); else @@ -630,22 +636,30 @@ ret = Fcons (sub, ret); } /* make the order the same as the items we have parsed */ - return Fnreverse (ret); + RETURN_UNGCPRO (Fnreverse (ret)); } static Lisp_Object parse_gui_item_tree_list (Lisp_Object list) { Lisp_Object ret; + struct gcpro gcpro1; CHECK_CONS (list); /* first one can never be a list */ ret = parse_gui_item_tree_item (XCAR (list)); - return Fcons (ret, parse_gui_item_tree_children (XCDR (list))); + GCPRO1 (ret); + ret = Fcons (ret, parse_gui_item_tree_children (XCDR (list))); + RETURN_UNGCPRO (ret); +} + +static void +finalize_gui_item (void* header, int for_disksave) +{ } DEFINE_LRECORD_IMPLEMENTATION ("gui-item", gui_item, mark_gui_item, print_gui_item, - 0, gui_item_equal, + finalize_gui_item, gui_item_equal, gui_item_hash, 0, Lisp_Gui_Item); Index: src/window.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/window.c,v retrieving revision 1.41.2.46 diff -u -r1.41.2.46 window.c --- src/window.c 2000/03/18 08:52:05 1.41.2.46 +++ src/window.c 2000/03/19 14:07:16 @@ -3348,16 +3348,15 @@ /* we have already caught dead-window errors */ if (!NILP (w->hchild) || !NILP (w->vchild)) error ("Trying to select non-leaf window"); - + w->use_time = make_int (++window_select_count); -#if 1 - /* See the comment in Fset_window_buffer. */ + if (EQ (window, old_selected_window)) return window; -#endif + /* deselect the old window, if it exists (it might not exist if the selected device has no frames, which occurs at startup) */ - if (!NILP (old_selected_window) && !EQ (window, old_selected_window)) + if (!NILP (old_selected_window)) { struct window *ow = XWINDOW (old_selected_window); @@ -5477,9 +5476,15 @@ Fselect_window (config->current_window, Qnil); if (!NILP (new_current_buffer)) - Fset_buffer (new_current_buffer); + { + Fset_buffer (new_current_buffer); + Frecord_buffer (new_current_buffer); + } else - Fset_buffer (XWINDOW (config->current_window)->buffer); + { + Fset_buffer (XWINDOW (config->current_window)->buffer); + Frecord_buffer (XWINDOW (config->current_window)->buffer); + } } else set_frame_selected_window (f, config->current_window); Index: tests/glyph-test.el =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/tests/Attic/glyph-test.el,v retrieving revision 1.1.2.18 diff -u -r1.1.2.18 glyph-test.el --- tests/glyph-test.el 2000/03/11 18:10:55 1.1.2.18 +++ tests/glyph-test.el 2000/03/19 14:07:17 @@ -18,26 +18,26 @@ (make-extent (point) (point)) (setq radio-button1 (make-glyph - [button :descriptor ["ok " (setq ok-select t) + [button :descriptor ["ok1" (setq ok-select t) :style radio :selected ok-select]]))) ;; button in a group (set-extent-begin-glyph (make-extent (point) (point)) (setq radio-button2 (make-glyph - [button :descriptor ["ok" (setq ok-select nil) :style radio +` [button :descriptor ["ok2" (setq ok-select nil) :style radio :selected (not ok-select)]]))) ;; toggle button (set-extent-begin-glyph (make-extent (point) (point)) (setq tbutton - (make-glyph [button :descriptor ["ok" (setq ok-select nil) + (make-glyph [button :descriptor ["ok3" (setq ok-select nil) :style toggle :selected (not ok-select)]]))) (set-extent-begin-glyph (make-extent (point) (point)) (setq toggle-button - (make-glyph [button :descriptor ["ok" :style toggle + (make-glyph [button :descriptor ["ok4" :style toggle :callback (setq ok-select (not ok-select)) :selected ok-select]])))