Dialog items lifecycle

A place where plug-in developers can share their knowledge and experience.
Post Reply
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Dialog items lifecycle

Post 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?
User avatar
DrKnS
Posts: 6114
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 12 times
Been thanked: 426 times

Dialog items lifecycle

Post 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.
Post Reply

Return to “Plug-In Developers”