Running the code below will cause a crash on 5.8.7/5.6
with Win32-GUI 1.02 when the programme is exited.
use strict;
use Win32::GUI;
#We init the EmployeeSelector class
EmployeeSelector::Init();
# Create the main window
my $mainwindow = new Win32::GUI::Window(
-name => "Window",
-title => "Objects and Windows",
-pos => [100,100],
-size => [400,400],
);
$mainwindow->Show();
#We now create several employee selector 'controls'.
my $search1=EmployeeSelector->new
($mainwindow,20,20);
my $search2=EmployeeSelector->new
($mainwindow,20,50);
my $search3=EmployeeSelector->new
($mainwindow,20,80);
my $search4=EmployeeSelector->new
($mainwindow,20,110);
my $search5=EmployeeSelector->new
($mainwindow,20,140);
#Show all our controls
$search1->Show();
$search2->Show();
$search3->Show();
$search4->Show();
$search5->Show();
$search2->Move(200,200);
#Enter the message processing loop
Win32::GUI::Dialog();
package EmployeeSelector;
#Class spefic globals
my $searchwindow; #The search window
my $active; #The active object
sub Init {
#This is a class function, and is used to initilise all
objects
$searchwindow = new Win32::GUI::DialogBox(
-name => "EmployeeSelector",
-title => "Search for Employee",
-size => [300,270],
);
$searchwindow->AddListView(
-name => 'ListView',
-pos => [8,8],
-size => [280,189],
-fullrowselect=> 1,
);
$searchwindow->AddButton (
-name => 'OK',
-text => 'OK',
-pos => [164,208],
-size => [60,21],
#When we click ok, we populate the calling controls
EmpID
-onClick => sub {my $item=$searchwindow-
>ListView->SelectedItems();
my %hItem=$searchwindow->ListView-
>ItemInfo($item,0);
$active->SetEmpID($hItem{-text});
return -1;
},
);
$searchwindow->AddButton (
-name => 'Cancel',
-text => 'Cancel',
-pos => [228,208],
-size => [60,21],
-onClick => sub {return -1},
);
#populate the list view
$searchwindow->ListView->InsertColumn(-width =>
55,-text => 'Emp ID');
$searchwindow->ListView->InsertColumn(-width =>
205,-text => 'Employee Name');
$searchwindow->ListView->InsertItem(-text =>
[1234, 'Bob Smith']);
$searchwindow->ListView->InsertItem(-text =>
[4321, 'Peter Jones']);
$searchwindow->ListView->InsertItem(-text =>
[7890, 'John Brown']);
}
#The constructor
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
my ($parent,$xcor,$ycor)=@_;
#Create window
my $childwin = new Win32::GUI::Window (
-parent => $parent,
-name => "ChildWin",
-pos => [$xcor,$ycor],
-size => [150, 24],
-popstyle => Win32::GUI::WS_CAPTION |
Win32::GUI::WS_SIZEBOX,
-pushstyle => Win32::GUI::WS_CHILD |
Win32::GUI::WS_CLIPCHILDREN,
);
#add the window to the object
$self->{win}=$childwin;
#Create other controls
$childwin->AddLabel(
-name => 'Label',
-text => 'ID#',
-height => 20,
-width => 20,
-top => 6,
-left => 0,
);
$childwin->AddTextfield (
-name => 'EmpID',
-height => 20,
-width => 35,
-top => 2,
-left => 20,
-tip => 'Employee ID',
);
$childwin->AddButton (
-name => 'Search',
-text => 'Search',
-height => 20,
-width => 60,
-top => 2,
-left => 60,
-tip => 'Search for a Employee ID',
#$self will become a closure
-onClick => sub {Search($self)},
);
return $self;
}
sub Search {
#Open the search window - can be called as a method
or as an event handler
my $self=shift;
#Set the active object to be this object
$active=$self;
$searchwindow->Center;
$searchwindow->DoModal(1);
}
sub SetEmpID {
#Set the EmpID of the text box - can be called as a
method or as an event handler
my $self=shift;
$self->{win}->EmpID->Text(shift);
}
sub Show {
#Show the window
my $self=shift;
$self->{win}->Show();
}
sub Hide {
#Hide the window
my $self=shift;
$self->{win}->Hide();
}
sub Move {
#Move the window
my $self=shift;
$self->{win}->Move(@_);
}
sub DESTROY {
#We have a circular link(?)
my $self=shift;
print 'in Destroy'.$self;
$self->{win}=undef;
}
Logged In: NO
Still a problem under 1.03
Logged In: YES
user_id=674651
Jez,
I think this is the example that you posted to the users
list for feedback from others earlier in the year. The
example in this tracker does not crash for me (Win32::GUI
1.03, Win98, Perl 5.8.7). Can you let me know if it is
still a problem for you? If so, can you let me have details
of error messages, OS, perl and Win32::GUI versions.
Thanks,
ob.
Logged In: NO
Hi,
Still a problem for me...
Looks like this is going to be a real pain to track down.
I've now upgraded to perl 5.8.7 for all development, so my
environment is:
Win32::GUI 1.03, WinXP (sp2), Perl 5.8.7
I've tested this with both the ppm from sourceforge and
manually built Win32::GUI (mingw). When running under a
mingw version, I get the following trace:
perl.exe caused an Access Violation at location 280899be
in module perl58.dll Reading from location fffffffb.
Registers:
eax=ffffffff ebx=0023418c ecx=00232770 edx=00232784
esi=fffffff3 edi=00232770
eip=280899be esp=0140f99c ebp=0140f9f8 iopl=0 nv
up ei ng nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b
gs=0000 efl=00000286
Call stack:
280899BE perl58.dll:280899BE Perl_my_socketpair
233C7932 GUI.dll:233C7932 ControlMsgLoop(HWND__*,
unsigned, unsigned, long) GUI_MessageLoops.cpp:824
LRESULT ControlMsgLoop(HWND__*, unsigned, unsigned, long)(
HWND hwnd = &(indirect),
UINT uMsg = 2,
WPARAM wParam = 0,
LPARAM lParam = 0
)
...
else
PerlResult = DefWindowProc(hwnd, uMsg,
wParam, lParam);
> PERLUD_FREE;
return PerlResult;
case WM_TIMER:
...
Logged In: YES
user_id=674651
Jez,
Although I can't reproduce this, the stack trace point to
the same issue that I think I've resolved looking at
Tracker 1243378 (Richedit crash on exit). Once I've
checked in my latest changes (probably tomorrow) I'd
appreciate it if you could test and see if that fixes this
issue.
Regards,
Rob.
Logged In: YES
user_id=674651
Based on our email conversation I'm going to mark this as
fixed. The fix in is CVS, and will make it into the v1.04
release.