Files
textmate/Frameworks/OakTextView/src/GutterView.h
Ronald Wampler 4c1f8a18fb Use weak storage for GutterView's partnerView
On 10.12 beta 3, when closing a window, the following exception is thrown:

Exception Name: NSInternalInconsistencyException
Description: <GutterView 0x7fa71c511150> has reached dealloc but still has a super view. Super views strongly reference there children, so this is being over-released, or has been over-released in the past.

Despite the mention of our GutterView instance being over-released, the actual problem is that we do not call super in our override of `removeFromSuperView`, where we nil out our partner view. A simple fix to avoid crashing would be just calling super in that method so that the view is marked as being removed; however, we can simplify the code and eliminate the need to override our super's method by using a weak reference instead and let ARC automatically handle the zeroing of our partner view.
2016-07-21 15:55:01 -04:00

56 lines
2.3 KiB
Objective-C

extern NSString* GVColumnDataSourceDidChange;
extern NSString* GVLineNumbersColumnIdentifier;
struct GVLineRecord
{
GVLineRecord (NSUInteger lineNumber = NSNotFound, NSUInteger softlineOffset = 0, CGFloat firstY = 0, CGFloat lastY = 0, CGFloat baseline = 0) : lineNumber(lineNumber), softlineOffset(softlineOffset), firstY(firstY), lastY(lastY), baseline(baseline) { }
NSUInteger lineNumber;
NSUInteger softlineOffset;
CGFloat firstY;
CGFloat lastY;
CGFloat baseline;
};
@protocol GutterViewDelegate
- (GVLineRecord)lineRecordForPosition:(CGFloat)yPos;
- (GVLineRecord)lineFragmentForLine:(NSUInteger)aLine column:(NSUInteger)aColumn;
@end
typedef NS_ENUM(NSUInteger, GutterViewRowState) {
GutterViewRowStateRegular = 0,
GutterViewRowStatePressed,
GutterViewRowStateRollover
};
@protocol GutterViewColumnDataSource
- (NSImage*)imageForLine:(NSUInteger)aLine inColumnWithIdentifier:(id)columnIdentifier state:(GutterViewRowState)rowState;
- (CGFloat)widthForColumnWithIdentifier:(id)columnIdentifier;
@end
@protocol GutterViewColumnDelegate
- (void)userDidClickColumnWithIdentifier:(id)columnIdentifier atLine:(NSUInteger)lineNumber;
@end
@interface GutterView : NSView
@property (nonatomic, weak) IBOutlet NSView* partnerView;
@property (nonatomic) NSFont* lineNumberFont;
@property (nonatomic, weak) id <GutterViewDelegate> delegate;
@property (nonatomic) NSColor* foregroundColor;
@property (nonatomic) NSColor* backgroundColor;
@property (nonatomic) NSColor* iconColor;
@property (nonatomic) NSColor* iconHoverColor;
@property (nonatomic) NSColor* iconPressedColor;
@property (nonatomic) NSColor* selectionForegroundColor;
@property (nonatomic) NSColor* selectionBackgroundColor;
@property (nonatomic) NSColor* selectionIconColor;
@property (nonatomic) NSColor* selectionIconHoverColor;
@property (nonatomic) NSColor* selectionIconPressedColor;
@property (nonatomic) NSColor* selectionBorderColor;
- (void)setHighlightedRange:(std::string const&)str;
- (void)reloadData:(id)sender;
- (void)insertColumnWithIdentifier:(NSString*)columnIdentifier atPosition:(NSUInteger)index dataSource:(id <GutterViewColumnDataSource>)columnDataSource delegate:(id <GutterViewColumnDelegate>)columnDelegate;
- (void)setVisibility:(BOOL)visible forColumnWithIdentifier:(NSString*)columnIdentifier;
- (BOOL)visibilityForColumnWithIdentifier:(NSString*)identifier;
@end