Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ destroy(3) — OSF1 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Composite(3)

Constraint(3)

Core(3)

destroy

 

Name

destroy — Core method called when a widget is destroyed. 

Synopsis

typedef void (∗XtWidgetProc)(Widget);

    Widget w;

Arguments

wSpecifies the widget. 

Description

The Core destroy method frees any memory allocated for this widget instance. 

The destroy methods are called in subclass-to-superclass order.  A widget’s destroy method should only deallocate storage originally allocated by it and should not deallocate memory allocated by its superclasses.  If a widget does not need to deallocate any storage, the destroy procedure pointer in its widget class record can be NULL. 

To reclaim memory, at least the following deallocations should be performed:

•Call XtFree on dynamic storage allocated with XtCalloc, XtMalloc, etc. 

•Call XFreePixmap on pixmaps created with direct Xlib calls. 

•Call XtDestroyGC on GCs allocated with XtGetGC. 

•Call XFreeGC on GCs allocated with direct Xlib calls. 

•Call XtRemoveEventHandler on event handlers added with XtAddEventHandler. 

•Call XtRemoveTimeOut on timers created with XtAppAddTimeOut. 

•Call XtDestroyWidget for each child if the widget has children and is not a subclass of compositeWidgetClass. 

Examples

The following is the destroy method of the BitmapEdit widget:

static void
Destroy(w)
Widget w;
{
    BitmapEditWidget cw = (BitmapEditWidget) w;
     if (cw->bitmapEdit.big_picture)
        XFreePixmap(XtDisplay(cw), cw->bitmapEdit.big_picture);
     if (cw->bitmapEdit.draw_gc)
        XFreeGC(XtDisplay(cw), cw->bitmapEdit.draw_gc);
     if (cw->bitmapEdit.undraw_gc)
        XFreeGC(XtDisplay(cw), cw->bitmapEdit.undraw_gc);
     if (cw->bitmapEdit.copy_gc)
        XFreeGC(XtDisplay(cw), cw->bitmapEdit.copy_gc);
  /∗ malloc’ed char array that stores bitmap state. ∗/
    XtFree(cw->bitmapEdit.cell);
}

See Also

Composite(3), Constraint(3), Core(3),
Constraint destroy(4). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026