-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
same goes for GetSaveFileName.
NB:
also if you're a pedant (like me) then you can change
filterlen += 2, to filterlen++ (so long as you change the pointer
stuff), and save a _whole_ byte of memory (for about 15 seconds).
> Sorry about essentially spamming this newsgroup, but I have a fix
> for the following problem (if anyone else is ever actually effected by
> it).
>
> in the GetOpenFileName XSUB; change to following code:
> int i, filterlen;
> char *fpointer;
> filters = (AV*)SvRV(ST(next_i));
> for(i=0; i<=av_len(filters); i++) {
> t = av_fetch(filters, i, 0);
> if(t != NULL) {
> filterlen += SvCUR(*t) + 1;
> }
> }
> to:
> int i, filterlen = 0; /* <---- must
> initialize this */
> char *fpointer;
> filters = (AV*)SvRV(ST(next_i));
> for(i=0; i<=av_len(filters); i++) {
> t = av_fetch(filters, i, 0);
> if(t != NULL) {
> filterlen += SvCUR(*t) + 1;
> }
> }
>
> also (and _please_ correct me if I'm wrong) I've changed the
> following code a little, as I disagree with the pointer arithmetic.
>
> filterlen += 2;
> filter = (char *) safemalloc(filterlen);
> fpointer = filter;
> for(i=0; i<=av_len(filters); i++) {
> t = av_fetch(filters, i, 0);
> if(t != NULL) {
> strcpy(fpointer, SvPV_nolen(*t));
> fpointer += SvCUR(*t);
> /* no + 1 */
> *fpointer++ = 0; /* changed */
> }
>
> }
> *fpointer = 0; /* changed */
> ofn.lpstrFilter = (LPCTSTR) filter;
>
> hope this helps someone. If not then sorry for the needless traffic.
>
> > can anyone out there recreate this:
> >
> > from perl call
> > my $filename = Win32::GUI::GetOpenFileName(
> > -filter => [
> > "File type 1" => "*.ft1",
> > "File type 2" => "*.ft2",
> > ],
> > );
> >
> > now call this twice. The first time it works wonderfully, the second
> > time it causes my program to exit, and this is displayed:
> > Out of memory!
> > Callback called exit.
> > (I believe the message is from the perl interpreter rather than win32-
> > gui).
> >
> > I'd be interested to hear if anyone is using this function with
> > success (multiple times), as it may be a problem purely with my
> > build of win32-gui (0.0502) or perl (5.60).
> >
> > It doesn't seem to happen unless you specify a filter. All the other
> > options work perfectly.
> >
> > Sam Jacobson
> > R & D Manager / Software Engineer
> > Selective Communications
> > Ph +64 9 302 1142
> > www.selective.co.nz
> >
> > _______________________________________________
> > Perl-Win32-GUI-Users mailing list
> > [email protected]
> > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> >
> >
>
> Sam Jacobson
> R & D Manager / Software Engineer
> Selective Communications
> Ph +64 9 302 1142
> www.selective.co.nz
>
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> [email protected]
> http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
>
>
-----BEGIN PGP SIGNATURE-----
Version: N/A
iQA/AwUBOlyX45sRND2Z+TaWEQIEAACcCwaE+SlILJnPMgDI6oX99+27yg0An1ig
Y4DrESrVnnx4uF4kHJ3oRD7r
=AdVr
-----END PGP SIGNATURE-----
Sam Jacobson
R & D Manager / Software Engineer
Selective Communications
Ph +64 9 302 1142
www.selective.co.nz