Page 1 of 1

Dialog items lifecycle

Posted: Tue 14 Jan, 2020 13:03
by pepak
Hi! Is there a description of the expected lifecycle of items in FAR dialogs? What I mean is:

At some time, I build an array of FarDialogItems and call DialogInit with this array. The function builds the dialog and returns a Handle, which I can use to display the dialog and later to free the dialog using DialogFree. That's clear.

What is not clear is the array of FarDialogItems. Once DialogInit completes, do I still need that array of can I free it? Currently, I am assuming that I need to keep that array, but that leads to quite a complicated code, so if I don't need to array, I would like to know about it so that I could get rid of the code.

Incidentally, very much the same question applies to other structures, too. When can I free the structures used in GetGlobalInfoW or GetPluginInfoW?

Dialog items lifecycle

Posted: Wed 15 Jan, 2020 00:50
by DrKnS
pepak wrote:
Tue 14 Jan, 2020 13:03
Once DialogInit completes, do I still need that array
No.
When can I free the structures used in GetGlobalInfoW or GetPluginInfoW?
Rule of thumb: if a function wants a pointer to your data, the data should remain valid at least until the next call of the function, even better until ExitFARW, even better always.