diff options
| author | Eli Zaretskii | 2019-01-28 17:24:04 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-01-28 17:24:04 +0200 |
| commit | cd06d173a602bf0aa8a227ff1626dc70013fe480 (patch) | |
| tree | 054908e08e1f1adcc8aace9b10e872e05e592b6a /src | |
| parent | fa7a841124578c00872d8a5aa834f6bbe57400ff (diff) | |
| download | emacs-cd06d173a602bf0aa8a227ff1626dc70013fe480.tar.gz emacs-cd06d173a602bf0aa8a227ff1626dc70013fe480.zip | |
Fix bug with face-id after restoring from pdump
* src/xfaces.c (init_xfaces): New function.
* src/emacs.c (main) [HAVE_PDUMPER]: If dumped with pdumper,
call init_xfaces. (Bug#34226)
* src/lisp.h (init_xfaces) [HAVE_PDUMPER]: Add prototype.
* test/lisp/faces-tests.el (faces--test-face-id): New test for
bug#34226.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 5 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/xfaces.c | 40 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c index 2acee8e6fea..d6b8a87c723 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1484,6 +1484,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1484 | running_asynch_code = 0; | 1484 | running_asynch_code = 0; |
| 1485 | init_random (); | 1485 | init_random (); |
| 1486 | 1486 | ||
| 1487 | #ifdef HAVE_PDUMPER | ||
| 1488 | if (dumped_with_pdumper_p ()) | ||
| 1489 | init_xfaces (); | ||
| 1490 | #endif | ||
| 1491 | |||
| 1487 | #if defined HAVE_JSON && !defined WINDOWSNT | 1492 | #if defined HAVE_JSON && !defined WINDOWSNT |
| 1488 | init_json (); | 1493 | init_json (); |
| 1489 | #endif | 1494 | #endif |
diff --git a/src/lisp.h b/src/lisp.h index c5631e28453..5159f050a49 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4606,6 +4606,9 @@ extern void syms_of_w32cygwinx (void); | |||
| 4606 | extern Lisp_Object Vface_alternative_font_family_alist; | 4606 | extern Lisp_Object Vface_alternative_font_family_alist; |
| 4607 | extern Lisp_Object Vface_alternative_font_registry_alist; | 4607 | extern Lisp_Object Vface_alternative_font_registry_alist; |
| 4608 | extern void syms_of_xfaces (void); | 4608 | extern void syms_of_xfaces (void); |
| 4609 | #ifdef HAVE_PDUMPER | ||
| 4610 | extern void init_xfaces (void); | ||
| 4611 | #endif | ||
| 4609 | 4612 | ||
| 4610 | #ifdef HAVE_X_WINDOWS | 4613 | #ifdef HAVE_X_WINDOWS |
| 4611 | /* Defined in xfns.c. */ | 4614 | /* Defined in xfns.c. */ |
diff --git a/src/xfaces.c b/src/xfaces.c index cffa89e1f39..7facb13b76c 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -6507,6 +6507,46 @@ DEFUN ("show-face-resources", Fshow_face_resources, Sshow_face_resources, | |||
| 6507 | Initialization | 6507 | Initialization |
| 6508 | ***********************************************************************/ | 6508 | ***********************************************************************/ |
| 6509 | 6509 | ||
| 6510 | #ifdef HAVE_PDUMPER | ||
| 6511 | /* All the faces defined during loadup are recorded in | ||
| 6512 | face-new-frame-defaults, with the last face first in the list. We | ||
| 6513 | need to set next_lface_id to the next face ID number, so that any | ||
| 6514 | new faces defined in this session will have face IDs different from | ||
| 6515 | those defined during loadup. We also need to set up the | ||
| 6516 | lface_id_to_name[] array for the faces that were defined during | ||
| 6517 | loadup. */ | ||
| 6518 | void | ||
| 6519 | init_xfaces (void) | ||
| 6520 | { | ||
| 6521 | if (CONSP (Vface_new_frame_defaults)) | ||
| 6522 | { | ||
| 6523 | Lisp_Object lface = XCAR (Vface_new_frame_defaults); | ||
| 6524 | if (CONSP (lface)) | ||
| 6525 | { | ||
| 6526 | /* The first face in the list is the last face defined | ||
| 6527 | during loadup. Compute how many faces are there, and | ||
| 6528 | allocate the lface_id_to_name[] array. */ | ||
| 6529 | Lisp_Object lface_id = Fget (XCAR (lface), Qface); | ||
| 6530 | lface_id_to_name_size = next_lface_id = XFIXNAT (lface_id) + 1; | ||
| 6531 | lface_id_to_name = xnmalloc (next_lface_id, sizeof *lface_id_to_name); | ||
| 6532 | /* Store the last face. */ | ||
| 6533 | lface_id_to_name[next_lface_id - 1] = lface; | ||
| 6534 | |||
| 6535 | /* Store the rest of the faces. */ | ||
| 6536 | Lisp_Object tail; | ||
| 6537 | for (tail = XCDR (Vface_new_frame_defaults); CONSP (tail); | ||
| 6538 | tail = XCDR (tail)) | ||
| 6539 | { | ||
| 6540 | lface = XCAR (tail); | ||
| 6541 | int face_id = XFIXNAT (Fget (XCAR (lface), Qface)); | ||
| 6542 | eassert (face_id < lface_id_to_name_size); | ||
| 6543 | lface_id_to_name[face_id] = lface; | ||
| 6544 | } | ||
| 6545 | } | ||
| 6546 | } | ||
| 6547 | } | ||
| 6548 | #endif | ||
| 6549 | |||
| 6510 | void | 6550 | void |
| 6511 | syms_of_xfaces (void) | 6551 | syms_of_xfaces (void) |
| 6512 | { | 6552 | { |