Clean up setters, they take the ownership, so no need to retain and autorelease

This commit is contained in:
Stefan Csomor
2017-06-28 10:28:04 +02:00
parent 1902c5ceb8
commit 8d78887a22

View File

@@ -388,7 +388,7 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column)
[[nativeColumn headerCell] setAlignment: [[nativeColumn headerCell] setAlignment:
ConvertToNativeHorizontalTextAlignment(column->GetAlignment())]; ConvertToNativeHorizontalTextAlignment(column->GetAlignment())];
[[nativeColumn headerCell] setStringValue: [[nativeColumn headerCell] setStringValue:
[[wxCFStringRef(column->GetTitle()).AsNSString() retain] autorelease]]; wxCFStringRef(column->GetTitle()).AsNSString()];
renderData->ApplyLineBreakMode([nativeColumn headerCell]); renderData->ApplyLineBreakMode([nativeColumn headerCell]);
// setting data cell's properties: // setting data cell's properties:
@@ -3039,14 +3039,14 @@ bool wxDataViewBitmapRenderer::MacRender()
wxBitmap bitmap; wxBitmap bitmap;
bitmap << GetValue(); bitmap << GetValue();
if (bitmap.IsOk()) if (bitmap.IsOk())
[GetNativeData()->GetItemCell() setObjectValue:[[bitmap.GetNSImage() retain] autorelease]]; [GetNativeData()->GetItemCell() setObjectValue:bitmap.GetNSImage()];
} }
else if (GetValue().GetType() == wxS("wxIcon")) else if (GetValue().GetType() == wxS("wxIcon"))
{ {
wxIcon icon; wxIcon icon;
icon << GetValue(); icon << GetValue();
if (icon.IsOk()) if (icon.IsOk())
[GetNativeData()->GetItemCell() setObjectValue:[[icon.GetNSImage() retain] autorelease]]; [GetNativeData()->GetItemCell() setObjectValue:icon.GetNSImage()];
} }
return true; return true;
} }
@@ -3104,7 +3104,7 @@ wxDataViewChoiceRenderer::OSXOnCellChanged(NSObject *value,
bool wxDataViewChoiceRenderer::MacRender() bool wxDataViewChoiceRenderer::MacRender()
{ {
[((NSPopUpButtonCell*) GetNativeData()->GetItemCell()) selectItemWithTitle:[[wxCFStringRef(GetValue().GetString()).AsNSString() retain] autorelease]]; [((NSPopUpButtonCell*) GetNativeData()->GetItemCell()) selectItemWithTitle:wxCFStringRef(GetValue().GetString()).AsNSString()];
return true; return true;
} }
@@ -3266,10 +3266,10 @@ bool wxDataViewIconTextRenderer::MacRender()
cell = (wxImageTextCell*) GetNativeData()->GetItemCell(); cell = (wxImageTextCell*) GetNativeData()->GetItemCell();
iconText << GetValue(); iconText << GetValue();
if (iconText.GetIcon().IsOk()) if (iconText.GetIcon().IsOk())
[cell setImage:[[wxBitmap(iconText.GetIcon()).GetNSImage() retain] autorelease]]; [cell setImage:wxBitmap(iconText.GetIcon()).GetNSImage()];
else else
[cell setImage:nil]; [cell setImage:nil];
[cell setStringValue:[[wxCFStringRef(iconText.GetText()).AsNSString() retain] autorelease]]; [cell setStringValue:wxCFStringRef(iconText.GetText()).AsNSString()];
return true; return true;
} }
@@ -3438,7 +3438,7 @@ void wxDataViewColumn::SetBitmap(const wxBitmap& bitmap)
// the title is removed: // the title is removed:
m_title = wxEmptyString; m_title = wxEmptyString;
wxDataViewColumnBase::SetBitmap(bitmap); wxDataViewColumnBase::SetBitmap(bitmap);
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setImage:[[bitmap.GetNSImage() retain] autorelease]]; [[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setImage:bitmap.GetNSImage()];
} }
void wxDataViewColumn::SetMaxWidth(int maxWidth) void wxDataViewColumn::SetMaxWidth(int maxWidth)
@@ -3517,7 +3517,7 @@ void wxDataViewColumn::SetTitle(const wxString& title)
// the bitmap is removed: // the bitmap is removed:
wxDataViewColumnBase::SetBitmap(wxBitmap()); wxDataViewColumnBase::SetBitmap(wxBitmap());
m_title = title; m_title = title;
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setStringValue:[[wxCFStringRef(title).AsNSString() retain] autorelease]]; [[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setStringValue:wxCFStringRef(title).AsNSString()];
} }
void wxDataViewColumn::SetWidth(int width) void wxDataViewColumn::SetWidth(int width)