Revision: 29142 http://sourceforge.net/p/bibdesk/svn/29142 Author: hofman Date: 2025-04-19 21:21:14 +0000 (Sat, 19 Apr 2025) Log Message: ----------- Simply calculate row and column for index
Modified Paths: -------------- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2025-04-19 16:32:39 UTC (rev 29141) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2025-04-19 21:21:14 UTC (rev 29142) @@ -1426,28 +1426,19 @@ - (BOOL)_getGridRow:(NSUInteger *)rowIndex column:(NSUInteger *)colIndex ofIndex:(NSUInteger)anIndex; { + if (anIndex >= [self numberOfIcons]) + return NO; + NSUInteger cMax = [self numberOfColumns], rMax = [self numberOfRows]; if (0 == cMax || 0 == rMax) return NO; - + // initialize all of these, in case we don't make it to the inner loop - NSUInteger r, c = 0, i = 0; + NSUInteger r = anIndex / cMax; + NSUInteger c = anIndex - r * cMax; - // iterate columns within each row - for (r = 0; r < rMax && i <= anIndex; r++) - { - for (c = 0; c < cMax && i <= anIndex; c++) - { - i++; - } - } - - // grid row/index are zero based - r--; - c--; - - if (i <= [self numberOfIcons]) { + if (r < rMax) { if (NULL != rowIndex) *rowIndex = r; if (NULL != colIndex) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit