DAD: Dynamic Attribute Dialogs: closing sequence

There are two ways a DAD can be closed:

There are four sets of structures/allocations associated with a DAD:

There is only one allocation sequence:

  1. [caller] allocates the user data
  2. [caller] calls [dad] to allocate the dad ctx: PCB_DAD_NEW()
  3. [dad] calls [HID] to allocate the hid ctx
  4. [HID] calls the [toolkit] to allocate widgets
  5. the [caller] calls PCB_DAD_RUN() or PCB_DAD_AUTORUN()
There are many different free sequences possible, the three most typical ones are:

In other words, one PCB_DAD_NEW() needs to have exactly one PCB_DAD_FREE() pair. If PCB_DAD_FREE() is called while the dialog is on (code close), the dialog is closed and the callback function is called (unless it is already running). The [caller] can access DAD widget states and values only between PCB_DAD_NEW() and PCB_DAD_FREE().