Skip to content

Commit

Permalink
Fix releasing control handlers/delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
roblillack committed May 27, 2024
1 parent 101ca94 commit 270a541
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion button.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ButtonPtr Button_New(int goButtonID, int x, int y, int w, int h) {
id nsButton = [[[NSButton alloc] initWithFrame:NSMakeRect(x, y, w, h)] autorelease];
ButtonHandler* handler = [[ButtonHandler alloc] init];
[handler setGoButtonID:goButtonID];
[handler autorelease];
[nsButton setTarget:handler];
[nsButton setAction:@selector(buttonClicked:)];

Expand All @@ -30,6 +29,7 @@ void Button_SetTitle(ButtonPtr btnPtr, const char* title) {
void Button_Remove(ButtonPtr btnPtr) {
NSButton* button = (NSButton*)btnPtr;
[button removeFromSuperview];
[[button target] release];
}

const char* Button_Title(ButtonPtr btnPtr) {
Expand Down
2 changes: 1 addition & 1 deletion combobox.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ComboBoxPtr ComboBox_New(int goComboBoxID, int x, int y, int w, int h) {
id nsComboBox = [[[NSComboBox alloc] initWithFrame:NSMakeRect(x, y, w, h)] autorelease];
ComboBoxHandler* handler = [[ComboBoxHandler alloc] init];
[handler setGoComboBoxID:goComboBoxID];
[handler autorelease];
[nsComboBox setDelegate:handler];
[nsComboBox setTarget:handler];
[nsComboBox setAction:@selector(comboBoxSelectionDidChange:)];
Expand Down Expand Up @@ -63,4 +62,5 @@ void ComboBox_SetStringValue(ComboBoxPtr comboBoxPtr, const char* stringValue) {
void ComboBox_Remove(ComboBoxPtr comboBoxPtr) {
NSComboBox* comboBox = (NSComboBox*)comboBoxPtr;
[comboBox removeFromSuperview];
[[comboBox target] release];
}
2 changes: 1 addition & 1 deletion slider.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ SliderPtr Slider_New(int goSliderID, int x, int y, int w, int h) {
[handler setGoSliderID:goSliderID];
[nsSlider setTarget:handler];
[nsSlider setAction:@selector(sliderValueChanged:)];
// [handler autorelease];

return (SliderPtr)nsSlider;
}
Expand Down Expand Up @@ -48,4 +47,5 @@ void Slider_SetSliderType(SliderPtr sliderPtr, int sliderType) {
void Slider_Remove(SliderPtr sliderPtr) {
NSSlider* slider = (NSSlider*)sliderPtr;
[slider removeFromSuperview];
[[slider target] release];
}
2 changes: 1 addition & 1 deletion stepper.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ StepperPtr Stepper_New(int goStepperId, int x, int y, int w, int h) {

StepperHandler *handler = [[StepperHandler alloc] init];
[handler setGoStepperId:goStepperId];
[handler autorelease];
[nsStepper setTarget:handler];
[nsStepper setAction:@selector(stepperValueChanged:)];

Expand Down Expand Up @@ -58,4 +57,5 @@ void Stepper_SetValueWraps(StepperPtr StepperPtr, bool wraps) {
void Stepper_Remove(StepperPtr StepperPtr) {
NSStepper *stepper = (NSStepper *)StepperPtr;
[stepper removeFromSuperview];
[[stepper target] release];
}
1 change: 1 addition & 0 deletions tableview.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ TableViewPtr TableView_New(int goTableViewId, int x, int y, int w, int h) {
void TableView_Remove(TableViewPtr tableViewPtr) {
NSScrollView *x = (NSScrollView *)tableViewPtr;
[x removeFromSuperview];
[[x delegate] release];
}

const int TableView_IsEnabled(TableViewPtr tableViewPtr) {
Expand Down
1 change: 1 addition & 0 deletions textfield.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void TextField_SetStringValue(TextFieldPtr textFieldPtr, const char* text) {
void TextField_Remove(TextFieldPtr textFieldPtr) {
NSTextField* tf = (NSTextField*)textFieldPtr;
[tf removeFromSuperview];
[[tf delegate] release];
}

const int TextField_Enabled(TextFieldPtr textFieldPtr) {
Expand Down

0 comments on commit 270a541

Please sign in to comment.