Back to the main page.

Bug 2407 - function handles with warning_once

Status CLOSED FIXED
Reported 2013-12-03 16:00:00 +0100
Modified 2014-03-12 12:19:58 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: All
Operating System: All
Importance: P3 minor
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks:
See also:

Guillaume - 2013-12-03 16:00:58 +0100

warning_once crashes if the initial calling function is a function handle: Invalid field name: '@(x,y)my_function(y)'. In file "fieldtrip/utilities/private/warning_once.m" (v8355), function "fieldnameFromStack" at line 196. In file "fieldtrip/utilities/private/warning_once.m" (v8355), function "warning_once" at line 123. In file "fieldtrip/utilities/private/ft_postamble_history.m" (v8241), function "ft_postamble_history" at line 55. In file "fieldtrip/utilities/ft_postamble.m" (v7134), function "ft_postamble" at line 55.


Jörn M. Horschig - 2014-01-29 13:20:57 +0100

*** Bug 2459 has been marked as a duplicate of this bug. ***


Jörn M. Horschig - 2014-01-29 13:53:18 +0100

fixed, the fix is available in tomorrow's FT version svn ci warning_once.m -m "warning stack names can only contain letters and numbers" Sending warning_once.m Transmitting file data . Committed revision 9140. thanks for reporting this!


Ian Andolina - 2014-01-29 18:17:23 +0100

Hi Jörn, This is still broken for me after using your patch: https://github.com/fieldtrip/fieldtrip/compare/9bf2839971...c46820faa1 Invalid field name: 'plxReader.ftTimeLockAnalysis'. Error in warning_once>fieldnameFromStack (line 198) ft_previous_warnings.(stack(end).name) = []; % iteratively build up structure fields fname = horzcat(stack(end).name); %remove anything but characters and numbers fname = regexprep(fname,'[^a-zA-Z0-9]',''); if ~issubfield(ft_previous_warnings, stack(end).name) ft_previous_warnings.(stack(end).name) = []; % iteratively build up structure fields end You need to use fname: fname = horzcat(stack(end).name); %remove anything but characters and numbers fname = regexprep(fname,'[^a-zA-Z0-9]',''); if ~issubfield(ft_previous_warnings, fname) ft_previous_warnings.(fname) = []; % iteratively build up structure fields end


Jörn M. Horschig - 2014-01-30 08:56:08 +0100

Hi Ian, yes, I also realized that right after writing this comment, see http://code.google.com/p/fieldtrip/source/diff?spec=svn9143&r=9143&format=side&path=/trunk/utilities/private/warning_once.m that should work, right?


Ian Andolina - 2014-01-30 10:44:25 +0100

Yes, fixname correctly parses both my 'class.method' and the @()anonymous function names properly, so fixed!