Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Freeing resources

When a widget-based application terminates, it needs to free the resources (the containers, widgets, models, etc.) that it has instantiated. It also needs to cancel any model listeners it has created.

The FreeAppData function for c_simple_widget_app_1_0 does all of this as follows:

    // cancel the model listener for the button
    LISTENER_Cancel(&pMe->ButtonChanged);

    // Release all of the widgets, containers, and models

    if (NULL != pMe->piwTitle) {
        IWidget_Release(pMe->piwTitle);
        pMe->piwTitle = NULL;
    }

    if (NULL != pMe->piwButton) {
        IWidget_Release(pMe->piwButton);
        pMe->piwButton = NULL;
    }

    if (NULL != pMe->piwRadio1) {
        IWidget_Release(pMe->piwRadio1);
        pMe->piwRadio1 = NULL;
    }

    if (NULL != pMe->piwRadio2) {
        IWidget_Release(pMe->piwRadio2);
        pMe->piwRadio2 = NULL;
    }

    if (NULL != pMe->piwRText1) {
        IWidget_Release(pMe->piwRText1);
        pMe->piwRText1 = NULL;
    }

    if (NULL != pMe->piwRText2) {
        IWidget_Release(pMe->piwRText2);
        pMe->piwRText2 = NULL;
    }

    if (NULL != pMe->piwTitleStaticWidget) {
        IWidget_Release(pMe->piwTitleStaticWidget);
        pMe->piwTitleStaticWidget = NULL;
    }

    if (NULL != pMe->piwJulianDate) {
        IWidget_Release(pMe->piwJulianDate);
        pMe->piwJulianDate = NULL;
    }

    if (NULL != pMe->piwJulianTime) {
        IWidget_Release(pMe->piwJulianTime);
        pMe->piwJulianTime = NULL;
    }

    if (NULL != pMe->picTimeDateXYCon) {
        IXYContainer_Release(pMe->picTimeDateXYCon);
        pMe->picTimeDateXYCon = NULL;
    }

    if (NULL != pMe->piwTimeDateXYCon) {
        IWidget_Release(pMe->piwTimeDateXYCon);
        pMe->piwTimeDateXYCon = NULL;
    }

    if (NULL != pMe->picXYCon) {
        IXYContainer_Release(pMe->picXYCon);
        pMe->picXYCon = NULL;
    }

    if (NULL != pMe->piwXYCon) {
        IWidget_Release(pMe->piwXYCon);
        pMe->piwXYCon = NULL;
    }

    if (NULL != pMe->picRoot) {
        IRootContainer_Release(pMe->picRoot);
        pMe->picRoot = NULL;
    }

    if (NULL != pMe->piwRoot) {
        IWidget_Release(pMe->piwRoot);
        pMe->piwRoot = NULL;
    }

    if (NULL != pMe->piCanvas) {
        IDisplayCanvas_Release(pMe->piCanvas);
        pMe->piCanvas = NULL;
    }