Revision: 4608
http://skim-app.svn.sourceforge.net/skim-app/?rev=4608&view=rev
Author: hofman
Date: 2008-09-11 00:30:01 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
Wrap outline items in a custom class on Tiger to avoid them from getting
released under our nose, and to ensure the items in the outline are always the
same.
Modified Paths:
--------------
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKPDFOutline.h
trunk/SKPDFOutline.m
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2008-09-10 20:20:29 UTC (rev 4607)
+++ trunk/SKMainWindowController.h 2008-09-11 00:30:01 UTC (rev 4608)
@@ -123,8 +123,7 @@
IBOutlet SKTocOutlineView *outlineView;
IBOutlet NSView *tocView;
- PDFOutline *pdfOutline;
- NSMutableArray *pdfOutlineItems;
+ id pdfOutline;
BOOL updatingOutlineSelection;
IBOutlet NSObjectController *ownerController;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-09-10 20:20:29 UTC (rev 4607)
+++ trunk/SKMainWindowController.m 2008-09-11 00:30:01 UTC (rev 4608)
@@ -97,6 +97,7 @@
#import "SKUnarchiveFromDataArrayTransformer.h"
#import "RemoteControl.h"
#import "NSView_SKExtensions.h"
+#import "SKPDFOutline.h"
#define MULTIPLICATION_SIGN_CHARACTER 0x00d7
@@ -241,8 +242,6 @@
dirtySnapshots = [[NSMutableArray alloc] init];
pageLabels = [[NSMutableArray alloc] init];
lastViewedPages = [[NSMutableArray alloc] init];
- // @@ remove or set to nil for Leopard?
- pdfOutlineItems = [[NSMutableArray alloc] init];
rowHeights = CFDictionaryCreateMutable(NULL, 0,
&kSKPointerEqualObjectDictionaryKeyCallBacks,
&kSKFloatDictionaryValueCallBacks);
savedNormalSetup = [[NSMutableDictionary alloc] init];
leftSidePaneState = SKThumbnailSidePaneState;
@@ -288,7 +287,6 @@
[mainWindow release];
[statusBar release];
[toolbarItems release];
- [pdfOutlineItems release];
[savedNormalSetup release];
[progressController release];
[colorAccessoryView release];
@@ -672,14 +670,14 @@
// update the outline
[pdfOutline release];
- pdfOutline = [[pdfDoc outlineRoot] retain];
- [pdfOutlineItems removeAllObjects];
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4)
+ pdfOutline = [[pdfDoc outlineRoot] retain];
+ else
+ pdfOutline = [[SKPDFOutline alloc] initWithOutline:[pdfDoc
outlineRoot] parent:nil];
updatingOutlineSelection = YES;
// If this is a reload following a TeX run and the user just killed the
outline for some reason, we get a crash if the outlineView isn't reloaded, so
no longer make it conditional on pdfOutline != nil
[outlineView reloadData];
- if ([outlineView numberOfRows] == 1)
- [outlineView expandItem: [outlineView itemAtRow: 0] expandChildren:
NO];
updatingOutlineSelection = NO;
[self updateOutlineSelection];
@@ -738,7 +736,6 @@
[pdfOutline release];
pdfOutline = nil;
- [pdfOutlineItems removeAllObjects];
[lastViewedPages removeAllObjects];
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2008-09-10 20:20:29 UTC (rev 4607)
+++ trunk/SKMainWindowController_UI.m 2008-09-11 00:30:01 UTC (rev 4608)
@@ -530,10 +530,7 @@
if ([ov isEqual:outlineView]) {
if (item == nil && [[pdfView document] isLocked] == NO)
item = pdfOutline;
- PDFOutline *obj = [(PDFOutline *)item childAtIndex:anIndex];
- // Apple's sample code retains this object before returning it, which
prevents a crash, but also causes a leak. We could rewrite PDFOutline, but
it's easier just to collect these objects and release them in -dealloc.
- if (obj)
- [pdfOutlineItems addObject:obj];
+ id obj = [(PDFOutline *)item childAtIndex:anIndex];
return obj;
} else if ([ov isEqual:noteOutlineView]) {
if (item == nil)
@@ -640,13 +637,13 @@
- (void)outlineViewSelectionDidChange:(NSNotification *)notification{
// Get the destination associated with the search result list. Tell the
PDFView to go there.
if ([[notification object] isEqual:outlineView] &&
(updatingOutlineSelection == NO)){
- PDFOutline *outlineItem = [outlineView itemAtRow: [outlineView
selectedRow]];
- PDFDestination *dest = [outlineItem destination];
+ id outlineItem = [outlineView itemAtRow: [outlineView selectedRow]];
+ PDFDestination *dest = [(PDFOutline *)outlineItem destination];
updatingOutlineSelection = YES;
if (dest)
[self goToDestination:dest];
- else if ([outlineItem respondsToSelector:@selector(action)] &&
[outlineItem action])
- [pdfView performAction:[outlineItem action]];
+ else if ([outlineItem respondsToSelector:@selector(action)] &&
[(PDFOutline *)outlineItem action])
+ [pdfView performAction:[(PDFOutline *)outlineItem action]];
updatingOutlineSelection = NO;
if ([self isPresentation] && [[NSUserDefaults standardUserDefaults]
boolForKey:SKAutoHidePresentationContentsKey])
[self hideLeftSideWindow];
Added: trunk/SKPDFOutline.h
===================================================================
--- trunk/SKPDFOutline.h (rev 0)
+++ trunk/SKPDFOutline.h 2008-09-11 00:30:01 UTC (rev 4608)
@@ -0,0 +1,64 @@
+//
+// SKPDFOutline.h
+// Skim
+//
+// Created by Christiaan Hofman on 9/11/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <Quartz/Quartz.h>
+
+
[EMAIL PROTECTED] SKPDFOutline : NSObject {
+ PDFOutline *outline;
+ SKPDFOutline *parent;
+ NSMutableArray *children;
+}
+
+- (id)initWithOutline:(PDFOutline *)anOutline parent:(SKPDFOutline *)aParent;
+
+- (PDFDocument *)document;
+
+- (SKPDFOutline *)parent;
+
+- (unsigned int)numberOfChildren;
+- (SKPDFOutline *)childAtIndex:(unsigned int)anIndex;
+
+- (PDFDestination *)destination;
+
+- (NSString *)label;
+
+- (BOOL)isOpen;
+
[EMAIL PROTECTED]
Added: trunk/SKPDFOutline.m
===================================================================
--- trunk/SKPDFOutline.m (rev 0)
+++ trunk/SKPDFOutline.m 2008-09-11 00:30:01 UTC (rev 4608)
@@ -0,0 +1,106 @@
+//
+// SKPDFOutline.m
+// Skim
+//
+// Created by Christiaan Hofman on 11/9/08.
+// Created by Christiaan Hofman on 9/11/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "SKPDFOutline.h"
+
+
[EMAIL PROTECTED] SKPDFOutline
+
+
+- (id)initWithOutline:(PDFOutline *)anOutline parent:(SKPDFOutline *)aParent {
+ if (self = [super init]) {
+ if (outline) {
+ outline = [anOutline retain];
+ parent = aParent;
+ children = [[NSMutableArray alloc] init];
+ } else {
+ [self release];
+ self = nil;
+ }
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [outline release];
+ [children release];
+ [super dealloc];
+}
+
+- (PDFDocument *)document {
+ return [outline document];
+}
+
+- (SKPDFOutline *)parent {
+ return parent;
+}
+
+- (unsigned int)numberOfChildren {
+ return [outline numberOfChildren];
+}
+
+- (SKPDFOutline *)childAtIndex:(unsigned int)anIndex {
+ if (children == nil) {
+ int i, count = [outline numberOfChildren];
+ children = [[NSMutableArray alloc] initWithCapacity:count];
+ for (i = 0; i < count; i++) {
+ SKPDFOutline *child = [[SKPDFOutline alloc]
initWithOutline:[outline childAtIndex:i] parent:self];
+ [children addObject:child];
+ [child release];
+ }
+ }
+ return [children objectAtIndex:anIndex];
+}
+
+- (PDFDestination *)destination {
+ return [outline destination];
+}
+
+- (NSString *)label {
+ return [outline label];
+}
+
+- (BOOL)isOpen {
+ if ([outline respondsToSelector:_cmd])
+ return [outline isOpen];
+ else
+ return [parent parent] == nil && [parent numberOfChildren] == 1;
+}
+
[EMAIL PROTECTED]
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-09-10 20:20:29 UTC (rev
4607)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-09-11 00:30:01 UTC (rev
4608)
@@ -60,6 +60,7 @@
CE2093910C5F9A8D009D3EFB /* BDSKGradientView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE20938F0C5F9A8D009D3EFB /* BDSKGradientView.m
*/; };
CE209FAA0C9D38C6007C72F9 /* SKProgressController.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CE209FA80C9D38C6007C72F9 /*
SKProgressController.m */; };
CE20B1950C9F23CC007C72F9 /* NSView_SKExtensions.m in Sources */
= {isa = PBXBuildFile; fileRef = CE20B1930C9F23CC007C72F9 /*
NSView_SKExtensions.m */; };
+ CE2896DA0E78948200031EEA /* SKPDFOutline.m in Sources */ = {isa
= PBXBuildFile; fileRef = CE2896D90E78948200031EEA /* SKPDFOutline.m */; };
CE2A1E630CE513E400A0499B /* RemoteControl.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE2A1E610CE513E300A0499B /* RemoteControl.m */;
};
CE2DE4920B85D48F00D0DA12 /* SKThumbnail.m in Sources */ = {isa
= PBXBuildFile; fileRef = CE2DE4910B85D48F00D0DA12 /* SKThumbnail.m */; };
CE2DE49D0B85D4F400D0DA12 /* SKFullScreenWindow.m in Sources */
= {isa = PBXBuildFile; fileRef = CE2DE49C0B85D4F400D0DA12 /*
SKFullScreenWindow.m */; };
@@ -468,6 +469,8 @@
CE209FA80C9D38C6007C72F9 /* SKProgressController.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKProgressController.m; sourceTree = "<group>"; };
CE20B1920C9F23CC007C72F9 /* NSView_SKExtensions.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
NSView_SKExtensions.h; sourceTree = "<group>"; };
CE20B1930C9F23CC007C72F9 /* NSView_SKExtensions.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= NSView_SKExtensions.m; sourceTree = "<group>"; };
+ CE2896D80E78948200031EEA /* SKPDFOutline.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKPDFOutline.h; sourceTree = "<group>"; };
+ CE2896D90E78948200031EEA /* SKPDFOutline.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKPDFOutline.m; sourceTree = "<group>"; };
CE2A11660CE3B51600A0499B /* archivedmg.sh */ = {isa =
PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.sh; path =
archivedmg.sh; sourceTree = "<group>"; };
CE2A1E600CE513E300A0499B /* RemoteControl.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
RemoteControl.h; sourceTree = "<group>"; };
CE2A1E610CE513E300A0499B /* RemoteControl.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= RemoteControl.m; sourceTree = "<group>"; };
@@ -1330,6 +1333,8 @@
CEE54DF00DA2EF0E0037169F /*
SKPDFAnnotationTemporary.m */,
CE3366DD0E28BCFA005F99E6 /* SKPDFSyncRecord.h
*/,
CE3366DE0E28BCFA005F99E6 /* SKPDFSyncRecord.m
*/,
+ CE2896D80E78948200031EEA /* SKPDFOutline.h */,
+ CE2896D90E78948200031EEA /* SKPDFOutline.m */,
);
name = Data;
sourceTree = "<group>";
@@ -2095,6 +2100,7 @@
CE3366DF0E28BCFA005F99E6 /* SKPDFSyncRecord.m
in Sources */,
CE09FC3C0E3886C100BDF413 /* SKRuntime.m in
Sources */,
CEA450F40E47A87500D161AD /*
NSLayoutManager_SKExtensions.m in Sources */,
+ CE2896DA0E78948200031EEA /* SKPDFOutline.m in
Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit