From 3d4104bd1c420362a31ba08c28771c75f4b3128f Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 4 Jan 2013 18:23:23 +1100 Subject: Fix object ownership and thus memory management. Change owner and backend properties to (nonatomic, assign) as pointers to owners should not be retained and backend is a pointer to a C++ object. Move property declarations before methods. Update copyright notice. From Mike Lischke at Oracle. --- cocoa/ScintillaCocoa.mm | 4 +--- cocoa/ScintillaView.h | 11 +++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index be8987083..cdf3f059a 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -381,7 +381,7 @@ const CGFloat paddingHighlightY = 2; ScintillaCocoa::ScintillaCocoa(NSView* view) { - wMain= [view retain]; + wMain = view; // Don't retain since we're owned by view, which would cause a cycle timerTarget = [[[TimerTarget alloc] init: this] retain]; layerFindIndicator = NULL; Initialise(); @@ -393,8 +393,6 @@ ScintillaCocoa::~ScintillaCocoa() { SetTicking(false); [timerTarget release]; - NSView* container = ContentView(); - [container release]; } //-------------------------------------------------------------------------------------------------- diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h index dcdea93a9..b55591e80 100644 --- a/cocoa/ScintillaView.h +++ b/cocoa/ScintillaView.h @@ -4,7 +4,8 @@ * * Created by Mike Lischke. * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Copyright 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright 2009, 2011 Sun Microsystems, Inc. All rights reserved. * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). */ @@ -36,6 +37,8 @@ extern NSString *SCIUpdateUINotification; NSRange mMarkedTextRange; } +@property (nonatomic, assign) ScintillaView* owner; + - (void) dealloc; - (void) removeMarkedText; - (void) setCursor: (Scintilla::Window::Cursor) cursor; @@ -43,7 +46,6 @@ extern NSString *SCIUpdateUINotification; - (BOOL) canUndo; - (BOOL) canRedo; -@property (assign) ScintillaView* owner; @end @interface ScintillaView : NSView @@ -70,6 +72,9 @@ extern NSString *SCIUpdateUINotification; int mInitialInfoBarWidth; } +@property (nonatomic, assign) Scintilla::ScintillaCocoa* backend; +@property (nonatomic, assign) NSObject* owner; + - (void) dealloc; - (void) positionSubViews; @@ -137,6 +142,4 @@ extern NSString *SCIUpdateUINotification; scrollTo: (BOOL) scrollTo wrap: (BOOL) wrap; -@property Scintilla::ScintillaCocoa* backend; -@property (retain) NSObject* owner; @end -- cgit v1.2.3