Put wxAutoNSAutoreleasePool in methods that may be used outside the run loop.
authorDavid Elliott <dfe@tgwbd.org>
Mon, 14 Jul 2003 13:10:32 +0000 (13:10 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Mon, 14 Jul 2003 13:10:32 +0000 (13:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21952 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
src/cocoa/NSMenu.mm
src/cocoa/button.mm
src/cocoa/checkbox.mm
src/cocoa/colour.mm
src/cocoa/dc.mm
src/cocoa/dialog.mm
src/cocoa/frame.mm
src/cocoa/menu.mm
src/cocoa/menuitem.mm
src/cocoa/statbox.mm
src/cocoa/stattext.mm
src/cocoa/textctrl.mm
src/cocoa/toplevel.mm
src/cocoa/window.mm

index a930b8a4dee7b0b3d6dda890096b35da8a9fe02d..45089152892c8aba695823dedc6af1dc8daca814 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "wx/cocoa/NSMenu.h"
 #include "wx/cocoa/ObjcPose.h"
+#include "wx/cocoa/autorelease.h"
 
 #import <Foundation/NSString.h>
 #import <AppKit/NSMenu.h>
@@ -53,6 +54,7 @@ WX_IMPLEMENT_POSER(wxPoserNSMenu);
 // ============================================================================
 bool wxCocoaNSMenu::CocoaCreate(const wxString &title)
 {
+    wxAutoNSAutoreleasePool pool;
     wxLogDebug("CocoaCreate: "+title);
     m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: [NSString stringWithCString: title.c_str()]];
     return true;
index 46a2201e0e51a1e143bdf7236747ccad41d68131..ab685b206b1be1efc63cfeb239e630dc44624756 100644 (file)
@@ -16,6 +16,8 @@
     #include "wx/log.h"
 #endif
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSButton.h>
 #include "wx/cocoa/string.h"
 
@@ -29,6 +31,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID winid,
             const wxSize& size, long style,
             const wxValidator& validator, const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     wxLogDebug("Creating control with id=%d",winid);
     if(!CreateControl(parent,winid,pos,size,style,validator,name))
         return false;
index 71fb5d4dc44f8b8794768257ce39e8f07ba50e4d..921a1d3a287c93dc07d97bfec019ccefcfcc8d6a 100644 (file)
@@ -13,6 +13,8 @@
 #include "wx/checkbox.h"
 #include "wx/log.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSButton.h>
 #import <Foundation/NSString.h>
 
@@ -29,6 +31,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid,
            const wxValidator& validator,
            const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     if(!CreateControl(parent,winid,pos,size,style,validator,name))
         return false;
     m_cocoaNSView = NULL;
index b755914c4c77d25d61ef422feddf0d7bd7657980..c6b73d70f196ace5dabcfcaefb29c50d00950328 100644 (file)
@@ -14,6 +14,8 @@
 #include "wx/gdicmn.h"
 #include "wx/colour.h"
 
+#include "wx/cocoa/autorelease.h"
+
 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
 
 wxColour::wxColour ()
@@ -65,6 +67,7 @@ wxColour::~wxColour ()
 
 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
 {
+    wxAutoNSAutoreleasePool pool;
     [m_cocoaNSColor release];
     m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];
     m_red = r;
index d9e7e3af62682ed44f5ff6112b1ea5aac10a21c0..4b6e74c6af453fdad50db96a1ca7e9d9e6fc1822 100644 (file)
@@ -12,6 +12,8 @@
 #include "wx/dc.h"
 #include "wx/log.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSBezierPath.h>
 #import <AppKit/NSTextStorage.h>
 #import <AppKit/NSLayoutManager.h>
@@ -83,6 +85,7 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
 
 void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const
 {
+    wxAutoNSAutoreleasePool pool;
 // FIXME: Cache this so it can be used for DoDrawText
     wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, "Text system has not been initialized.  BAD PROGRAMMER!");
     NSAttributedString *attributedString = [[NSAttributedString alloc]
index 3a3625556da6cfe386d9d6e9cb496ca98ede44af..635487ceeb09aacca0ee1745227d41c89d7361d6 100644 (file)
@@ -14,6 +14,8 @@
 #include "wx/settings.h"
 #include "wx/log.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSPanel.h>
 #import <AppKit/NSApplication.h>
 
@@ -44,6 +46,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID winid,
            long style,
            const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     wxTopLevelWindows.Append(this);
 
     if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
@@ -108,6 +111,7 @@ bool wxDialog::Show(bool show)
     {
         if(show)
         {
+            wxAutoNSAutoreleasePool pool;
             wxModalDialogs.Append(this);
             wxLogDebug("runModal");
             [wxTheApp->GetNSApplication() runModalForWindow:m_cocoaNSWindow];
index 3ab4609843bc41fecf8f1e6a7f596f91d698f29a..4024b2534c0f4b8c6d3aeebff90de15400ad98ff 100644 (file)
@@ -16,6 +16,8 @@
 #include "wx/log.h"
 #include "wx/statusbr.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSWindow.h>
 #import <AppKit/NSApplication.h>
 
@@ -73,6 +75,7 @@ void wxFrame::DetachMenuBar()
 
 bool wxFrame::Show(bool show)
 {
+    wxAutoNSAutoreleasePool pool;
     bool ret = wxFrameBase::Show(show);
     if(show && GetMenuBar())
         [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
index 4b8dbf315333951e3553e027b6d2a93daba32a46..f0fc49998a942515f9420cc2f6dc85dd54fece28 100644 (file)
@@ -23,6 +23,8 @@
     #include "wx/log.h"
 #endif // WX_PRECOMP
 
+#include "wx/cocoa/autorelease.h"
+
 #import <Foundation/NSString.h>
 #import <AppKit/NSMenu.h>
 
@@ -53,6 +55,7 @@ wxMenu::~wxMenu()
 
 bool wxMenu::DoAppend(wxMenuItem *item)
 {
+    wxAutoNSAutoreleasePool pool;
     if(!wxMenuBase::DoAppend(item))
         return false;
     [m_cocoaNSMenu addItem: item->GetNSMenuItem()];
@@ -61,6 +64,7 @@ bool wxMenu::DoAppend(wxMenuItem *item)
 
 bool wxMenu::DoInsert(unsigned long pos, wxMenuItem *item)
 {
+    wxAutoNSAutoreleasePool pool;
     if(!wxMenuBase::DoInsert(pos,item))
         return false;
     [m_cocoaNSMenu insertItem:item->GetNSMenuItem() atIndex:pos];
@@ -69,6 +73,7 @@ bool wxMenu::DoInsert(unsigned long pos, wxMenuItem *item)
 
 wxMenuItem* wxMenu::DoRemove(wxMenuItem *item)
 {
+    wxAutoNSAutoreleasePool pool;
     wxMenuItem *retitem = wxMenuBase::DoRemove(item);
     wxASSERT(retitem->GetNSMenuItem());
     [m_cocoaNSMenu removeItem:retitem->GetNSMenuItem()];
@@ -93,6 +98,7 @@ wxMenuBar::~wxMenuBar()
 
 bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
 {
+    wxAutoNSAutoreleasePool pool;
     wxLogDebug("append menu=%p, title=%s",menu,title.c_str());
     if(!wxMenuBarBase::Append(menu,title))
         return false;
@@ -112,6 +118,7 @@ bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
 
 bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
 {
+    wxAutoNSAutoreleasePool pool;
     wxLogDebug("insert pos=%lu, menu=%p, title=%s",pos,menu,title.c_str());
     if(!wxMenuBarBase::Insert(pos,menu,title))
         return false;
index e5cae2430e459cfa5976d58765381daec7e51179..5b7882191849dfd630727dcdb42c4f981f141953 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include "wx/cocoa/ObjcPose.h"
+#include "wx/cocoa/autorelease.h"
 
 #import <AppKit/NSMenuItem.h>
 #import <AppKit/NSMenu.h>
@@ -92,6 +93,7 @@ wxMenuItemCocoa::wxMenuItemCocoa(wxMenu *pParentMenu,
                        wxMenu *pSubMenu)
           : wxMenuItemBase(pParentMenu, itemid, strName, strHelp, kind, pSubMenu)
 {
+    wxAutoNSAutoreleasePool pool;
     NSString *menuTitle = [[NSString alloc] initWithCString: wxStripMenuCodes(strName).c_str()];
     m_cocoaNSMenuItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:@selector(wxMenuItemAction:) keyEquivalent:@""];
     sm_cocoaHash.insert(wxMenuItemCocoaHash::value_type(m_cocoaNSMenuItem,this));
index 766f6773fb9fc6525f94f0f23f9bb4f7661c1bdc..0a8ecab19054ae54fbea22b2ad31d0e18cfe58db 100644 (file)
@@ -12,6 +12,8 @@
 #include "wx/app.h"
 #include "wx/statbox.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSBox.h>
 #import <Foundation/NSString.h>
 
@@ -27,6 +29,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
            long style, const wxValidator& validator,
            const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     if(!CreateControl(parent,winid,pos,size,style,validator,name))
         return false;
     m_cocoaNSView = NULL;
index 88574eeb03a61bc1d5b9aa1d3b2239623104cf4e..31165040f4e9a81309d69c755ea7251be5cb3666 100644 (file)
@@ -12,6 +12,8 @@
 #include "wx/app.h"
 #include "wx/stattext.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <Foundation/NSString.h>
 #import <AppKit/NSTextField.h>
 
@@ -27,6 +29,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
            long style,
            const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
         return false;
     m_cocoaNSView = NULL;
index e062ea4f42c3c8b88b9eca0e966dedd64a01a9de..c04e12a99e415cb21f33fb02994e47ca7052f751 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "wx/cocoa/string.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <Foundation/NSString.h>
 #import <AppKit/NSTextField.h>
 
@@ -30,6 +32,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
             const wxValidator& validator,
             const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     if(!CreateControl(parent,winid,pos,size,style,validator,name))
         return false;
     m_cocoaNSView = NULL;
@@ -113,6 +116,7 @@ void wxTextCtrl::Replace(long, long, wxString const&)
 
 void wxTextCtrl::SetValue(wxString const& value)
 {
+    wxAutoNSAutoreleasePool pool;
     [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
 }
 
@@ -181,6 +185,7 @@ bool wxTextCtrl::CanUndo() const
 
 wxString wxTextCtrl::GetValue() const
 {
+    wxAutoNSAutoreleasePool pool;
     return wxString([[GetNSTextField() stringValue] lossyCString]);
 }
 
index 39b1b48f9dea7c1b54af0eb3ac073de756261d54..c4bfd67a419ab4a83e1a03ee9f30b43821f0f9cb 100644 (file)
@@ -28,6 +28,8 @@
     #include "wx/app.h"
 #endif //WX_PRECOMP
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSView.h>
 #import <AppKit/NSWindow.h>
 // ----------------------------------------------------------------------------
@@ -63,6 +65,7 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent,
                                  long style,
                                  const wxString& name)
 {
+    wxAutoNSAutoreleasePool pool;
     wxTopLevelWindows.Append(this);
 
     if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
@@ -94,6 +97,7 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent,
 
 wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa()
 {
+    wxAutoNSAutoreleasePool pool;
     // Hand ownership of the content view to wxWindow so it can destroy
     // itself properly.
     NSView *view = [m_cocoaNSView retain];
@@ -169,6 +173,7 @@ void wxTopLevelWindowCocoa::Restore()
 
 bool wxTopLevelWindowCocoa::Show(bool show)
 {
+    wxAutoNSAutoreleasePool pool;
     if(show)
         [m_cocoaNSWindow makeKeyAndOrderFront:m_cocoaNSWindow];
     else
index 9adb78257a130ba296f24fbc17e6ac92635ec1f3..683ef6fc23ab40a4ec9e9b79d97bb8e76fd6edd9 100644 (file)
@@ -12,6 +12,8 @@
 #include "wx/window.h"
 #include "wx/log.h"
 
+#include "wx/cocoa/autorelease.h"
+
 #import <Appkit/NSView.h>
 #import <AppKit/NSEvent.h>
 
@@ -64,6 +66,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID winid,
 // Destructor
 wxWindow::~wxWindow()
 {
+    wxAutoNSAutoreleasePool pool;
     DestroyChildren();
 
     if(m_parent)
@@ -244,6 +247,7 @@ bool wxWindow::Close(bool force)
 
 bool wxWindow::Show(bool show)
 {
+    wxAutoNSAutoreleasePool pool;
     // If the window is marked as visible, then it shouldn't have a dummy view
     // If the window is marked hidden, then it should have a dummy view
     wxASSERT_MSG( (m_isShown && !m_dummyNSView) || (!m_isShown && m_dummyNSView),"wxWindow: m_isShown does not agree with m_dummyNSView");
@@ -485,6 +489,7 @@ void wxWindow::Clear()
 // Raise the window to the top of the Z order
 void wxWindow::Raise()
 {
+    wxAutoNSAutoreleasePool pool;
     NSView *nsview = m_dummyNSView?m_dummyNSView:m_cocoaNSView;
     NSView *superview = [nsview superview];
     [nsview retain];