This queue is for tickets about the Wx CPAN distribution.

Report information
The Basics
Id:
99607
Status:
rejected
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
pwnbusiness2012 [...] centurylink.net
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



Subject: Issue using wxTextEntryBox
Date: Mon, 20 Oct 2014 19:52:05 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
Hello,

I was attempting to use a wxTextEntryBox object in my application and I ran into a little issue.

I'm using Wx 0.9923 and Strawberry Perl v. 5.16.3 (built for MSWin32-x86-multi-thread) under Windows XP 32-bit SP3.  It think the WxWidgets install is v. 3.0.0.

The following is the code:

#!/usr/bin/env perl

use warnings;
use strict;
use Wx qw(:everything);


package MyFrame;
   
use base 'Wx::Frame';

sub new {

    my $ref = shift;
    my $self = $ref->SUPER::new( undef,
                                 1,
                                 'Parent Window',
                                 Wx::wxDefaultPosition,
                                 [500, 500],
                               );
    my $panel = Wx::Panel->new( $self,
                                2
                              );
    my $dialog = Wx::TextEntryDialog->new( $panel,
                                           'Please Enter Text',
                                           'Dialog Header',
                                           "",
                                           Wx::wxOK|Wx::wxCANCEL,
                                           Wx::wxDefaultPosition
                                         );
                                     
    return $self;
}

package MyApp;

use base 'Wx::App';

sub OnInit {

    my $frame = MyFrame->new;

    $frame->Show( 1 );

}

package main;

my $app = MyApp->new;
$app->MainLoop;

When I launch this code from the command prompt in a command window and then exit the program normally (using the red "X" in the upper right hand side of the window), the window closes, but the program does not terminate.  I have to use Control+C to get the command prompt to return and I get the message "Terminating on signal SIGINT(2)."  If I comment out the call to the "new" method of the TextEntryDialog, the program will exit normally and the command prompt will be redisplayed with no error message.

Thanks for your time.

