Bill Caroselli <email@example.com> wrote:
I’ve gotten PtUnrealizWidget() to work.
There’s a big difference between unrealizing a widget and destroying it.
If you just unrealize a dialog, it remembers any changes to its state
that user input or your code may have caused. When you realize it
again, it’ll come up at the same position and size and with the same
contents it had when you unrealized it.
When you destroy a widget (or, more accurately, soon after), it ceases
to exist; if you want to preserve any information that was stored in the
widget, you have to grab it from the widget before it’s destroyed. If
you then create a new copy of it, it’ll come up in its default state,
and you’ll need to put the contents in the widgets again.
Normally, when I want to get rid of a dialog after it’s done its job, I
destroy it. Unrealizing can produce unexpected results – imagine, for
instance, that the user has moved the main window to a different virtual
console but the dialog remembers its position on the old console…
This is a PhAB app and the dialog will be needed again. I seem to
recall that with Photon 1.14 PhAB was less graceful about if you
dismissed a dialog incorectly. I guess I was destroying it.
I remember there were changes in this area before Photon 1.14, but
from a quick look at the code, QNX6 should behave the same way as Photon
Does Photon 2 now have the ability to know if a PHAB widget is extant
and recreate it if it is not?
Both Photon 1.14 and 2 keep track of whether a dialog module exists or
not by setting its ABW variable to NULL when it’s destroyed. For any
other PhAB widget (including the contents of a dialog module), the ABW
variable is set when the widget is created, every time it’s created, and
never set to NULL, even if the widget is destroyed.
When your code calls ApCreateModule() on a dialog, or when a widget
invokes a PhAB callback that points to a dialog module, the PhAB
library checks if the dialog already exists (by examining its ABW
variable). If it doesn’t, it gets created (and its setup function, if
any, is called).
If the dialog already exists, the library just makes sure that it’s
realized, and brings it to the front. (Before 1.14, it used to do
something else if the dialog existed but was unrealized; I don’t
remember what exactly, but I remember that it was something unexpected