@@ -235,6 +235,11 @@ - (FICImageTableChunk *)_chunkAtIndex:(NSInteger)index {
235235 }
236236 }
237237
238+ if (!chunk) {
239+ NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s failed to get chunk for index %d ." , __PRETTY_FUNCTION__, index];
240+ [[FICImageCache sharedImageCache ] _logMessage: message];
241+ }
242+
238243 return chunk;
239244}
240245
@@ -262,30 +267,32 @@ - (void)setEntryForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *
262267
263268 // Create context whose backing store *is* the mapped file data
264269 FICImageTableEntry *entryData = [self _entryDataAtIndex: newEntryIndex];
265- CGContextRef context = CGBitmapContextCreate ([entryData bytes ], pixelSize.width , pixelSize.height , bitsPerComponent, _imageRowLength, colorSpace, bitmapInfo);
266- CGColorSpaceRelease (colorSpace);
267-
268- CGContextTranslateCTM (context, 0 , pixelSize.height );
269- CGContextScaleCTM (context, _screenScale, -_screenScale);
270-
271- // Call drawing block to allow client to draw into the context
272- imageDrawingBlock (context, [_imageFormat imageSize ]);
273- CGContextRelease (context);
274-
275- [entryData setEntityUUIDBytes: FICUUIDBytesWithString (entityUUID)];
276- [entryData setSourceImageUUIDBytes: FICUUIDBytesWithString (sourceImageUUID)];
277-
278- // Update our book-keeping
279- [_indexMap setObject: [NSNumber numberWithUnsignedInteger: newEntryIndex] forKey: entityUUID];
280- [_occupiedIndexes addIndex: newEntryIndex];
281- [_sourceImageMap setObject: sourceImageUUID forKey: entityUUID];
282-
283- // Update MRU array
284- [self _entryWasAccessedWithEntityUUID: entityUUID];
285- [self saveMetadata ];
286-
287- // Write the data back to the filesystem
288- [entryData flush ];
270+ if (entryData) {
271+ CGContextRef context = CGBitmapContextCreate ([entryData bytes ], pixelSize.width , pixelSize.height , bitsPerComponent, _imageRowLength, colorSpace, bitmapInfo);
272+ CGColorSpaceRelease (colorSpace);
273+
274+ CGContextTranslateCTM (context, 0 , pixelSize.height );
275+ CGContextScaleCTM (context, _screenScale, -_screenScale);
276+
277+ // Call drawing block to allow client to draw into the context
278+ imageDrawingBlock (context, [_imageFormat imageSize ]);
279+ CGContextRelease (context);
280+
281+ [entryData setEntityUUIDBytes: FICUUIDBytesWithString (entityUUID)];
282+ [entryData setSourceImageUUIDBytes: FICUUIDBytesWithString (sourceImageUUID)];
283+
284+ // Update our book-keeping
285+ [_indexMap setObject: [NSNumber numberWithUnsignedInteger: newEntryIndex] forKey: entityUUID];
286+ [_occupiedIndexes addIndex: newEntryIndex];
287+ [_sourceImageMap setObject: sourceImageUUID forKey: entityUUID];
288+
289+ // Update MRU array
290+ [self _entryWasAccessedWithEntityUUID: entityUUID];
291+ [self saveMetadata ];
292+
293+ // Write the data back to the filesystem
294+ [entryData flush ];
295+ }
289296 }
290297
291298 [_lock unlock ];
@@ -458,6 +465,11 @@ - (FICImageTableEntry *)_entryDataAtIndex:(NSInteger)index {
458465
459466 [_lock unlock ];
460467
468+ if (!entryData) {
469+ NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s failed to get entry for index %d ." , __PRETTY_FUNCTION__, index];
470+ [[FICImageCache sharedImageCache ] _logMessage: message];
471+ }
472+
461473 return entryData;
462474}
463475
0 commit comments