Patrick Nighswonger
Hi Patrick, Add this line after the dialog creation and try again. You might understand what is happening. $dialog->Show(1); -- Erik
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 09:00:26 +0100
To: bug-Wx@rt.cpan.org, wxperl-users@perl.org
From: Steve Cookson <steve.cookson@sca-uk.com>
Hi Patrick, On 21-10-2014 00:52, Patrick via RT wrote:
Show quoted text
> my $self = $ref->SUPER::new( undef, > 1, > 'Parent Window', > Wx::wxDefaultPosition, > [500, 500], > ); > my $panel = Wx::Panel->new( $self, > 2 > );
If you use -1 (or wxID_ANY) as the widget ID, it will assign the next free identifier. Then you don't have to keep track of what has already been used. Regards, Steve.
On Tue Oct 21 02:26:08 2014, ecocode wrote:
Show quoted text
> Hi Patrick, > > Add this line after the dialog creation and try again. You might > understand what is happening. > > $dialog->Show(1);
I'll explain my point of view on this: Wx::TextEntryBox is a 'convenience' Dialog which, although 'parent' aught to be defined in the constructor, the dialog is not added as a children to the parent. Reason for this is that $dialog has no wxwindow ID (look at the constructor params). Therefor it can't be added as a children to any wx container. This kind of dialogs are ment to be used in procedures where they are shown modally, and then destroyed. You can use DDP to show the relation to other widgets i.e.: use DDP; p $frame->GetChildren; # should show the panel as a children p $panel->GetChildren; # doesn't show the dialog as a children also try p $panel; p $dialog; which illustrates the internal difference between both. In conclusion: destroying $frame destroys $panel, but won't destroy $dialog, because it is _not_ the child of $panel. So, you are on your own to destroy the dialog with $dialog->Destroy; you can argue against this behaviour, but this is rather wxwidgets related and probably shouldn't be altered in wxPerl, assuming it can be. -- Erik
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 08:04:20 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
Thanks for the suggestion. I find it convenient to use explicit identifiers on everything since I do need to use explicit identifiers on some things to access them in certain situations. This code sample doesn't reflect that fact, but it is a clip from a larger piece.
Show quoted text
----- Original Message ----- From: "Steve Cookson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 4:00:48 AM Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > Hi Patrick, On 21-10-2014 00:52, Patrick via RT wrote:
> my $self = $ref->SUPER::new( undef, > 1, > 'Parent Window', > Wx::wxDefaultPosition, > [500, 500], > ); > my $panel = Wx::Panel->new( $self, > 2 > );
If you use -1 (or wxID_ANY) as the widget ID, it will assign the next free identifier. Then you don't have to keep track of what has already been used. Regards, Steve.
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 08:05:59 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
Thanks for the response. In another piece of code, I actually used a ShowModal() call to display the window with the same result. I think I follow what you are saying, and I will give it a try.
Show quoted text
----- Original Message ----- From: "Erik Colson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 4:20:44 AM Subject: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > On Tue Oct 21 02:26:08 2014, ecocode wrote:
> Hi Patrick, > > Add this line after the dialog creation and try again. You might > understand what is happening. > > $dialog->Show(1);
I'll explain my point of view on this: Wx::TextEntryBox is a 'convenience' Dialog which, although 'parent' aught to be defined in the constructor, the dialog is not added as a children to the parent. Reason for this is that $dialog has no wxwindow ID (look at the constructor params). Therefor it can't be added as a children to any wx container. This kind of dialogs are ment to be used in procedures where they are shown modally, and then destroyed. You can use DDP to show the relation to other widgets i.e.: use DDP; p $frame->GetChildren; # should show the panel as a children p $panel->GetChildren; # doesn't show the dialog as a children also try p $panel; p $dialog; which illustrates the internal difference between both. In conclusion: destroying $frame destroys $panel, but won't destroy $dialog, because it is _not_ the child of $panel. So, you are on your own to destroy the dialog with $dialog->Destroy; you can argue against this behaviour, but this is rather wxwidgets related and probably shouldn't be altered in wxPerl, assuming it can be. -- Erik
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 09:09:47 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
I tried what you suggested, and nothing changes. I use a SingleChoiceDialog in another program and this works flawlessly. It seems to be of the same vein as the TextEntryBox. How is the SingleChoiceDialog handled?
Show quoted text
----- Original Message ----- From: "Erik Colson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 4:20:44 AM Subject: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > On Tue Oct 21 02:26:08 2014, ecocode wrote:
> Hi Patrick, > > Add this line after the dialog creation and try again. You might > understand what is happening. > > $dialog->Show(1);
I'll explain my point of view on this: Wx::TextEntryBox is a 'convenience' Dialog which, although 'parent' aught to be defined in the constructor, the dialog is not added as a children to the parent. Reason for this is that $dialog has no wxwindow ID (look at the constructor params). Therefor it can't be added as a children to any wx container. This kind of dialogs are ment to be used in procedures where they are shown modally, and then destroyed. You can use DDP to show the relation to other widgets i.e.: use DDP; p $frame->GetChildren; # should show the panel as a children p $panel->GetChildren; # doesn't show the dialog as a children also try p $panel; p $dialog; which illustrates the internal difference between both. In conclusion: destroying $frame destroys $panel, but won't destroy $dialog, because it is _not_ the child of $panel. So, you are on your own to destroy the dialog with $dialog->Destroy; you can argue against this behaviour, but this is rather wxwidgets related and probably shouldn't be altered in wxPerl, assuming it can be. -- Erik
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 11:14:45 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
Isn't the "parent" parameter in the call to the "new" method the parent window?
Show quoted text
----- Original Message ----- From: "Erik Colson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 4:20:44 AM Subject: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > On Tue Oct 21 02:26:08 2014, ecocode wrote:
> Hi Patrick, > > Add this line after the dialog creation and try again. You might > understand what is happening. > > $dialog->Show(1);
I'll explain my point of view on this: Wx::TextEntryBox is a 'convenience' Dialog which, although 'parent' aught to be defined in the constructor, the dialog is not added as a children to the parent. Reason for this is that $dialog has no wxwindow ID (look at the constructor params). Therefor it can't be added as a children to any wx container. This kind of dialogs are ment to be used in procedures where they are shown modally, and then destroyed. You can use DDP to show the relation to other widgets i.e.: use DDP; p $frame->GetChildren; # should show the panel as a children p $panel->GetChildren; # doesn't show the dialog as a children also try p $panel; p $dialog; which illustrates the internal difference between both. In conclusion: destroying $frame destroys $panel, but won't destroy $dialog, because it is _not_ the child of $panel. So, you are on your own to destroy the dialog with $dialog->Destroy; you can argue against this behaviour, but this is rather wxwidgets related and probably shouldn't be altered in wxPerl, assuming it can be. -- Erik
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 12:05:48 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
I ran it with Data Dumper. $dialog does not show up as a child. When I create a wxSingleChoiceDialog, that does show up as a child. Why is the handling of these two different?
Show quoted text
----- Original Message ----- From: "Erik Colson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 4:20:44 AM Subject: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > On Tue Oct 21 02:26:08 2014, ecocode wrote:
> Hi Patrick, > > Add this line after the dialog creation and try again. You might > understand what is happening. > > $dialog->Show(1);
I'll explain my point of view on this: Wx::TextEntryBox is a 'convenience' Dialog which, although 'parent' aught to be defined in the constructor, the dialog is not added as a children to the parent. Reason for this is that $dialog has no wxwindow ID (look at the constructor params). Therefor it can't be added as a children to any wx container. This kind of dialogs are ment to be used in procedures where they are shown modally, and then destroyed. You can use DDP to show the relation to other widgets i.e.: use DDP; p $frame->GetChildren; # should show the panel as a children p $panel->GetChildren; # doesn't show the dialog as a children also try p $panel; p $dialog; which illustrates the internal difference between both. In conclusion: destroying $frame destroys $panel, but won't destroy $dialog, because it is _not_ the child of $panel. So, you are on your own to destroy the dialog with $dialog->Destroy; you can argue against this behaviour, but this is rather wxwidgets related and probably shouldn't be altered in wxPerl, assuming it can be. -- Erik
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 20:43:24 +0100
To: bug-Wx@rt.cpan.org, wxperl-users@perl.org
From: Steve Cookson <steve.cookson@sca-uk.com>
Hi Patrick,

On 21-10-2014 17:06, Patrick via RT wrote:
Show quoted text
 When I create a wxSingleChoiceDialog, that does show up as a child.  Why is the handling of these two different?
Well, the implementation of the wxSingleChoiceDialog is much more complicated. You can look in wxPerl::XS. Here isTextEntryBox:
Show quoted text
wxTextEntryDialog::new( parent, message, caption = wxGetTextFromUserPromptStr, defaultValue = wxEmptyString, style = wxTextEntryDialogStyle, pos = wxDefaultPosition )
    wxWindow* parent
    wxString message
    wxString caption
    wxString defaultValue
    long style
    wxPoint pos

and here is wxSingleChoiceDialog:
Show quoted text
wxSingleChoiceDialog::new( parent, message, caption, chs, dt = &PL_sv_undef, style = wxCHOICEDLG_STYLE, pos = wxDefaultPosition )
    wxWindow* parent
    wxString message
    wxString caption
    SV* chs
    SV* dt
    long style
    wxPoint pos
  PREINIT:
    wxString* choices;
    SV** data;
    int n, n2;
  CODE:
    n = wxPli_av_2_stringarray( aTHX_ chs, &choices );
    if( !SvOK( dt ) )
    {
      RETVAL = new wxPliSingleChoiceDialog( parent, message, caption, n,
            choices, 0, style, pos );
    }
    else
    {
      n2 = wxPli_av_2_svarray( aTHX_ dt, &data );
      if( n != n2 )
      {
        delete[] choices;
        delete[] data;
        choices = 0; data = 0; n = 0;
        croak( "supplied arrays of different size" );
      }
      RETVAL = new wxPliSingleChoiceDialog( parent, message, caption, n,
            choices, data, style, pos );
      delete[] data;
    }
    delete[] choices;
  OUTPUT:
    RETVAL
