summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 3390d8dd..7e826021 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 e9842693..f4d8fea5 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 16ab465c..cabd7895 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