From c5d60520442f21cd4515f6c323421e628fe4e8b8 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Tue, 17 Mar 2015 15:13:51 +1100 Subject: Bug [#1706]. Release list box objects when autocompletion closed. --- cocoa/PlatCocoa.mm | 57 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 7645fdd65..442f1f3bb 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1094,21 +1094,7 @@ Window::~Window() { } -//-------------------------------------------------------------------------------------------------- - -void Window::Destroy() -{ - if (wid) - { - id idWin = reinterpret_cast(wid); - if ([idWin isKindOfClass: [NSWindow class]]) - { - NSWindow* win = reinterpret_cast(idWin); - [win release]; - } - } - wid = 0; -} +// Window::Destroy needs to see definition of ListBoxImpl so is located after ListBoxImpl //-------------------------------------------------------------------------------------------------- @@ -1379,6 +1365,8 @@ static NSImage* ImageFromXPM(XPM* pxpm) //----------------- ListBox and related classes ---------------------------------------------------- +//----------------- IListBox ----------------------------------------------------------------------- + namespace { // unnamed namespace hides IListBox interface @@ -1572,6 +1560,9 @@ public: } void SetList(const char* list, char separator, char typesep); + // To clean up when closed + void ReleaseViews(); + // For access from AutoCompletionDataSource implement IListBox int Rows(); NSImage* ImageForRow(NSInteger row); @@ -1690,6 +1681,20 @@ int ListBoxImpl::CaretFromEdge() return 6 + static_cast([colIcon width]); } +void ListBoxImpl::ReleaseViews() +{ + [table release]; + table = nil; + [scroller release]; + scroller = nil; + [colIcon release]; + colIcon = nil; + [colText release ]; + colText = nil; + [ds release]; + ds = nil; +} + void ListBoxImpl::Clear() { maxItemWidth = 0; @@ -1905,6 +1910,28 @@ ListBox* ListBox::Allocate() return lb; } +//-------------------------------------------------------------------------------------------------- + +void Window::Destroy() +{ + ListBoxImpl *listbox = dynamic_cast(this); + if (listbox) + { + listbox->ReleaseViews(); + } + if (wid) + { + id idWin = reinterpret_cast(wid); + if ([idWin isKindOfClass: [NSWindow class]]) + { + NSWindow* win = reinterpret_cast(idWin); + [win release]; + } + } + wid = 0; +} + + //----------------- ScintillaContextMenu ----------------------------------------------------------- @implementation ScintillaContextMenu : NSMenu -- cgit v1.2.3