summaryrefslogtreecommitdiff
path: root/src/xfns.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-05-24 21:20:46 +0800
committerPo Lu <luangruo@yahoo.com>2022-05-24 21:20:46 +0800
commit6f3925eace76a39850c0c108a9e1fd0c010e803d (patch)
tree684ba661716dcbac46cbeef6820a79e39e27fdb0 /src/xfns.c
parent7c4a780721a64bf429bc87557922a46870a924c5 (diff)
downloademacs-6f3925eace76a39850c0c108a9e1fd0c010e803d.tar.gz
Add more error checking to some X functions
* src/xfns.c (Fx_change_window_property, Fx_delete_window_property) (Fx_window_property, Fx_window_property_attributes): Check for errors in case the window is invalid. Also use better function for interning prop names. * src/xterm.c (struct x_atom_ref): New structure. (x_atom_refs): New list. Extract from x_term_init. (x_intern_cached_atom): New function. Use it in several places to avoid interning common atoms. (x_term_init): Adjust accordingly. * src/xterm.h: Update prototypes.
Diffstat (limited to 'src/xfns.c')
-rw-r--r--src/xfns.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/xfns.c b/src/xfns.c
index e1f8947d558..912af0fa5a5 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -7396,16 +7396,17 @@ If WINDOW-ID is non-nil, change the property of that window instead
error ("Failed to intern type or property atom");
#endif
+ x_catch_errors (FRAME_X_DISPLAY (f));
XChangeProperty (FRAME_X_DISPLAY (f), target_window,
prop_atom, target_type, element_format, PropModeReplace,
data, nelements);
if (CONSP (value)) xfree (data);
+ x_check_errors (FRAME_X_DISPLAY (f),
+ "Couldn't change window property: %s");
+ x_uncatch_errors_after_check ();
- /* Make sure the property is set when we return. */
- XFlush (FRAME_X_DISPLAY (f));
unblock_input ();
-
return value;
}
@@ -7437,13 +7438,16 @@ Value is PROP. */)
}
block_input ();
- prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
+ prop_atom = x_intern_cached_atom (FRAME_DISPLAY_INFO (f),
+ SSDATA (prop));
+
+ x_catch_errors (FRAME_X_DISPLAY (f));
XDeleteProperty (FRAME_X_DISPLAY (f), target_window, prop_atom);
+ x_check_errors (FRAME_X_DISPLAY (f),
+ "Couldn't delete window property: %s");
+ x_uncatch_errors_after_check ();
- /* Make sure the property is removed when we return. */
- XFlush (FRAME_X_DISPLAY (f));
unblock_input ();
-
return prop;
}
@@ -7570,10 +7574,12 @@ if PROP has no value of TYPE (always a string in the MS Windows case). */)
if (strcmp ("AnyPropertyType", SSDATA (type)) == 0)
target_type = AnyPropertyType;
else
- target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False);
+ target_type = x_intern_cached_atom (FRAME_DISPLAY_INFO (f),
+ SSDATA (type));
}
- prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
+ prop_atom = x_intern_cached_atom (FRAME_DISPLAY_INFO (f),
+ SSDATA (prop));
prop_value = x_window_property_intern (f,
target_window,
prop_atom,
@@ -7644,7 +7650,8 @@ Otherwise, the return value is a vector with the following fields:
block_input ();
x_catch_errors (FRAME_X_DISPLAY (f));
- prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
+ prop_atom = x_intern_cached_atom (FRAME_DISPLAY_INFO (f),
+ SSDATA (prop));
rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
prop_atom, 0, 0, False, AnyPropertyType,
&actual_type, &actual_format, &actual_size,