diff options
| author | Eli Zaretskii | 2018-02-03 12:19:41 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-02-03 12:19:41 +0200 |
| commit | 1ed408995a622a4c0cd7176f9bd0d81ebfbb5e43 (patch) | |
| tree | a30c88c37f7fddbe898b5034cfa357db762e96e0 | |
| parent | e23de39e22ccdf594b0ee84959f6df9d01af25a2 (diff) | |
| download | emacs-1ed408995a622a4c0cd7176f9bd0d81ebfbb5e43.tar.gz emacs-1ed408995a622a4c0cd7176f9bd0d81ebfbb5e43.zip | |
Update xdisp.c commentary
* src/xdisp.c: Update commentary regarding "asynchronous" entry
into redisplay. (Bug#30182)
| -rw-r--r-- | src/xdisp.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 7511e54ab1d..bf1737b9cf7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -34,26 +34,41 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 34 | in xdisp.c is the only entry into the inner redisplay code. | 34 | in xdisp.c is the only entry into the inner redisplay code. |
| 35 | 35 | ||
| 36 | The following diagram shows how redisplay code is invoked. As you | 36 | The following diagram shows how redisplay code is invoked. As you |
| 37 | can see, Lisp calls redisplay and vice versa. Under window systems | 37 | can see, Lisp calls redisplay and vice versa. |
| 38 | like X, some portions of the redisplay code are also called | 38 | |
| 39 | asynchronously during mouse movement or expose events. It is very | 39 | Under window systems like X, some portions of the redisplay code |
| 40 | important that these code parts do NOT use the C library (malloc, | 40 | are also called asynchronously, due to mouse movement or expose |
| 41 | free) because many C libraries under Unix are not reentrant. They | 41 | events. "Asynchronously" in this context means that any C function |
| 42 | may also NOT call functions of the Lisp interpreter which could | 42 | which calls maybe_quit or process_pending_signals could enter |
| 43 | change the interpreter's state. If you don't follow these rules, | 43 | redisplay via expose_frame and/or note_mouse_highlight, if X events |
| 44 | you will encounter bugs which are very hard to explain. | 44 | were recently reported to Emacs about mouse movements or frame(s) |
| 45 | that were exposed. And such redisplay could invoke the Lisp | ||
| 46 | interpreter, e.g. via the :eval forms in mode-line-format, and as | ||
| 47 | result the global state could change. It is therefore very | ||
| 48 | important that C functions which might cause such "asynchronous" | ||
| 49 | redisplay, but cannot tolerate the results, use | ||
| 50 | block_input/unblock_input around code fragments which assume that | ||
| 51 | global Lisp state doesn't change. If you don't follow this rule, | ||
| 52 | you will encounter bugs which are very hard to explain. One place | ||
| 53 | that needs to take such precautions is timer_check, some of whose | ||
| 54 | code cannot tolerate changes in timer alists while it processes | ||
| 55 | timers. | ||
| 45 | 56 | ||
| 46 | +--------------+ redisplay +----------------+ | 57 | +--------------+ redisplay +----------------+ |
| 47 | | Lisp machine |---------------->| Redisplay code |<--+ | 58 | | Lisp machine |---------------->| Redisplay code |<--+ |
| 48 | +--------------+ (xdisp.c) +----------------+ | | 59 | +--------------+ (xdisp.c) +----------------+ | |
| 49 | ^ | | | 60 | ^ | | |
| 50 | +----------------------------------+ | | 61 | +----------------------------------+ | |
| 51 | Don't use this path when called | | 62 | Block input to prevent this when | |
| 52 | asynchronously! | | 63 | called asynchronously! | |
| 53 | | | 64 | | |
| 54 | expose_window (asynchronous) | | 65 | note_mouse_highlight (asynchronous) | |
| 55 | | | 66 | | |
| 56 | X expose events -----+ | 67 | X mouse events -----+ |
| 68 | | | ||
| 69 | expose_frame (asynchronous) | | ||
| 70 | | | ||
| 71 | X expose events -----+ | ||
| 57 | 72 | ||
| 58 | What does redisplay do? Obviously, it has to figure out somehow what | 73 | What does redisplay do? Obviously, it has to figure out somehow what |
| 59 | has been changed since the last time the display has been updated, | 74 | has been changed since the last time the display has been updated, |