wxSingleChoiceDialog has a whole new .cpp function (wxPliSingleChoiceDialog) written within wxPerl.  It also has a destructor there.  It is one of only 7 .cpps. It's not clear to me how the destructor it is called, but the two functions are implemented very differently.

It would be good to understand why they are different and bring them into line with each other.

Regards,

Steve.





Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 16:15:57 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
Thanks for the reply, Steve. I can see what you are saying. I have C and some slight C++ experience from years ago. It was just when OOP was starting to take off. I'd be glad to try to get oriented enough that I could make a little contribution, but right now I'm a little disoriented in the syntax and protocol of the open-source contribution system not to mention the wxperl contribution system. What file is the wxTextEntryDialog code in? I can see the wxSingleChoiceDialog that you are speaking of.
Show quoted text
----- Original Message ----- From: "Steve Cookson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 3:43:42 PM Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > Hi Patrick, On 21-10-2014 17:06, Patrick via RT wrote:
> When I create a wxSingleChoiceDialog, that does show up as a child. Why is the handling of these two different?
Well, the implementation of the wxSingleChoiceDialog is much more complicated. You can look in wxPerl::XS. Here isTextEntryBox: wxTextEntryDialog::new( parent, message, caption = wxGetTextFromUserPromptStr, defaultValue = wxEmptyString, style = wxTextEntryDialogStyle, pos = wxDefaultPosition ) wxWindow* parent wxString message wxString caption wxString defaultValue long style wxPoint pos and here is wxSingleChoiceDialog: wxSingleChoiceDialog::new( parent, message, caption, chs, dt = &PL_sv_undef, style = wxCHOICEDLG_STYLE, pos = wxDefaultPosition ) wxWindow* parent wxString message wxString caption SV* chs SV* dt long style wxPoint pos PREINIT: wxString* choices; SV** data; int n, n2; CODE: n = wxPli_av_2_stringarray( aTHX_ chs, &choices ); if( !SvOK( dt ) ) { RETVAL = new wxPliSingleChoiceDialog( parent, message, caption, n, choices, 0, style, pos ); } else { n2 = wxPli_av_2_svarray( aTHX_ dt, &data ); if( n != n2 ) { delete[] choices; delete[] data; choices = 0; data = 0; n = 0; croak( "supplied arrays of different size" ); } RETVAL = new wxPliSingleChoiceDialog( parent, message, caption, n, choices, data, style, pos ); delete[] data; } delete[] choices; OUTPUT: RETVAL wxSingleChoiceDialog has a whole new .cpp function (wxPliSingleChoiceDialog) written within wxPerl. It also has a destructor there. It is one of only 7 .cpps. It's not clear to me how the destructor it is called, but the two functions are implemented very differently. It would be good to understand why they are different and bring them into line with each other. Regards, Steve.
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 21:38:11 +0100
To: bug-Wx@rt.cpan.org, wxperl-users@perl.org
From: Steve Cookson - gmail <steveco.1959@gmail.com>
Hi Patrick, On 21-10-2014 21:16, Patrick via RT wrote:
Show quoted text
> Thanks for the reply, Steve. I can see what you are saying. I have C and some slight C++ experience from years ago. It was just when OOP was starting to take off. I'd be glad to try to get oriented enough that I could make a little contribution, but right now I'm a little disoriented in the syntax and protocol of the open-source contribution system not to mention the wxperl contribution system.
Your not alone in that! wxPerl has been more organised in the past, but we've been through a bit of a hiatus this year and we're still trying to pull ourselves together.
Show quoted text
> What file is the wxTextEntryDialog code in?
wxPerl::XS::TextEntryDialog.xs
Show quoted text
> I can see the wxSingleChoiceDialog that you are speaking of.
wxPerl::XS::SingleChoiceDialog.xs wxPerl::cpp::SingleChoiceDialog. But there are many other references to all these files across the directories in MANIFEST files, Makefile files and typemap files among others. There are some descriptions about how it all hangs together on the wiki, here: http://wiki.wxperl.nl/Main_Page especially the first two items: here: http://wiki.wxperl.nl/NewClass and here: http://wiki.wxperl.nl/Internals_-_Introduction_to_Wx_XS_Wrappers Good luck. Regards Steve
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Tue, 21 Oct 2014 16:54:21 -0400
To: <bug-Wx@rt.cpan.org>
From: "Patrick Nighswonger" <pwnbusiness2012@centurylink.net>
Thanks. I'll see what I can digest of it.
Show quoted text
----- Original Message ----- From: "Steve Cookson - gmail via RT" <bug-Wx@rt.cpan.org> To: <pwnbusiness2012@centurylink.net> Sent: Tuesday, October 21, 2014 4:38 PM Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
> <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > > > Hi Patrick, > > On 21-10-2014 21:16, Patrick via RT wrote:
>> Thanks for the reply, Steve. I can see what you are saying. I have C >> and some slight C++ experience from years ago. It was just when OOP was >> starting to take off. I'd be glad to try to get oriented enough that I >> could make a little contribution, but right now I'm a little disoriented >> in the syntax and protocol of the open-source contribution system not to >> mention the wxperl contribution system.
> Your not alone in that! wxPerl has been more organised in the past, but > we've been through a bit of a hiatus this year and we're still trying to > pull ourselves together.
>> What file is the wxTextEntryDialog code in?
> wxPerl::XS::TextEntryDialog.xs >
>> I can see the wxSingleChoiceDialog that you are speaking of.
> wxPerl::XS::SingleChoiceDialog.xs > wxPerl::cpp::SingleChoiceDialog. > > But there are many other references to all these files across the > directories in MANIFEST files, Makefile files and typemap files among > others. > > There are some descriptions about how it all hangs together on the wiki, > here: > > http://wiki.wxperl.nl/Main_Page > > especially the first two items: > > here: > > http://wiki.wxperl.nl/NewClass > > and here: > > http://wiki.wxperl.nl/Internals_-_Introduction_to_Wx_XS_Wrappers > > Good luck. > > Regards > > Steve >
--- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Wed, 22 Oct 2014 08:50:21 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
Just from a quick look over a few things, it looks like the only difference in is that the wxSingleChoiceDialog XS(?) file handles client data or if client data is not present, an overloading situation exits. It may be a problem in wxWidgets itself and not in wxperl.
Show quoted text
----- Original Message ----- From: "Steve Cookson - gmail via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 4:38:25 PM Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > Hi Patrick, On 21-10-2014 21:16, Patrick via RT wrote:
> Thanks for the reply, Steve. I can see what you are saying. I have C and some slight C++ experience from years ago. It was just when OOP was starting to take off. I'd be glad to try to get oriented enough that I could make a little contribution, but right now I'm a little disoriented in the syntax and protocol of the open-source contribution system not to mention the wxperl contribution system.
Your not alone in that! wxPerl has been more organised in the past, but we've been through a bit of a hiatus this year and we're still trying to pull ourselves together.
> What file is the wxTextEntryDialog code in?
wxPerl::XS::TextEntryDialog.xs
> I can see the wxSingleChoiceDialog that you are speaking of.
wxPerl::XS::SingleChoiceDialog.xs wxPerl::cpp::SingleChoiceDialog. But there are many other references to all these files across the directories in MANIFEST files, Makefile files and typemap files among others. There are some descriptions about how it all hangs together on the wiki, here: http://wiki.wxperl.nl/Main_Page especially the first two items: here: http://wiki.wxperl.nl/NewClass and here: http://wiki.wxperl.nl/Internals_-_Introduction_to_Wx_XS_Wrappers Good luck. Regards Steve
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Wed, 22 Oct 2014 08:54:59 -0400 (EDT)
To: bug-Wx@rt.cpan.org
From: Patrick <pwnbusiness2012@centurylink.net>
(repost) Just from a quick look over a few things, it looks like the only difference in them is that the wxSingleChoiceDialog XS(?) file handles client data or if client data is not present, an overloading situation exists. It may be a problem in wxWidgets itself and not in wxperl.
Show quoted text
----- Original Message ----- From: "Patrick" <pwnbusiness2012@centurylink.net> To: bug-Wx@rt.cpan.org Sent: Tuesday, October 21, 2014 4:15:57 PM Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox Thanks for the reply, Steve. I can see what you are saying. I have C and some slight C++ experience from years ago. It was just when OOP was starting to take off. I'd be glad to try to get oriented enough that I could make a little contribution, but right now I'm a little disoriented in the syntax and protocol of the open-source contribution system not to mention the wxperl contribution system. What file is the wxTextEntryDialog code in? I can see the wxSingleChoiceDialog that you are speaking of.
----- Original Message ----- From: "Steve Cookson via RT" <bug-Wx@rt.cpan.org> To: pwnbusiness2012@centurylink.net Sent: Tuesday, October 21, 2014 3:43:42 PM Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox <URL: https://rt.cpan.org/Ticket/Display.html?id=99607 > Hi Patrick, On 21-10-2014 17:06, Patrick via RT wrote:
> When I create a wxSingleChoiceDialog, that does show up as a child. Why is the handling of these two different?
Well, the implementation of the wxSingleChoiceDialog is much more complicated. You can look in wxPerl::XS. Here isTextEntryBox: wxTextEntryDialog::new( parent, message, caption = wxGetTextFromUserPromptStr, defaultValue = wxEmptyString, style = wxTextEntryDialogStyle, pos = wxDefaultPosition ) wxWindow* parent wxString message wxString caption wxString defaultValue long style wxPoint pos and here is wxSingleChoiceDialog: wxSingleChoiceDialog::new( parent, message, caption, chs, dt = &PL_sv_undef, style = wxCHOICEDLG_STYLE, pos = wxDefaultPosition ) wxWindow* parent wxString message wxString caption SV* chs SV* dt long style wxPoint pos PREINIT: wxString* choices; SV** data; int n, n2; CODE: n = wxPli_av_2_stringarray( aTHX_ chs, &choices ); if( !SvOK( dt ) ) { RETVAL = new wxPliSingleChoiceDialog( parent, message, caption, n, choices, 0, style, pos ); } else { n2 = wxPli_av_2_svarray( aTHX_ dt, &data ); if( n != n2 ) { delete[] choices; delete[] data; choices = 0; data = 0; n = 0; croak( "supplied arrays of different size" ); } RETVAL = new wxPliSingleChoiceDialog( parent, message, caption, n, choices, data, style, pos ); delete[] data; } delete[] choices; OUTPUT: RETVAL wxSingleChoiceDialog has a whole new .cpp function (wxPliSingleChoiceDialog) written within wxPerl. It also has a destructor there. It is one of only 7 .cpps. It's not clear to me how the destructor it is called, but the two functions are implemented very differently. It would be good to understand why they are different and bring them into line with each other. Regards, Steve.
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
Subject: Re: [rt.cpan.org #99607] Issue using wxTextEntryBox
Date: Mon, 27 Oct 2014 18:31:25 -0400
To: <bug-Wx@rt.cpan.org>
From: "Patrick Nighswonger" <pwnbusiness2012@centurylink.net>
Thanks. Yes that helps. So you are saying that I should wait until I call a subroutine to actually create a new instance of the TextEntryDialog. That way the panel would already be visible and would therefore be a valid parent?
Show quoted text
----- Original Message ----- From: "Mark Dootson via RT" <bug-Wx@rt.cpan.org> To: <pwnbusiness2012@centurylink.net> Sent: Monday, October 27, 2014 3:05 PM Subject: [rt.cpan.org #99607] Issue using wxTextEntryBox
> <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 > > > > > > > > > > > > > > > > > > > > >
--- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.