data->p_width = data->p_height = 0;
}
+static void
+destroy_xft_data (Widget widget, XtPointer closure, XtPointer call_data)
+{
+ struct widget_xft_data *xft_data = closure;
+
+ for (int i = 0; xft_data[i].widget; ++i)
+ {
+ if (xft_data[i].xft_draw)
+ XftDrawDestroy (xft_data[i].xft_draw);
+ if (xft_data[i].p != None)
+ XFreePixmap (XtDisplay (widget), xft_data[i].p);
+ }
+ if (xft_data[0].xft_font)
+ XftFontClose (XtDisplay (widget), xft_data[0].xft_font);
+ xfree (xft_data);
+}
+
static XftFont*
openFont (Widget widget, char *name)
{
}
if (!inst || !inst->xft_data || !inst->xft_data[0].xft_font) return 0;
- for (nr = 0; data == NULL && nr < inst->nr_xft_data; ++nr)
+ for (nr = 0; data == NULL && inst->xft_data[nr].widget; ++nr)
{
if (inst->xft_data[nr].widget == widget)
data = &inst->xft_data[nr];
{
int th;
int nr;
- for (nr = 0; nr < instance->nr_xft_data; ++nr)
+ for (nr = 0; instance->xft_data[nr].widget; ++nr)
if (instance->xft_data[nr].widget == widget)
break;
- if (nr < instance->nr_xft_data)
+ if (instance->xft_data[nr].widget)
{
set_text (&instance->xft_data[nr], instance->parent,
val->value, 6);
void
xaw_destroy_instance (widget_instance *instance)
{
-#ifdef HAVE_XFT
- if (instance->xft_data)
- {
- int i;
- for (i = 0; i < instance->nr_xft_data; ++i)
- {
- if (instance->xft_data[i].xft_draw)
- XftDrawDestroy (instance->xft_data[i].xft_draw);
- if (instance->xft_data[i].p != None)
- {
- XtVaSetValues (instance->xft_data[i].widget, XtNbitmap, None,
- NULL);
- XFreePixmap (XtDisplay (instance->widget),
- instance->xft_data[i].p);
- }
- }
- if (instance->xft_data[0].xft_font)
- XftFontClose (XtDisplay (instance->widget),
- instance->xft_data[0].xft_font);
- xfree (instance->xft_data);
- }
-#endif
if (XtIsSubclass (instance->widget, dialogWidgetClass))
/* Need to destroy the Shell too. */
XtDestroyWidget (XtParent (instance->widget));
}
}
instance->xft_data = 0;
- instance->nr_xft_data = 0;
if (w)
{
XtResource rec[] =
if (xft_font)
{
- instance->nr_xft_data = left_buttons + right_buttons + 1;
- instance->xft_data = calloc (instance->nr_xft_data,
+ int nr_xft_data = left_buttons + right_buttons + 1;
+ instance->xft_data = calloc (nr_xft_data + 1,
sizeof(*instance->xft_data));
fill_xft_data (&instance->xft_data[0], w, xft_font);
+ XtAddCallback (dialog, XtNdestroyCallback, destroy_xft_data,
+ instance->xft_data);
}
}