Mon Oct 27 15:05:08 2014: Request 99607 was acted upon.
Transaction: Correspondence added by MDOOTSON
       Queue: Wx
     Subject: Issue using wxTextEntryBox
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: pwnbusiness2...@centurylink.net
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 >


Hi,

Your issue with Wx::TextEntryBox arises from the basic way wxWidgets handles 
applications and windows.

The basic rule is that the main application loop will exit when no more 
instances of Wx::TopLevelWindow ( e.g. Wx::Frame and Wx::Dialog ) exist in the 
application.

Top level windows (Frames and Dialogs) must be explicitly destroyed.

$dialog_>Destroy;

unless your code causes them to be destroyed by some other method (such as 
being a child of another TopLevelWindow when it is destroyed or the automatic 
behaviour when you close the window using system menus / buttons).

In your example, none of these things happens so the application loop never 
exits. Your Wx::TextEntryDialog has no parent so continues to exist after you 
close your Frame.

Dialogs designed for modal usage, such as Wx::TextEntryDialog, need to have a 
valid parent to work properly, or be created as  a special case without a 
parent.

When you create the dialog and pass in the Wx::Panel as the parent the 
following things happen.

Dialogs need top level parents so the wxWidgets code determines the parent of 
Wx::Panel - your frame - and checks if that is a valid parent. It isn't - a 
parent top level window needs to be visible on the display to be a valid parent 
for a dialog. So the dialog is created without a parent. When you close the 
$frame, the TextEntryDialog is left hanging around so the main application loop 
never exits.

In this situation, wxWidgets will use anything you have set as the top window 
(wxTheApp->SetTopWindow) but your example does not do this.

In standard usage you would always do:

my $dialog = Wx::textEntryDialog->new(....);
my $result = $dialog->ShowModal;
# .. get stuff from dialog
$dialog->Destroy;

so your particular issue would not arise.

With regard to the different in implementation between Wx:TextEntryDialog and 
Wx::SingleChoiceDialog, it is indeed because of the use of client data. The 
wxPerl implementation allows you to pass a reference to an array of anything 
(so maybe references to objects) so a C++ class is required to maintain the 
correct reference counts on the Perl SVs for the array ref.

Hope it helps

Mark
















 




Reply via email to