diff options
author | nyamatongwe <nyamatongwe@gmail.com> | 2011-11-09 13:39:39 +1100 |
---|---|---|
committer | nyamatongwe <nyamatongwe@gmail.com> | 2011-11-09 13:39:39 +1100 |
commit | 2fce522eae48f7263df90a99c1fa0c7f7f89675b (patch) | |
tree | f219d08dd83983b5ae81706623ce33aef4159a4e | |
parent | 84607c2c9bbaf931b5e6907486ce276f65940ab0 (diff) | |
download | scintilla-mirror-2fce522eae48f7263df90a99c1fa0c7f7f89675b.tar.gz |
Fix potential memory problems found by analyze.
-rw-r--r-- | cocoa/PlatCocoa.mm | 12 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 10 |
2 files changed, 11 insertions, 11 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 7f0d86813..5703a76f8 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1452,7 +1452,8 @@ private: NSScrollView* scroller; NSTableColumn* colIcon; NSTableColumn* colText; - + AutoCompletionDataSource* ds; + LinesData ld; CallBackAction doubleClickAction; void* doubleClickActionData; @@ -1569,24 +1570,23 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt NSRect scRect = NSMakeRect(0, 0, lbRect.size.width, lbRect.size.height); [scroller initWithFrame: scRect]; [scroller setHasVerticalScroller:YES]; - table = [NSTableView alloc]; - [table initWithFrame: scRect]; + table = [[NSTableView alloc] initWithFrame: scRect]; [table setHeaderView:nil]; [scroller setDocumentView: table]; colIcon = [[NSTableColumn alloc] initWithIdentifier:@"icon"]; [colIcon setWidth: 20]; [colIcon setEditable:NO]; [colIcon setHidden:YES]; - NSImageCell* imCell = [[NSImageCell alloc] init]; + NSImageCell* imCell = [[[NSImageCell alloc] init] autorelease]; [colIcon setDataCell:imCell]; [table addTableColumn:colIcon]; colText = [[NSTableColumn alloc] initWithIdentifier:@"name"]; [colText setResizingMask:NSTableColumnAutoresizingMask]; [colText setEditable:NO]; [table addTableColumn:colText]; - AutoCompletionDataSource* ds = [[AutoCompletionDataSource alloc] init]; + ds = [[AutoCompletionDataSource alloc] init]; [ds setBox:this]; - [table setDataSource: ds]; + [table setDataSource: ds]; // Weak reference [scroller setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [[winLB contentView] addSubview: scroller]; diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 0b4fe6294..ccaa384f7 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -799,15 +799,15 @@ void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled) [menu setOwner: this]; [menu setAutoenablesItems: NO]; - if (cmd == 0) + if (cmd == 0) { item = [NSMenuItem separatorItem]; - else - item = [[NSMenuItem alloc] init]; - + } else { + item = [[[NSMenuItem alloc] init] autorelease]; + [item setTitle: [NSString stringWithUTF8String: label]]; + } [item setTarget: menu]; [item setAction: @selector(handleCommand:)]; [item setTag: cmd]; - [item setTitle: [NSString stringWithUTF8String: label]]; [item setEnabled: enabled]; [menu addItem: item]; |