Re: XForms: fl_free_form

From: Steve Lamont (
Date: Fri Mar 24 2000 - 13:40:38 EST

  • Next message: T.C. Zhao: "Re: XForms: fl_exe_command,fl_popen"

    # To subscribers of the xforms list from (Steve Lamont) :

    > I need to open a very big form sometimes. The aspect of the form
    > has to change from a call to another. As a consequence, between two calls,
    > I want to free the form :
    > -> I call fl_free_form when I close (hide) the form
    > -> when I need it again, I rebuilt it (new call to the procedure
    > that create the form, new allocation of the form pointer).
    > Then, quite often but not always I "win" a core dump, and I feel
    > anhappy :)
    > Is there some bugs you know in fl_free_form ?

    None of which I'm aware.

    Are you hiding the form first with fl_hide_form()?

    Here's what I do:

            void destroy_form( FL_FORM *form )
                void *dui = form->fdui;
                FL_OBJECT *obj = form->first;
                 * This hack necessary because it appears that the cleanup
                 * routine is otherwise called after the window is destroyed!
                    if ( ( obj->objclass == FL_CANVAS ) ||
                         ( obj->objclass == FL_GLCANVAS ) )
                        fl_hide_object( obj );
                while ( obj = obj->next );
                fl_hide_form( form );
                fl_free_form( form );
                free( dui );

    Note that the Canvas hack may no longer be necessary -- this is from
    some pretty old code. TC mentioned that this has been fixed but I'm
    not sure -- I haven't checked recently.

    Obviously, once you've freed the form, you should not use its pointer
    any longer.

    > How should I free a form if I need to re-open it later ?

    See above.

    In this case, every time you want to display the form, you have to
    create it from scratch with your create_form_whatever() call and then
    use fl_show_form() to display it.

    If you want to just undisplay the form and show it again, you should
    *not* call fl_free_form(), since it destroys the form's data
    structures and all its objects, as well.

    If you call fl_show_form() after freeing the form, you will indeed
    almost invariably "win" a nice core dump -- especially if you have
    called any functions which allocate memory in the mean time, since it
    becomes quite likely that the freed form's data structures will have
    been overwrittten.

    Just call fl_hide_form() and then when you want to show the form
    again, call fl_show_form().

    Refer to the manual for details.


    To unsubscribe, send the message "unsubscribe" to or see
    XForms Home Page:
    List Archive:

    This archive was generated by hypermail 2b29 : Fri Mar 24 2000 - 13:46:15 EST