[fxruby-users] Closing a modal FXDialogBox correctly?
Jeroen van der Zijp
jeroen at fox-toolkit.org
Wed Jan 31 13:29:55 EST 2007
On Wednesday 31 January 2007 12:07, Philippe Lang wrote:
> Jeroen van der Zijp wrote:
> > On Wednesday 31 January 2007 11:11, Philippe Lang wrote:
> >> Hi,
> >>
> >> Very rarely, I have a bug when closing a modal dialog box.
> >>
> >> What is the 100% correct way of closing a modal dialog box,
> >> programmatically, from within the dialog code itself?
> >
> > To close the dialog, the ID_ACCEPT or ID_CANCEL message is used,
> > which (1) breaks out of the modal loop and (2) hides the window.
> >
> > Implied herein is that you've started the modal loop via the dialog's
> > execute() function [or with runModalFor()].
> >
> > The modal event loop is a re-incarnation of the event loop which
> > won't return to the caller until the stopModal() function is invoked.
> >
> > Note that the window argument in runModalFor() and stopModal() must
> > match up; perhaps that is the problem?
>
> Hi,
>
> Thanks for your answer.
>
> I'm starting all the dialogs with a call to "execute", so I don't have
> to pass any specific parameter as an argument.
>
> Is there a chance there can be in very rare occasions some sort of
> "concurrency" problem when closing a dialog which is receving a fox
> message mostly in the same time? And that the code triggered by the fox
> message relies on a "half-closed" dialog somehow? I ask this because I
> got twice a message which is "This FXTextField * already release". All
> my dialogs contain at least one "FXTextField"...
The only thing you need to be aware of is that there is some nastiness
when you use the SEL_COMMAND from FXTextField to close the dialog using
ID_ACCEPT.
This is because the SEL_COMMAND may be generated when you're focusing
out of the FXTextField into another widget, and this could cause the
FXTextField to commit its value.
The fix is to pass TEXTFIELD_ENTER_ONLY, which will stop FXTextField
from issueing SEL_COMMAND due to focus-out.
Most likely, however, this is not your problem here.
> Note that I'm using the Ruby bindings. Is there a chance the problems
> comes from here?
Yes, indeed. It appears to have to do with the Ruby garbage collector;
I believe Lyle was in the process of fixing this, however.
I've bounced this mail to him to see if he's aware of any specifics.
- Jeroen
More information about the fxruby-users
mailing list