Skip to content

Commit f8838eb

Browse files
committed
Merge remote-tracking branch 'upstream/release-8.1.7' into merge-release-8.1.7-01.10.2017
2 parents ffdf5b3 + 9b57f1b commit f8838eb

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

docs/notes/bugfix-20490.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix crash when closing color dialog on macOS High Sierra

engine/src/mac-dialog.mm

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,9 @@ -(id) initWithColorPanel: (NSColorPanel*) p_panel
717717
NSButton *t_cancel_button;
718718

719719
// Get the colour picker's view and store it
720-
mColorPanel = p_panel;
720+
mColorPanel = [p_panel retain];
721721

722-
mColorPickerView = p_view;
722+
mColorPickerView = [p_view retain];
723723

724724
// Remove the colour picker's view
725725
[mColorPanel setContentView:0];
@@ -759,14 +759,10 @@ -(id) initWithColorPanel: (NSColorPanel*) p_panel
759759

760760
-(void)dealloc
761761
{
762-
NSColorPanel *t_color_picker;
763-
t_color_picker = [NSColorPanel sharedColorPanel];
764762

765-
[[mColorPickerView window] close];
763+
[mColorPanel release];
764+
[mColorPickerView release];
766765

767-
// Reset the color's picker view
768-
[mColorPickerView removeFromSuperview];
769-
[t_color_picker setContentView: mColorPickerView];
770766

771767
[mOkButton release];
772768
[mCancelButton release];
@@ -775,6 +771,16 @@ -(void)dealloc
775771
[super dealloc];
776772
}
777773

774+
-(void)closePanel
775+
{
776+
[mColorPanel close];
777+
[mColorPanel setDelegate: nil];
778+
779+
// Reset the color's picker view
780+
[mColorPickerView removeFromSuperview];
781+
[mColorPanel setContentView: mColorPickerView];
782+
}
783+
778784
// Redrawing method - adapts the size of the buttons to the size of the picker
779785
-(void)relayout
780786
{
@@ -941,9 +947,7 @@ void MCPlatformBeginColorDialog(MCStringRef p_title, const MCColor& p_color)
941947
alpha:1];
942948
[t_colorPicker setColor:t_initial_color];
943949

944-
NSView* t_pickerView;
945-
t_pickerView = [t_colorPicker contentView];
946-
[t_pickerView retain];
950+
NSView* t_pickerView = [t_colorPicker contentView];
947951

948952
s_color_dialog_result = kMCPlatformDialogResultContinue;
949953
s_color_dialog_delegate = [[com_runrev_livecode_MCColorPanelDelegate alloc] initWithColorPanel:t_colorPicker
@@ -969,7 +973,9 @@ MCPlatformDialogResult MCPlatformEndColorDialog(MCColor& r_color)
969973
r_color = s_color_dialog_color;
970974

971975
[NSApp becomePseudoModalFor: nil];
972-
[s_color_dialog_delegate dealloc];
976+
977+
[s_color_dialog_delegate closePanel];
978+
[s_color_dialog_delegate release];
973979
s_color_dialog_delegate = NULL;
974980
}
975981

0 commit comments

Comments
 (0)