Revision: 3364
http://skim-app.svn.sourceforge.net/skim-app/?rev=3364&view=rev
Author: hofman
Date: 2008-01-10 05:48:18 -0800 (Thu, 10 Jan 2008)
Log Message:
-----------
Use Carbon functions for array of integers. Don't add hover rects when there is
no document or no window. This avoids exception when loading a document.
Modified Paths:
--------------
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2008-01-10 13:06:31 UTC (rev 3363)
+++ trunk/SKPDFView.h 2008-01-10 13:48:18 UTC (rev 3364)
@@ -113,7 +113,7 @@
int dragMask;
int trackingRect;
- NSMutableArray *hoverRects;
+ CFMutableArrayRef hoverRects;
int hoverRect;
int spellingTag;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-01-10 13:06:31 UTC (rev 3363)
+++ trunk/SKPDFView.m 2008-01-10 13:48:18 UTC (rev 3364)
@@ -251,7 +251,8 @@
[self doAutohide:NO]; // invalidates and releases the timer
[[SKPDFHoverWindow sharedHoverWindow] orderOut:self];
[self removeHoverRects];
- [hoverRects release];
+ if (hoverRects)
+ CFRelease(hoverRects);
[typeSelectHelper setDataSource:nil];
[typeSelectHelper release];
[transitionController release];
@@ -273,34 +274,35 @@
- (void)scheduleAddingToolips {}
- (void)removeHoverRects {
- CFIndex idx = [hoverRects count];
- while (idx--) {
- [self removeTrackingRect:(NSTrackingRectTag)[hoverRects
objectAtIndex:idx]];
- [hoverRects removeObjectAtIndex:idx];
- }
+ CFIndex idx = CFArrayGetCount(hoverRects);
+ while (idx--)
+ [self
removeTrackingRect:(NSTrackingRectTag)CFArrayGetValueAtIndex(hoverRects, idx)];
+ CFArrayRemoveAllValues(hoverRects);
}
- (void)resetHoverRects {
if (hoverRects == nil)
- hoverRects = (NSMutableArray *)CFArrayCreateMutable(NULL, 0, NULL);
+ hoverRects = CFArrayCreateMutable(NULL, 0, NULL);
else
[self removeHoverRects];
- NSRange range = [self visiblePageIndexRange];
- unsigned i, iMax = NSMaxRange(range);
- NSRect visibleRect = [self visibleContentRect];
-
- for (i = range.location; i < iMax; i++) {
- PDFPage *page = [[self document] pageAtIndex:i];
- NSArray *annotations = [page annotations];
- unsigned j, jMax = [annotations count];
- for (j = 0; j < jMax; j++) {
- PDFAnnotation *annotation = [annotations objectAtIndex:j];
- if ([[annotation type] isEqualToString:SKNoteString] ||
[[annotation type] isEqualToString:SKLinkString]) {
- NSRect rect = NSIntersectionRect([self convertRect:[annotation
bounds] fromPage:page], visibleRect);
- if (NSIsEmptyRect(rect) == NO) {
- NSTrackingRectTag tag = [self addTrackingRect:rect
owner:self userData:annotation assumeInside:NO];
- [hoverRects addObject:(id)tag];
+ if ([self document] && [self window]) {
+ NSRange range = [self visiblePageIndexRange];
+ unsigned i, iMax = NSMaxRange(range);
+ NSRect visibleRect = [self visibleContentRect];
+
+ for (i = range.location; i < iMax; i++) {
+ PDFPage *page = [[self document] pageAtIndex:i];
+ NSArray *annotations = [page annotations];
+ unsigned j, jMax = [annotations count];
+ for (j = 0; j < jMax; j++) {
+ PDFAnnotation *annotation = [annotations objectAtIndex:j];
+ if ([[annotation type] isEqualToString:SKNoteString] ||
[[annotation type] isEqualToString:SKLinkString]) {
+ NSRect rect = NSIntersectionRect([self
convertRect:[annotation bounds] fromPage:page], visibleRect);
+ if (NSIsEmptyRect(rect) == NO) {
+ NSTrackingRectTag tag = [self addTrackingRect:rect
owner:self userData:annotation assumeInside:NO];
+ CFArrayAppendValue(hoverRects, (void *)tag);
+ }
}
}
}
@@ -1371,7 +1373,7 @@
[super mouseEntered:theEvent];
if (trackingNumber == trackingRect) {
[[self window] setAcceptsMouseMovedEvents:YES];
- } else if (NSNotFound != [hoverRects indexOfObject:(id)trackingNumber]) {
+ } else if (NSNotFound != CFArrayGetFirstIndexOfValue(hoverRects,
CFRangeMake(0, CFArrayGetCount(hoverRects)), (void *)trackingNumber)) {
[[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:(id)[theEvent
userData] atPoint:NSZeroPoint];
hoverRect = trackingNumber;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit