Put wxAutoNSAutoreleasePool in methods that may be used outside the run loop.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21952 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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]
|
||||
|
@@ -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];
|
||||
|
@@ -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() ];
|
||||
|
@@ -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;
|
||||
|
@@ -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));
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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]);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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];
|
||||
|
Reference in New Issue
Block a user