diff options
| author | Gerd Moellmann | 2000-12-13 20:27:01 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-12-13 20:27:01 +0000 |
| commit | eaf1eea98639840fc6f3d4c85eca975c7e787fdd (patch) | |
| tree | f3fb4346f4a364513da5dfa46686ce7198c6ac4a /src | |
| parent | 70de49cc69eeeea702ab1c0d2dfd84d7274844f3 (diff) | |
| download | emacs-eaf1eea98639840fc6f3d4c85eca975c7e787fdd.tar.gz emacs-eaf1eea98639840fc6f3d4c85eca975c7e787fdd.zip | |
(image_cache_refcount, dpyinfo_refcount) [GLYPH_DEBUG]:
New variables.
(unwind_create_frame, unwind_create_tip_frame): New functions.
(Fx_create_frame, x_create_tip_frame): Handle errors signaled
while a frame is only partially constructed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 80 |
1 files changed, 75 insertions, 5 deletions
diff --git a/src/xfns.c b/src/xfns.c index be89268ec76..b560c70c0d6 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -255,6 +255,11 @@ extern Lisp_Object Vwindow_system_version; | |||
| 255 | 255 | ||
| 256 | Lisp_Object Qface_set_after_frame_default; | 256 | Lisp_Object Qface_set_after_frame_default; |
| 257 | 257 | ||
| 258 | #ifdef GLYPH_DEBUG | ||
| 259 | int image_cache_refcount, dpyinfo_refcount; | ||
| 260 | #endif | ||
| 261 | |||
| 262 | |||
| 258 | 263 | ||
| 259 | /* Error if we are not connected to X. */ | 264 | /* Error if we are not connected to X. */ |
| 260 | 265 | ||
| @@ -746,6 +751,8 @@ struct x_frame_parm_table | |||
| 746 | void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 751 | void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 747 | }; | 752 | }; |
| 748 | 753 | ||
| 754 | static Lisp_Object unwind_create_frame P_ ((Lisp_Object)); | ||
| 755 | static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object)); | ||
| 749 | static void x_change_window_heights P_ ((Lisp_Object, int)); | 756 | static void x_change_window_heights P_ ((Lisp_Object, int)); |
| 750 | static void x_disable_image P_ ((struct frame *, struct image *)); | 757 | static void x_disable_image P_ ((struct frame *, struct image *)); |
| 751 | static void x_create_im P_ ((struct frame *)); | 758 | static void x_create_im P_ ((struct frame *)); |
| @@ -4023,6 +4030,37 @@ x_free_gcs (f) | |||
| 4023 | } | 4030 | } |
| 4024 | 4031 | ||
| 4025 | 4032 | ||
| 4033 | /* Handler for signals raised during x_create_frame and | ||
| 4034 | x_create_top_frame. FRAME is the frame which is partially | ||
| 4035 | constructed. */ | ||
| 4036 | |||
| 4037 | static Lisp_Object | ||
| 4038 | unwind_create_frame (frame) | ||
| 4039 | Lisp_Object frame; | ||
| 4040 | { | ||
| 4041 | struct frame *f = XFRAME (frame); | ||
| 4042 | |||
| 4043 | /* If frame is ``official'', nothing to do. */ | ||
| 4044 | if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) | ||
| 4045 | { | ||
| 4046 | #ifdef GLYPH_DEBUG | ||
| 4047 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 4048 | #endif | ||
| 4049 | |||
| 4050 | x_free_frame_resources (f); | ||
| 4051 | |||
| 4052 | /* Check that reference counts are indeed correct. */ | ||
| 4053 | xassert (dpyinfo->reference_count == dpyinfo_refcount); | ||
| 4054 | xassert (dpyinfo->image_cache->refcount == image_cache_refcount); | ||
| 4055 | |||
| 4056 | tip_window = None; | ||
| 4057 | tip_frame = Qnil; | ||
| 4058 | } | ||
| 4059 | |||
| 4060 | return Qnil; | ||
| 4061 | } | ||
| 4062 | |||
| 4063 | |||
| 4026 | DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, | 4064 | DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, |
| 4027 | 1, 1, 0, | 4065 | 1, 1, 0, |
| 4028 | "Make a new X window, which is called a \"frame\" in Emacs terms.\n\ | 4066 | "Make a new X window, which is called a \"frame\" in Emacs terms.\n\ |
| @@ -4043,7 +4081,7 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 4043 | int minibuffer_only = 0; | 4081 | int minibuffer_only = 0; |
| 4044 | long window_prompting = 0; | 4082 | long window_prompting = 0; |
| 4045 | int width, height; | 4083 | int width, height; |
| 4046 | int count = specpdl_ptr - specpdl; | 4084 | int count = BINDING_STACK_SIZE (); |
| 4047 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 4085 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 4048 | Lisp_Object display; | 4086 | Lisp_Object display; |
| 4049 | struct x_display_info *dpyinfo = NULL; | 4087 | struct x_display_info *dpyinfo = NULL; |
| @@ -4113,6 +4151,7 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 4113 | f->output_data.x->fontset = -1; | 4151 | f->output_data.x->fontset = -1; |
| 4114 | f->output_data.x->scroll_bar_foreground_pixel = -1; | 4152 | f->output_data.x->scroll_bar_foreground_pixel = -1; |
| 4115 | f->output_data.x->scroll_bar_background_pixel = -1; | 4153 | f->output_data.x->scroll_bar_background_pixel = -1; |
| 4154 | record_unwind_protect (unwind_create_frame, frame); | ||
| 4116 | 4155 | ||
| 4117 | f->icon_name | 4156 | f->icon_name |
| 4118 | = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", | 4157 | = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", |
| @@ -4121,6 +4160,10 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 4121 | f->icon_name = Qnil; | 4160 | f->icon_name = Qnil; |
| 4122 | 4161 | ||
| 4123 | FRAME_X_DISPLAY_INFO (f) = dpyinfo; | 4162 | FRAME_X_DISPLAY_INFO (f) = dpyinfo; |
| 4163 | #ifdef GLYPH_DEBUG | ||
| 4164 | image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; | ||
| 4165 | dpyinfo_refcount = dpyinfo->reference_count; | ||
| 4166 | #endif /* GLYPH_DEBUG */ | ||
| 4124 | #ifdef MULTI_KBOARD | 4167 | #ifdef MULTI_KBOARD |
| 4125 | FRAME_KBOARD (f) = kb; | 4168 | FRAME_KBOARD (f) = kb; |
| 4126 | #endif | 4169 | #endif |
| @@ -4409,6 +4452,7 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 4409 | return unbind_to (count, frame); | 4452 | return unbind_to (count, frame); |
| 4410 | } | 4453 | } |
| 4411 | 4454 | ||
| 4455 | |||
| 4412 | /* FRAME is used only to get a handle on the X display. We don't pass the | 4456 | /* FRAME is used only to get a handle on the X display. We don't pass the |
| 4413 | display info directly because we're called from frame.c, which doesn't | 4457 | display info directly because we're called from frame.c, which doesn't |
| 4414 | know about that structure. */ | 4458 | know about that structure. */ |
| @@ -10308,8 +10352,24 @@ Lisp_Object tip_frame; | |||
| 10308 | Lisp_Object tip_timer; | 10352 | Lisp_Object tip_timer; |
| 10309 | Window tip_window; | 10353 | Window tip_window; |
| 10310 | 10354 | ||
| 10355 | |||
| 10356 | static Lisp_Object | ||
| 10357 | unwind_create_tip_frame (frame) | ||
| 10358 | Lisp_Object frame; | ||
| 10359 | { | ||
| 10360 | tip_window = None; | ||
| 10361 | tip_frame = Qnil; | ||
| 10362 | return unwind_create_frame (frame); | ||
| 10363 | } | ||
| 10364 | |||
| 10365 | |||
| 10311 | /* Create a frame for a tooltip on the display described by DPYINFO. | 10366 | /* Create a frame for a tooltip on the display described by DPYINFO. |
| 10312 | PARMS is a list of frame parameters. Value is the frame. */ | 10367 | PARMS is a list of frame parameters. Value is the frame. |
| 10368 | |||
| 10369 | Note that functions called here, esp. x_default_parameter can | ||
| 10370 | signal errors, for instance when a specified color name is | ||
| 10371 | undefined. We have to make sure that we're in a consistent state | ||
| 10372 | when this happens. */ | ||
| 10313 | 10373 | ||
| 10314 | static Lisp_Object | 10374 | static Lisp_Object |
| 10315 | x_create_tip_frame (dpyinfo, parms) | 10375 | x_create_tip_frame (dpyinfo, parms) |
| @@ -10321,7 +10381,7 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 10321 | Lisp_Object name; | 10381 | Lisp_Object name; |
| 10322 | long window_prompting = 0; | 10382 | long window_prompting = 0; |
| 10323 | int width, height; | 10383 | int width, height; |
| 10324 | int count = specpdl_ptr - specpdl; | 10384 | int count = BINDING_STACK_SIZE (); |
| 10325 | struct gcpro gcpro1, gcpro2, gcpro3; | 10385 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 10326 | struct kboard *kb; | 10386 | struct kboard *kb; |
| 10327 | 10387 | ||
| @@ -10350,7 +10410,12 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 10350 | f = make_frame (1); | 10410 | f = make_frame (1); |
| 10351 | XSETFRAME (frame, f); | 10411 | XSETFRAME (frame, f); |
| 10352 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | 10412 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
| 10413 | record_unwind_protect (unwind_create_frame, frame); | ||
| 10353 | 10414 | ||
| 10415 | /* By setting the output method, we're essentially saying that | ||
| 10416 | the frame is live, as per FRAME_LIVE_P. If we get a signal | ||
| 10417 | from this point on, x_destroy_window might screw up reference | ||
| 10418 | counts etc. */ | ||
| 10354 | f->output_method = output_x_window; | 10419 | f->output_method = output_x_window; |
| 10355 | f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); | 10420 | f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); |
| 10356 | bzero (f->output_data.x, sizeof (struct x_output)); | 10421 | bzero (f->output_data.x, sizeof (struct x_output)); |
| @@ -10360,6 +10425,10 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 10360 | f->output_data.x->scroll_bar_background_pixel = -1; | 10425 | f->output_data.x->scroll_bar_background_pixel = -1; |
| 10361 | f->icon_name = Qnil; | 10426 | f->icon_name = Qnil; |
| 10362 | FRAME_X_DISPLAY_INFO (f) = dpyinfo; | 10427 | FRAME_X_DISPLAY_INFO (f) = dpyinfo; |
| 10428 | #ifdef GLYPH_DEBUG | ||
| 10429 | image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; | ||
| 10430 | dpyinfo_refcount = dpyinfo->reference_count; | ||
| 10431 | #endif /* GLYPH_DEBUG */ | ||
| 10363 | #ifdef MULTI_KBOARD | 10432 | #ifdef MULTI_KBOARD |
| 10364 | FRAME_KBOARD (f) = kb; | 10433 | FRAME_KBOARD (f) = kb; |
| 10365 | #endif | 10434 | #endif |
| @@ -10404,8 +10473,8 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 10404 | specbind (Qx_resource_name, name); | 10473 | specbind (Qx_resource_name, name); |
| 10405 | } | 10474 | } |
| 10406 | 10475 | ||
| 10407 | /* Extract the window parameters from the supplied values | 10476 | /* Extract the window parameters from the supplied values that are |
| 10408 | that are needed to determine window geometry. */ | 10477 | needed to determine window geometry. */ |
| 10409 | { | 10478 | { |
| 10410 | Lisp_Object font; | 10479 | Lisp_Object font; |
| 10411 | 10480 | ||
| @@ -10566,6 +10635,7 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 10566 | its display. */ | 10635 | its display. */ |
| 10567 | FRAME_X_DISPLAY_INFO (f)->reference_count++; | 10636 | FRAME_X_DISPLAY_INFO (f)->reference_count++; |
| 10568 | 10637 | ||
| 10638 | /* Discard the unwind_protect. */ | ||
| 10569 | return unbind_to (count, frame); | 10639 | return unbind_to (count, frame); |
| 10570 | } | 10640 | } |
| 10571 | 10641 | ||