diff options
| author | Yuuki Harano | 2021-12-07 00:20:30 +0900 |
|---|---|---|
| committer | Yuuki Harano | 2021-12-07 00:20:30 +0900 |
| commit | 42d4ffad5ad3c381a5495c7ce059ff1526a22a28 (patch) | |
| tree | 926bde91bdb1d6391abbb3109fc9593b55729b4e /src | |
| parent | f99745c78ec13c02817dbd10eb1c4c041add7c21 (diff) | |
| download | emacs-42d4ffad5ad3c381a5495c7ce059ff1526a22a28.tar.gz emacs-42d4ffad5ad3c381a5495c7ce059ff1526a22a28.zip | |
Fix SEGV crash by unref css provider too much
I Got css provider from F, and was going to remove it from style
context. But between them, unhighlight was called when
gtk_container_remove was called, and the css provider was already
freed, so I can't use the css provider to remove it from style
context.
As a fix, I call gtk_container_remove after remove it.
Also, I free a css provider set by unhighlight.
* src/pgtkterm.c (x_set_parent_frame):
Diffstat (limited to 'src')
| -rw-r--r-- | src/pgtkterm.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index bf863c84745..ed7a4a45c25 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -798,15 +798,19 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, | |||
| 798 | gtk_widget_get_allocation (fixed, &alloc); | 798 | gtk_widget_get_allocation (fixed, &alloc); |
| 799 | g_object_ref (fixed); | 799 | g_object_ref (fixed); |
| 800 | 800 | ||
| 801 | /* Remember the css provider, and restore it later. */ | ||
| 801 | GtkCssProvider *provider = FRAME_X_OUTPUT (f)->border_color_css_provider; | 802 | GtkCssProvider *provider = FRAME_X_OUTPUT (f)->border_color_css_provider; |
| 803 | FRAME_X_OUTPUT (f)->border_color_css_provider = NULL; | ||
| 804 | { | ||
| 805 | GtkStyleContext *ctxt = gtk_widget_get_style_context (FRAME_WIDGET (f)); | ||
| 806 | gtk_style_context_remove_provider (ctxt, GTK_STYLE_PROVIDER (provider)); | ||
| 807 | } | ||
| 802 | 808 | ||
| 803 | { | 809 | { |
| 804 | GtkWidget *whbox_of_f = gtk_widget_get_parent (fixed); | 810 | GtkWidget *whbox_of_f = gtk_widget_get_parent (fixed); |
| 811 | /* Here, unhighlight can be called and may change border_color_css_provider. */ | ||
| 805 | gtk_container_remove (GTK_CONTAINER (whbox_of_f), fixed); | 812 | gtk_container_remove (GTK_CONTAINER (whbox_of_f), fixed); |
| 806 | 813 | ||
| 807 | GtkStyleContext *ctxt = gtk_widget_get_style_context (FRAME_WIDGET (f)); | ||
| 808 | gtk_style_context_remove_provider (ctxt, GTK_STYLE_PROVIDER (provider)); | ||
| 809 | |||
| 810 | if (FRAME_GTK_OUTER_WIDGET (f)) | 814 | if (FRAME_GTK_OUTER_WIDGET (f)) |
| 811 | { | 815 | { |
| 812 | gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); | 816 | gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); |
| @@ -842,9 +846,17 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, | |||
| 842 | gtk_widget_show_all (fixed); | 846 | gtk_widget_show_all (fixed); |
| 843 | } | 847 | } |
| 844 | 848 | ||
| 849 | /* Restore css provider. */ | ||
| 845 | GtkStyleContext *ctxt = gtk_widget_get_style_context (FRAME_WIDGET (f)); | 850 | GtkStyleContext *ctxt = gtk_widget_get_style_context (FRAME_WIDGET (f)); |
| 851 | GtkCssProvider *old = FRAME_X_OUTPUT (f)->border_color_css_provider; | ||
| 852 | FRAME_X_OUTPUT (f)->border_color_css_provider = provider; | ||
| 846 | gtk_style_context_add_provider (ctxt, GTK_STYLE_PROVIDER (provider), | 853 | gtk_style_context_add_provider (ctxt, GTK_STYLE_PROVIDER (provider), |
| 847 | GTK_STYLE_PROVIDER_PRIORITY_USER); | 854 | GTK_STYLE_PROVIDER_PRIORITY_USER); |
| 855 | if (old != NULL) | ||
| 856 | { | ||
| 857 | gtk_style_context_remove_provider (ctxt, GTK_STYLE_PROVIDER (old)); | ||
| 858 | g_object_unref(old); | ||
| 859 | } | ||
| 848 | 860 | ||
| 849 | g_object_unref (fixed); | 861 | g_object_unref (fixed); |
| 850 | 862 | ||