NearestResolution not working because screen('Resolutions') returns empty field

Hi,

I don't know under which conditions this replicates, but sometimes when
calling NearestResolution, I get the following error message (using PTB
2.53, Mac OS 10.3.4, Classic mode)

> ??? Error using ==> /
> Matrix dimensions must agree.
> Error in ==> x:Applications (Mac OS 9):MATLAB
> 5:Toolbox:PsychToolbox_2.53:PsychOneLiners:NearestResolution.m
> (distance)
> On line 93 ==> d=d+log10(a.width/b.width)^2;
> Error in ==> x:Applications (Mac OS 9):MATLAB
> 5:Toolbox:PsychToolbox_2.53:PsychOneLiners:NearestResolution.m
> On line 68 ==> d(i)=distance(wish,res(i));

Has anybody else seen this or similar behavior?
Best, Jochen


====================================================
Here is some background info
====================================================

Debugging shows that the call to screen('Resolutions') in line 62
> res=Screen(screenNumber,'Resolutions'); % get a list of available
> resolutions
sometimes returns empty width and height fields. On my system, if it
happened, then it affected the last record, res(48).

mode: 10
name: '1280 x 1024, 76 Hz'
width: []
height: []
hz: 76
pixelSizes: [8 16 32]
depths: [1x3 struct]
resolutionDependsOnDepthMode: 1
valid: 0
safe: 0
recommended: 0
recommendNow: 0
default: 0
interlaced: 0

By coincidence (?), 1280x1024 is the only resolution with
displayModes.depthBlockCount==6 [all other resolutions have
depthBlockCount<=3, as tested with a quick-and-dirty C program similar
to DisplayModesDemo()]. Furthermore, in the Monitor Control Panel, I
get "76 Hz" and "76.1 Hz" options for the 1280x1024 resolution.

I don't know whether the bug is in DisplayManager, Psychophysics
toolbox or VideoToolbox (GetDisplayModes.c). I currently use the
following workaround, checking for and replacing missing fields at the
top of function d=distance(a,b) in NearestResolution.m.

> %[...]
> function d=distance(a,b)
> % "a" may omit values, for which you "don't care".
> % "a" has "pixelSize" field, but "b" has "pixelSizes" field.
> % check for missing width or height fields, replace by values guessed
> from name string
> if isempty(b.width)
> b.width=str2num(b.name(1:4));
> end
> if isempty(b.height)
> xpos=findstr(b.name, 'x');
> b.height=str2num(b.name(xpos+1:xpos+5));
> end
> %[...]