I had this problem pretty frequently with
Win32::GUI::GetOpenFileName()

Things work just fine if you use 
Win32::FileOp::OpenDialog()
instead.  

The Win32::FileOp module is available from Jenda at
<http://jenda.krynicky.cz/>.

Laurent Rocher wrote:
> 
> Hello all,
> 
> I am new in the mailling list.
> I am french and my english is probably not good.
> 
> I think i have a bug report ;)
> I use Win32::GUI version 0.0.425.
> 
> I have a random error with GetOpenFileName.
> 
> my $ret = Win32::GUI::GetOpenFileName(
>                   -title  => "Choose a text file",
>                   -filter => [
>                       'Text documents (*.txt)' => '*.txt',
>                       'All files' => '*.*'
>                    ],
>                 );
> 
> My script stop and i receive in my console :
> 
> Out of memory!
> Callback called exit.
> 
> This error append only when i use the filter option of GetOpenFileName.
> 
> I look in gui.xs file and i think this error come from the filterlen variable.
> filterlen is not set to 0 and use after like :  filterlen += SvCUR(*t) + 1;
> so filterlen is not good.
> filterlen must be declare to 0.
> 
> The code below come from an old Version: 0.0.340 (02 Jul 1999) but it's probably
> the same code in version 0425 for GetOPenFileName function.
> 
> I have not tested with correction. I want first found 0.0.425 source code.
> 
>         Laurent.
> 
> ---- extract of GetOpenFileName function -----
> 
>             if(strcmp(option, "-filter") == 0) {
>                 next_i = i + 1;
>                 if(SvROK(ST(next_i)) && SvTYPE(SvRV(ST(next_i))) == SVt_PVAV) {
>                     AV* filters;
>                     SV** t;
>                     int i, filterlen = 0; // Original 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;
>                         }
>                     }
>                     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(*t, na));
>                             fpointer += SvCUR(*t) + 1;
>                             *fpointer = 0;
>                         }
> 
>                     }
>                     fpointer++;
>                     *fpointer = 0;
>                     ofn.lpstrFilter = (LPCTSTR) filter;
>                 } else {
>                     if(dowarn) warn("Win32::GUI: argument to -filter is not an
> array reference!");
>                 }
> 
> ------------------------------------------

-- 
Brian Lalonde  [EMAIL PROTECTED]  
Web Developer/DBA, Technology Services 
Spokane Public School District 81

Reply via email to