summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@src.gnome.org>2002-09-03 22:35:37 +0000
committerNalin Dahyabhai <nalin@src.gnome.org>2002-09-03 22:35:37 +0000
commitf0953feec5ff4b6cb5e0a93f4049cac1cb78098d (patch)
treeb69f005046e8d731af08f4857f632828abc92f16
parent27721b50e75f6d75fabf685270ad519a91bbabf7 (diff)
Avoid double color deallocations with Xft.vte_0_8_17
* src/vte.c: Avoid double color deallocations with Xft.
-rw-r--r--ChangeLog3
-rw-r--r--src/vte.c34
-rw-r--r--vte.spec5
3 files changed, 29 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 3390d8d..7e82602 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
2002-09-03 nalin
+ * src/vte.c: Avoid double color deallocations with Xft.
+
+2002-09-03 nalin
* src/vte.c: Handle color allocation failures with Xft better.
* src/vte.h: Clean up typedef declarations.
diff --git a/src/vte.c b/src/vte.c
index e984269..f4d8fea 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -319,6 +319,7 @@ struct _VteTerminalPrivate {
#ifdef HAVE_XFT
XRenderColor rcolor;
XftColor ftcolor;
+ gboolean ftcolor_allocated;
#endif
} palette[VTE_BOLD_FG + 1];
@@ -5314,9 +5315,12 @@ vte_terminal_set_color_internal(VteTerminal *terminal, int entry,
/* Try to allocate a color with Xft, otherwise fudge it. */
if (XftColorAllocValue(display, visual, colormap,
- rcolor, ftcolor) == 0) {
+ rcolor, ftcolor) != 0) {
+ terminal->pvt->palette[entry].ftcolor_allocated = TRUE;
+ } else {
ftcolor->color = *rcolor;
ftcolor->pixel = color.pixel;
+ terminal->pvt->palette[entry].ftcolor_allocated = FALSE;
}
}
#endif
@@ -10129,17 +10133,23 @@ vte_terminal_unrealize(GtkWidget *widget)
terminal->pvt->im_preedit_cursor = 0;
#ifdef HAVE_XFT
- /* Clean up after Xft. */
- display = gdk_x11_drawable_get_xdisplay(widget->window);
- gvisual = gtk_widget_get_visual(widget);
- visual = gdk_x11_visual_get_xvisual(gvisual);
- gcolormap = gtk_widget_get_colormap(widget);
- colormap = gdk_x11_colormap_get_xcolormap(gcolormap);
- for (i = 0; i < G_N_ELEMENTS(terminal->pvt->palette); i++) {
- XftColorFree(display,
- visual,
- colormap,
- &terminal->pvt->palette[i].ftcolor);
+ if ((terminal->pvt->render_method == VteRenderXft1) ||
+ (terminal->pvt->render_method == VteRenderXft2)) {
+ /* Clean up after Xft. */
+ display = gdk_x11_drawable_get_xdisplay(widget->window);
+ gvisual = gtk_widget_get_visual(widget);
+ visual = gdk_x11_visual_get_xvisual(gvisual);
+ gcolormap = gtk_widget_get_colormap(widget);
+ colormap = gdk_x11_colormap_get_xcolormap(gcolormap);
+ for (i = 0; i < G_N_ELEMENTS(terminal->pvt->palette); i++) {
+ if (terminal->pvt->palette[i].ftcolor_allocated) {
+ XftColorFree(display,
+ visual,
+ colormap,
+ &terminal->pvt->palette[i].ftcolor);
+ terminal->pvt->palette[i].ftcolor_allocated = FALSE;
+ }
+ }
}
#endif
diff --git a/vte.spec b/vte.spec
index 16ab465..cabd789 100644
--- a/vte.spec
+++ b/vte.spec
@@ -1,5 +1,5 @@
Name: vte
-Version: 0.8.16
+Version: 0.8.17
Release: 1
Summary: An experimental terminal emulator.
License: LGPL
@@ -61,6 +61,9 @@ rm $RPM_BUILD_ROOT/%{_libdir}/lib%{name}.la
%{_libdir}/pkgconfig/*
%changelog
+* Tue Sep 3 2002 Nalin Dahyabhai <nalin@redhat.com> 0.8.17-1
+- track Xft color deallocation to prevent freeing of colors we don't own
+
* Tue Sep 3 2002 Nalin Dahyabhai <nalin@redhat.com> 0.8.16-1
- handle color allocation failures better