perl-tk icon indicating copy to clipboard operation
perl-tk copied to clipboard

Tk.xs: Grab() method should not return anything

Open chrstphrchvz opened this issue 4 years ago • 1 comments

Address ParseXS warning:

Warning: Found a 'CODE' section which seems to be using 'RETVAL' but no 'OUTPUT' section. in Tk.xs, line 1030

Not sure if this is 100% correct or whether it fixes any actual bugs.

chrstphrchvz avatar Mar 13 '21 12:03 chrstphrchvz

The current situation is for sure wrong. Currently the method seems to return whatever is on top of the perl stack, which is probably not intended. However, the Grab() method (unlike the lowercase counterpart grab()) is not documented, nor can I find any usages of Grab() in the Tk code or even on CPAN. The original Tcl function returns TCL_OK or TCL_ERROR, which suggests that the method should rather return nothing, just throw an exception on errors. So maybe it would be better to change it to

  int result = Tk_Grab(info->interp,info->tkwin,global);
  if (result != TCL_OK)
   {
    croak("%s",Tcl_GetStringResult(info->interp));
   }

and change the return value of Tk_Grab to void.

eserte avatar Mar 14 '21 09:03 eserte