From 5532f8878b7219720de6145eabbe57efb894957c Mon Sep 17 00:00:00 2001 From: Johan Paulsson Date: Sun, 23 Mar 2014 02:48:06 +0000 Subject: Converting from GC to ARC This should only be for the osx specific code as all common files are left out. Hopefully this shouldn't introduce any problems on the other systems. --- tikzit/src/osx/AppDelegate.h | 4 +- tikzit/src/osx/CustomNodeCellView.h | 2 +- tikzit/src/osx/CustomNodeController.h | 16 +- tikzit/src/osx/CustomNodes.xib | 242 ++++++++++++++++++++++++++- tikzit/src/osx/EdgeControlLayer.m | 2 +- tikzit/src/osx/EdgeStyle+Coder.m | 2 +- tikzit/src/osx/GraphicsView.h | 6 +- tikzit/src/osx/Grid.m | 2 +- tikzit/src/osx/NilToEmptyStringTransformer.m | 2 +- tikzit/src/osx/NodeLayer.h | 6 +- tikzit/src/osx/NodeLayer.m | 3 +- tikzit/src/osx/NodeSelectionLayer.h | 4 +- tikzit/src/osx/NodeSelectionLayer.m | 2 +- tikzit/src/osx/NodeStyle+Coder.m | 2 +- tikzit/src/osx/PreambleController.h | 4 +- tikzit/src/osx/PreambleController.m | 2 +- tikzit/src/osx/Preambles+Coder.m | 2 +- tikzit/src/osx/PreferenceController.h | 5 + tikzit/src/osx/PreferenceController.m | 12 +- tikzit/src/osx/Preferences.xib | 74 +++++++- tikzit/src/osx/PreviewController.m | 2 +- tikzit/src/osx/PropertyInspectorController.h | 10 +- tikzit/src/osx/PropertyInspectorController.m | 2 +- tikzit/src/osx/SelectBoxLayer.m | 4 +- tikzit/src/osx/SelectableNodeView.h | 2 +- tikzit/src/osx/SelectableNodeView.m | 2 +- tikzit/src/osx/StylePaletteController.h | 16 +- tikzit/src/osx/TikzDocument.h | 2 +- tikzit/src/osx/TikzFormatter.m | 4 - tikzit/src/osx/TikzSourceController.h | 24 +-- tikzit/src/osx/TikzSourceController.m | 9 +- tikzit/src/osx/TikzWindowController.h | 8 +- tikzit/src/osx/TikzWindowController.m | 2 +- tikzit/src/osx/ToolPaletteController.h | 8 +- 34 files changed, 402 insertions(+), 87 deletions(-) (limited to 'tikzit/src/osx') diff --git a/tikzit/src/osx/AppDelegate.h b/tikzit/src/osx/AppDelegate.h index 64acc38..0f9d787 100644 --- a/tikzit/src/osx/AppDelegate.h +++ b/tikzit/src/osx/AppDelegate.h @@ -37,13 +37,13 @@ PreambleController *preambleController; PreviewController *previewController; PreferenceController *preferenceController; - ToolPaletteController *toolPaletteController; + ToolPaletteController *__weak toolPaletteController; IBOutlet GraphicsView *graphicsView; NSString *tempDir; } @property IBOutlet StylePaletteController *stylePaletteController; -@property IBOutlet ToolPaletteController *toolPaletteController; +@property (weak) IBOutlet ToolPaletteController *toolPaletteController; - (void)awakeFromNib; + (void)setDefaults; diff --git a/tikzit/src/osx/CustomNodeCellView.h b/tikzit/src/osx/CustomNodeCellView.h index 5b3b1ee..22606d7 100644 --- a/tikzit/src/osx/CustomNodeCellView.h +++ b/tikzit/src/osx/CustomNodeCellView.h @@ -18,6 +18,6 @@ BOOL selected; } -@property (retain) id objectValue; +@property (strong) id objectValue; @end diff --git a/tikzit/src/osx/CustomNodeController.h b/tikzit/src/osx/CustomNodeController.h index 55f0e0b..56cb74c 100644 --- a/tikzit/src/osx/CustomNodeController.h +++ b/tikzit/src/osx/CustomNodeController.h @@ -16,18 +16,18 @@ #import "SupportDir.h" @interface CustomNodeController : NSViewController { - NSDictionary* nodeStyles; + NSDictionary* __weak nodeStyles; NSMutableArray* customNodeStyles; - NSMutableArray* onodeStyles; + NSMutableArray* __weak onodeStyles; - GraphicsView *graphicsView; - TikzSourceController *tikzSourceController; + GraphicsView *__weak graphicsView; + TikzSourceController *__weak tikzSourceController; } -@property (readonly) NSDictionary *nodeStyles; -@property (readonly) NSMutableArray* onodeStyles; +@property (weak, readonly) NSDictionary *nodeStyles; +@property (weak, readonly) NSMutableArray* onodeStyles; -@property IBOutlet GraphicsView *graphicsView; -@property IBOutlet TikzSourceController *tikzSourceController; +@property (weak) IBOutlet GraphicsView *graphicsView; +@property (weak) IBOutlet TikzSourceController *tikzSourceController; @end diff --git a/tikzit/src/osx/CustomNodes.xib b/tikzit/src/osx/CustomNodes.xib index 8b2587a..1cc8db2 100644 --- a/tikzit/src/osx/CustomNodes.xib +++ b/tikzit/src/osx/CustomNodes.xib @@ -1,15 +1,249 @@ - + - + + - + + + + + + + + + + name + strokeThickness + strokeColor + fillColor + strokeColorIsKnown + fillColorIsKnown + representedObject.name + shapeName + scale + @distinctUnionOfObjects.category + category + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \begin{tikzpicture} + +\end{tikzpicture} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + + + + diff --git a/tikzit/src/osx/EdgeControlLayer.m b/tikzit/src/osx/EdgeControlLayer.m index 377cde4..facdd84 100644 --- a/tikzit/src/osx/EdgeControlLayer.m +++ b/tikzit/src/osx/EdgeControlLayer.m @@ -29,7 +29,7 @@ - (id)initWithEdge:(Edge*)e andTransformer:(Transformer*)t { - [super init]; + if (!(self = [super init])) return nil; transformer = t; edge = e; self.opacity = 0.0f; diff --git a/tikzit/src/osx/EdgeStyle+Coder.m b/tikzit/src/osx/EdgeStyle+Coder.m index 208fac0..039344d 100644 --- a/tikzit/src/osx/EdgeStyle+Coder.m +++ b/tikzit/src/osx/EdgeStyle+Coder.m @@ -26,7 +26,7 @@ @implementation EdgeStyle (Coder) - (id)initWithCoder:(NSCoder*)coder { - [super init]; + if (!(self = [super init])) return nil; name = [coder decodeObjectForKey:@"name"]; category = [coder decodeObjectForKey:@"category"]; diff --git a/tikzit/src/osx/GraphicsView.h b/tikzit/src/osx/GraphicsView.h index e963ac7..c3c2add 100644 --- a/tikzit/src/osx/GraphicsView.h +++ b/tikzit/src/osx/GraphicsView.h @@ -92,12 +92,12 @@ typedef enum { NSUndoManager *documentUndoManager; NSPoint startPoint; - TikzSourceController *tikzSourceController; + TikzSourceController *__weak tikzSourceController; } @property BOOL enabled; -@property Graph *graph; -@property IBOutlet TikzSourceController *tikzSourceController; +@property (weak) Graph *graph; +@property (weak) IBOutlet TikzSourceController *tikzSourceController; @property (readonly) Transformer *transformer; @property (readonly) PickSupport *pickSupport; diff --git a/tikzit/src/osx/Grid.m b/tikzit/src/osx/Grid.m index 3e412a3..aa35c1f 100644 --- a/tikzit/src/osx/Grid.m +++ b/tikzit/src/osx/Grid.m @@ -32,7 +32,7 @@ subdivisions:(int)subs transformer:(Transformer*)t { - [super init]; + if (!(self = [super init])) return nil; gridX = spacing; gridY = spacing; subdivisions = subs; diff --git a/tikzit/src/osx/NilToEmptyStringTransformer.m b/tikzit/src/osx/NilToEmptyStringTransformer.m index 97267e3..413f404 100644 --- a/tikzit/src/osx/NilToEmptyStringTransformer.m +++ b/tikzit/src/osx/NilToEmptyStringTransformer.m @@ -26,7 +26,7 @@ @implementation NilToEmptyStringTransformer - (id)init { - [super init]; + if (!(self = [super init])) return nil; return self; } diff --git a/tikzit/src/osx/NodeLayer.h b/tikzit/src/osx/NodeLayer.h index dfe05e8..d2a943b 100644 --- a/tikzit/src/osx/NodeLayer.h +++ b/tikzit/src/osx/NodeLayer.h @@ -30,7 +30,7 @@ #import "NodeSelectionLayer.h" @interface NodeLayer : CALayer { - Node *node; + Node *__weak node; Shape *shape; CGMutablePathRef path; float textwidth; @@ -42,10 +42,10 @@ BOOL dirty; // need to rebuild CGBezierPath of the shape } -@property Node *node; +@property (weak) Node *node; @property (assign) NSPoint center; @property (assign) BOOL rescale; -@property (retain) NodeSelectionLayer *selection; +@property (strong) NodeSelectionLayer *selection; @property (readonly) CGMutablePathRef path; - (id)initWithNode:(Node*)n transformer:(Transformer*)t; diff --git a/tikzit/src/osx/NodeLayer.m b/tikzit/src/osx/NodeLayer.m index 2c37c26..5d15585 100644 --- a/tikzit/src/osx/NodeLayer.m +++ b/tikzit/src/osx/NodeLayer.m @@ -34,7 +34,7 @@ @synthesize node, selection, rescale; - (id)initWithNode:(Node *)n transformer:(Transformer*)t { - [super init]; + if (!(self = [super init])) return nil; node = n; selection = [[NodeSelectionLayer alloc] init]; [selection setNodeLayer:self]; @@ -233,7 +233,6 @@ - (void)dealloc { if (path != NULL) CFRelease(path); - [super dealloc]; } @end diff --git a/tikzit/src/osx/NodeSelectionLayer.h b/tikzit/src/osx/NodeSelectionLayer.h index 99ee75f..68d5beb 100644 --- a/tikzit/src/osx/NodeSelectionLayer.h +++ b/tikzit/src/osx/NodeSelectionLayer.h @@ -31,10 +31,10 @@ BOOL selected; CGMutablePathRef path; NSLock *drawLock; - NodeLayer *nodeLayer; + NodeLayer *__weak nodeLayer; } -@property NodeLayer *nodeLayer; +@property (weak) NodeLayer *nodeLayer; - (id)init; - (void)select; diff --git a/tikzit/src/osx/NodeSelectionLayer.m b/tikzit/src/osx/NodeSelectionLayer.m index 5efcbf7..02b8ac2 100644 --- a/tikzit/src/osx/NodeSelectionLayer.m +++ b/tikzit/src/osx/NodeSelectionLayer.m @@ -30,7 +30,7 @@ @synthesize nodeLayer; - (id)init { - [super init]; + if (!(self = [super init])) return nil; selected = NO; drawLock = [[NSLock alloc] init]; nodeLayer = nil; diff --git a/tikzit/src/osx/NodeStyle+Coder.m b/tikzit/src/osx/NodeStyle+Coder.m index 8da91c1..d3623f5 100644 --- a/tikzit/src/osx/NodeStyle+Coder.m +++ b/tikzit/src/osx/NodeStyle+Coder.m @@ -59,7 +59,7 @@ } - (id)initWithCoder:(NSCoder *)coder { - [super init]; + if (!(self = [super init])) return nil; // decode keys name = [coder decodeObjectForKey:@"name"]; diff --git a/tikzit/src/osx/PreambleController.h b/tikzit/src/osx/PreambleController.h index 3c7a7c3..5b0931d 100644 --- a/tikzit/src/osx/PreambleController.h +++ b/tikzit/src/osx/PreambleController.h @@ -38,8 +38,8 @@ @property (readonly) BOOL useDefaultPreamble; @property (readonly) Preambles *preambles; -@property (retain) NSAttributedString *preambleText; -@property (retain) NSIndexSet *selectionIndexes; +@property (strong) NSAttributedString *preambleText; +@property (strong) NSIndexSet *selectionIndexes; - (id)initWithNibName:(NSString *)nibName plist:(NSString*)plist styles:(NSArray*)sty edges:(NSArray*)edg; - (void)savePreambles:(NSString*)plist; diff --git a/tikzit/src/osx/PreambleController.m b/tikzit/src/osx/PreambleController.m index 3e55eaf..206bb30 100644 --- a/tikzit/src/osx/PreambleController.m +++ b/tikzit/src/osx/PreambleController.m @@ -29,7 +29,7 @@ @synthesize preambleText, preambles; - (id)initWithNibName:(NSString *)nibName plist:(NSString*)plist styles:(NSArray*)sty edges:(NSArray*)edg { - [super initWithNibName:nibName bundle:Nil]; + if (!(self = [super initWithNibName:nibName bundle:Nil])) return nil; preambles = (Preambles*)[NSKeyedUnarchiver unarchiveObjectWithFile:plist]; [preambles setStyles:sty]; diff --git a/tikzit/src/osx/Preambles+Coder.m b/tikzit/src/osx/Preambles+Coder.m index 6b9768a..5e468b2 100644 --- a/tikzit/src/osx/Preambles+Coder.m +++ b/tikzit/src/osx/Preambles+Coder.m @@ -27,7 +27,7 @@ @implementation Preambles (Coder) - (id)initWithCoder:(NSCoder *)coder { - [super init]; + if (!(self = [super init])) return nil; selectedPreambleName = [coder decodeObjectForKey:@"selectedPreamble"]; preambleDict = [coder decodeObjectForKey:@"preambles"]; return self; diff --git a/tikzit/src/osx/PreferenceController.h b/tikzit/src/osx/PreferenceController.h index 5a14b72..b2b23f3 100644 --- a/tikzit/src/osx/PreferenceController.h +++ b/tikzit/src/osx/PreferenceController.h @@ -25,6 +25,7 @@ #import #import "UpdatePreferenceController.h" #import "PreambleController.h" +#import "CustomNodeController.h" @interface PreferenceController : NSWindowController{ @@ -32,13 +33,17 @@ IBOutlet NSView *generalView; IBOutlet NSView *updateView; IBOutlet NSView *preambleView; + IBOutlet NSView *customNodeView; UpdatePreferenceController *updateController; PreambleController *preambleController; + CustomNodeController *customNodeController; int currentViewTag; } +- (id)initWithWindowNibName:(NSString *)windowNibName preambleController:(PreambleController *)pc; + - (IBAction)switchView:(id)sender; @end diff --git a/tikzit/src/osx/PreferenceController.m b/tikzit/src/osx/PreferenceController.m index ab992ed..099bf48 100644 --- a/tikzit/src/osx/PreferenceController.m +++ b/tikzit/src/osx/PreferenceController.m @@ -30,8 +30,8 @@ @implementation PreferenceController -- (id)initWithWindowNibName:(NSString *)windowNibName preambleController:(PreambleController*)pc{ - [super initWithWindowNibName:windowNibName]; +- (id)initWithWindowNibName:(NSString *)windowNibName preambleController:(PreambleController *)pc{ + if (!(self = [super initWithWindowNibName:windowNibName])) return nil; preambleController = pc; @@ -69,6 +69,9 @@ case 3: view = preambleView; break; + case 4: + view = customNodeView; + break; } return view; @@ -96,6 +99,11 @@ [[[self window] contentView] replaceSubview:preambleView with:[preambleController view]]; preambleView = [preambleController view]; + customNodeController = [[CustomNodeController alloc] initWithNibName:@"CustomNodes" bundle:nil]; + [[customNodeController view] setFrame:[customNodeView frame]]; + [[[self window] contentView] replaceSubview:customNodeView with:[customNodeController view]]; + customNodeView = [customNodeController view]; + [[self window] setContentSize:[preambleView frame].size]; [[[self window] contentView] addSubview:preambleView]; currentViewTag = 3; diff --git a/tikzit/src/osx/Preferences.xib b/tikzit/src/osx/Preferences.xib index 8247c8d..155cf71 100644 --- a/tikzit/src/osx/Preferences.xib +++ b/tikzit/src/osx/Preferences.xib @@ -126,6 +126,28 @@ YES 0 + + + CBA2626C-DD4C-4ADD-BD5D-26D21216D9A8 + + Custom Nodes + Custom Nodes + + + + NSImage + customshape + + + + {0, 0} + {0, 0} + YES + YES + 4 + YES + 0 + F85FE7C2-9847-4E58-8BF6-BE334E918CA7 @@ -149,15 +171,17 @@ 0 - + + + @@ -329,6 +353,17 @@ _NS:9 NSView + + + 12 + + {557, 354} + + + + _NS:9 + NSView + YES @@ -407,6 +442,22 @@ 121 + + + customNodeView + + + + 123 + + + + switchView: + + + + 125 + delegate @@ -496,6 +547,7 @@ + @@ -744,6 +796,16 @@ + + 122 + + + + + 124 + + + @@ -758,6 +820,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -794,7 +858,7 @@ - 121 + 125 @@ -813,12 +877,17 @@ + NSView NSView NSView NSView NSView + + customNodeView + NSView + engineView NSView @@ -859,6 +928,7 @@ {32, 32} {15, 15} + {32, 32} {32, 32} {32, 32} {32, 32} diff --git a/tikzit/src/osx/PreviewController.m b/tikzit/src/osx/PreviewController.m index 310c2ab..cf069b1 100644 --- a/tikzit/src/osx/PreviewController.m +++ b/tikzit/src/osx/PreviewController.m @@ -33,7 +33,7 @@ static PreviewController *preview = nil; - (id)initWithWindowNibName:(NSString*)nib preambleController:(PreambleController*)pc tempDir:(NSString*)dir { - [super initWithWindowNibName:nib]; + if (!(self = [super initWithWindowNibName:nib])) return nil; tempDir = [dir copy]; typesetCount = 0; preambleController = pc; diff --git a/tikzit/src/osx/PropertyInspectorController.h b/tikzit/src/osx/PropertyInspectorController.h index 0625f9b..663ee4a 100644 --- a/tikzit/src/osx/PropertyInspectorController.h +++ b/tikzit/src/osx/PropertyInspectorController.h @@ -52,11 +52,11 @@ //@property (readonly) BOOL enableNodeDataControls; //@property (readonly) BOOL enableEdgeDataControls; -@property (retain) NSMutableArray *selectedNodes; -@property (retain) NSMutableArray *selectedEdges; -@property (retain) NSMutableArray *sourceAnchorNames; -@property (retain) NSMutableArray *targetAnchorNames; -@property (retain) StylePaletteController *stylePaletteController; +@property (strong) NSMutableArray *selectedNodes; +@property (strong) NSMutableArray *selectedEdges; +@property (strong) NSMutableArray *sourceAnchorNames; +@property (strong) NSMutableArray *targetAnchorNames; +@property (strong) StylePaletteController *stylePaletteController; - (id)initWithWindowNibName:(NSString *)windowNibName; - (void)graphSelectionChanged:(NSNotification*)notification; diff --git a/tikzit/src/osx/PropertyInspectorController.m b/tikzit/src/osx/PropertyInspectorController.m index 1411549..981f746 100644 --- a/tikzit/src/osx/PropertyInspectorController.m +++ b/tikzit/src/osx/PropertyInspectorController.m @@ -25,7 +25,7 @@ @synthesize sourceAnchorNames, targetAnchorNames; - (id)initWithWindowNibName:(NSString *)windowNibName { - [super initWithWindowNibName:windowNibName]; + if (!(self = [super initWithWindowNibName:windowNibName])) return nil; noSelection = [[GraphElementData alloc] init]; [noSelection setProperty:@"" forKey:@"No Selection"]; diff --git a/tikzit/src/osx/SelectBoxLayer.m b/tikzit/src/osx/SelectBoxLayer.m index c198ffa..a7abe33 100644 --- a/tikzit/src/osx/SelectBoxLayer.m +++ b/tikzit/src/osx/SelectBoxLayer.m @@ -14,7 +14,7 @@ @synthesize active; - (id)init { - [super init]; + if (!(self = [super init])) return nil; box = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); active = NO; return self; @@ -42,7 +42,7 @@ } + (SelectBoxLayer*)layer { - return [[[SelectBoxLayer alloc] init] autorelease]; + return [[SelectBoxLayer alloc] init]; } @end diff --git a/tikzit/src/osx/SelectableNodeView.h b/tikzit/src/osx/SelectableNodeView.h index be7d1a1..6b0841d 100644 --- a/tikzit/src/osx/SelectableNodeView.h +++ b/tikzit/src/osx/SelectableNodeView.h @@ -32,7 +32,7 @@ } @property (assign) BOOL selected; -@property (retain) NodeStyle *nodeStyle; +@property (strong) NodeStyle *nodeStyle; @end diff --git a/tikzit/src/osx/SelectableNodeView.m b/tikzit/src/osx/SelectableNodeView.m index 6fdd283..797a137 100644 --- a/tikzit/src/osx/SelectableNodeView.m +++ b/tikzit/src/osx/SelectableNodeView.m @@ -30,7 +30,7 @@ @synthesize selected; - (id)initWithFrame:(NSRect)frameRect { - [super initWithFrame:frameRect]; + if (!(self = [super initWithFrame:frameRect])) return nil; nodeLayer = nil; return self; } diff --git a/tikzit/src/osx/StylePaletteController.h b/tikzit/src/osx/StylePaletteController.h index ed30b58..51404bb 100644 --- a/tikzit/src/osx/StylePaletteController.h +++ b/tikzit/src/osx/StylePaletteController.h @@ -28,8 +28,8 @@ @class SFBInspectorView; @interface StylePaletteController : NSWindowController { - NSMutableArray *nodeStyles; - NSMutableArray *edgeStyles; + NSMutableArray *__weak nodeStyles; + NSMutableArray *__weak edgeStyles; IBOutlet NSArrayController *nodeStyleArrayController; IBOutlet NSArrayController *filteredNodeStyleArrayController; IBOutlet NSArrayController *edgeStyleArrayController; @@ -43,15 +43,15 @@ NSString *displayedEdgeStyleCategory; } -@property (readonly) NSMutableArray *nodeStyles; -@property (readonly) NSMutableArray *edgeStyles; +@property (weak, readonly) NSMutableArray *nodeStyles; +@property (weak, readonly) NSMutableArray *edgeStyles; @property (readonly) BOOL documentActive; -@property (assign) NodeStyle *activeNodeStyle; -@property (assign) EdgeStyle *activeEdgeStyle; +@property (weak) NodeStyle *activeNodeStyle; +@property (weak) EdgeStyle *activeEdgeStyle; @property (copy) NSString *displayedNodeStyleCategory; @property (copy) NSString *displayedEdgeStyleCategory; -@property (readonly) NSPredicate *displayedNodeStylePredicate; -@property (readonly) NSPredicate *displayedEdgeStylePredicate; +@property (weak, readonly) NSPredicate *displayedNodeStylePredicate; +@property (weak, readonly) NSPredicate *displayedEdgeStylePredicate; //@property NSString *nodeLabel; diff --git a/tikzit/src/osx/TikzDocument.h b/tikzit/src/osx/TikzDocument.h index d817b2e..1881994 100644 --- a/tikzit/src/osx/TikzDocument.h +++ b/tikzit/src/osx/TikzDocument.h @@ -32,6 +32,6 @@ } @property (readonly) NSString *tikz; -@property (readonly) GraphicsView *graphicsView; +@property (weak, readonly) GraphicsView *graphicsView; @end diff --git a/tikzit/src/osx/TikzFormatter.m b/tikzit/src/osx/TikzFormatter.m index 8972706..9e45cb6 100644 --- a/tikzit/src/osx/TikzFormatter.m +++ b/tikzit/src/osx/TikzFormatter.m @@ -76,10 +76,6 @@ } } - [cs autorelease]; - [scanner autorelease]; - [strippedString autorelease]; - if([strippedString length] % 2 == 1){ return NO; } diff --git a/tikzit/src/osx/TikzSourceController.h b/tikzit/src/osx/TikzSourceController.h index 3408d9f..84d36da 100644 --- a/tikzit/src/osx/TikzSourceController.h +++ b/tikzit/src/osx/TikzSourceController.h @@ -27,17 +27,17 @@ #import "ParseErrorView.h" @interface TikzSourceController : NSObject { - GraphicsView *graphicsView; - NSTextView *sourceView; + GraphicsView *__weak graphicsView; + NSTextView *__unsafe_unretained sourceView; NSAttributedString *source; - NSTextField *status; + NSTextField *__weak status; NSDictionary *textAttrs; NSColor *successColor; NSColor *failedColor; - NSTextField *errorMessage; - ParseErrorView *errorNotification; + NSTextField *__weak errorMessage; + ParseErrorView *__weak errorNotification; - NSUndoManager *documentUndoManager; + NSUndoManager *__weak documentUndoManager; BOOL tikzChanged; BOOL justUndid; @@ -46,14 +46,14 @@ } @property BOOL tikzChanged; -@property IBOutlet GraphicsView *graphicsView; -@property IBOutlet NSTextView *sourceView; -@property IBOutlet NSTextField *status; -@property NSUndoManager *documentUndoManager; +@property (weak) IBOutlet GraphicsView *graphicsView; +@property (unsafe_unretained) IBOutlet NSTextView *sourceView; +@property (weak) IBOutlet NSTextField *status; +@property (weak) NSUndoManager *documentUndoManager; @property (copy) NSAttributedString *source; @property (copy) NSString *tikz; -@property IBOutlet ParseErrorView *errorNotification; -@property IBOutlet NSTextField *errorMessage; +@property (weak) IBOutlet ParseErrorView *errorNotification; +@property (weak) IBOutlet NSTextField *errorMessage; - (void)updateTikzFromGraph; - (void)graphChanged:(NSNotification*)n; diff --git a/tikzit/src/osx/TikzSourceController.m b/tikzit/src/osx/TikzSourceController.m index 737d771..84eb3a5 100644 --- a/tikzit/src/osx/TikzSourceController.m +++ b/tikzit/src/osx/TikzSourceController.m @@ -142,8 +142,12 @@ } - (BOOL)tryParseTikz { + NSError *thisError; + Graph *g = [TikzGraphAssembler parseTikz:[self tikz] - error:&lastError]; + error:&thisError]; + + lastError = thisError; if (g) { [graphicsView deselectAll:self]; @@ -230,9 +234,8 @@ } } -- (void)finalize { +- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [super finalize]; } @end diff --git a/tikzit/src/osx/TikzWindowController.h b/tikzit/src/osx/TikzWindowController.h index e35b7eb..eab427c 100644 --- a/tikzit/src/osx/TikzWindowController.h +++ b/tikzit/src/osx/TikzWindowController.h @@ -11,13 +11,13 @@ @class TikzDocument, GraphicsView, TikzSourceController; @interface TikzWindowController : NSWindowController { - GraphicsView *graphicsView; - TikzSourceController *tikzSourceController; + GraphicsView *__weak graphicsView; + TikzSourceController *__weak tikzSourceController; TikzDocument *document; } -@property IBOutlet GraphicsView *graphicsView; -@property IBOutlet TikzSourceController *tikzSourceController; +@property (weak) IBOutlet GraphicsView *graphicsView; +@property (weak) IBOutlet TikzSourceController *tikzSourceController; - (id)initWithDocument:(TikzDocument*)doc; diff --git a/tikzit/src/osx/TikzWindowController.m b/tikzit/src/osx/TikzWindowController.m index 2e672d2..bfacbfb 100644 --- a/tikzit/src/osx/TikzWindowController.m +++ b/tikzit/src/osx/TikzWindowController.m @@ -16,7 +16,7 @@ @synthesize graphicsView, tikzSourceController; - (id)initWithDocument:(TikzDocument*)doc { - [super initWithWindowNibName:@"TikzDocument"]; + if (!(self = [super initWithWindowNibName:@"TikzDocument"])) return nil; document = doc; return self; } diff --git a/tikzit/src/osx/ToolPaletteController.h b/tikzit/src/osx/ToolPaletteController.h index e45c08d..6301c6b 100644 --- a/tikzit/src/osx/ToolPaletteController.h +++ b/tikzit/src/osx/ToolPaletteController.h @@ -30,13 +30,13 @@ typedef enum { } TikzTool; @interface ToolPaletteController : NSObject { - NSPanel *toolPalette; - NSMatrix *toolMatrix; + NSPanel *__weak toolPalette; + NSMatrix *__weak toolMatrix; } @property TikzTool selectedTool; -@property IBOutlet NSPanel *toolPalette; -@property IBOutlet NSMatrix *toolMatrix; +@property (weak) IBOutlet NSPanel *toolPalette; +@property (weak) IBOutlet NSMatrix *toolMatrix; @end -- cgit v1.2.3