|
30 | 30 |
|
31 | 31 | //////////////////////////////////////////////////////////////////////////////// |
32 | 32 |
|
| 33 | +// MW-2014-06-25: [[ Bug 12686 ]] Make sure we first try the defaultStack, then |
| 34 | +// the topStack. |
| 35 | +static MCPlatformWindowRef compute_sheet_owner(unsigned int p_options) |
| 36 | +{ |
| 37 | + if ((p_options & MCA_OPTION_SHEET) == 0) |
| 38 | + return nil; |
| 39 | + |
| 40 | + MCPlatformWindowRef t_window; |
| 41 | + t_window = MCdefaultstackptr -> getwindow(); |
| 42 | + if (t_window != nil && MCPlatformIsWindowVisible(t_window)) |
| 43 | + return t_window; |
| 44 | + |
| 45 | + t_window = MCtopstackptr -> getwindow(); |
| 46 | + if (t_window != nil && MCPlatformIsWindowVisible(t_window)) |
| 47 | + return t_window; |
| 48 | + |
| 49 | + return nil; |
| 50 | +} |
| 51 | + |
| 52 | +//////////////////////////////////////////////////////////////////////////////// |
| 53 | + |
33 | 54 | // MM-2012-02-13: Updated to use Cocoa APIs. Code mostly cribbed from plugin dialog stuff |
34 | 55 | int MCA_folder(MCExecPoint& ep, const char *p_title, const char *p_prompt, const char *p_initial, unsigned int p_options) |
35 | 56 | { |
36 | 57 | MCPlatformWindowRef t_owner; |
37 | | - if ((p_options & MCA_OPTION_SHEET) != 0) |
38 | | - t_owner = MCtopstackptr -> getwindow(); |
39 | | - else |
40 | | - t_owner = nil; |
| 58 | + t_owner = compute_sheet_owner(p_options); |
41 | 59 |
|
42 | 60 | MCPlatformBeginFolderDialog(t_owner, p_title, p_prompt, p_initial); |
43 | 61 |
|
@@ -126,10 +144,7 @@ int MCA_file(MCExecPoint& ep, const char *p_title, const char *p_prompt, const c |
126 | 144 | filter_to_type_list(p_filter, t_types, t_type_count); |
127 | 145 |
|
128 | 146 | MCPlatformWindowRef t_owner; |
129 | | - if ((p_options & MCA_OPTION_SHEET) != 0) |
130 | | - t_owner = MCtopstackptr -> getwindow(); |
131 | | - else |
132 | | - t_owner = nil; |
| 147 | + t_owner = compute_sheet_owner(p_options); |
133 | 148 |
|
134 | 149 | MCPlatformFileDialogKind t_kind; |
135 | 150 | if ((p_options & MCA_OPTION_PLURAL) != 0) |
@@ -167,10 +182,7 @@ int MCA_file(MCExecPoint& ep, const char *p_title, const char *p_prompt, const c |
167 | 182 | int MCA_file_with_types(MCExecPoint& ep, const char *p_title, const char *p_prompt, char * const p_types[], uint4 p_type_count, const char *p_initial, unsigned int p_options) |
168 | 183 | { |
169 | 184 | MCPlatformWindowRef t_owner; |
170 | | - if ((p_options & MCA_OPTION_SHEET) != 0) |
171 | | - t_owner = MCtopstackptr -> getwindow(); |
172 | | - else |
173 | | - t_owner = nil; |
| 185 | + t_owner = compute_sheet_owner(p_options); |
174 | 186 |
|
175 | 187 | MCPlatformFileDialogKind t_kind; |
176 | 188 | if ((p_options & MCA_OPTION_PLURAL) != 0) |
@@ -216,10 +228,7 @@ int MCA_ask_file(MCExecPoint& ep, const char *p_title, const char *p_prompt, con |
216 | 228 | filter_to_type_list(p_filter, t_types, t_type_count); |
217 | 229 |
|
218 | 230 | MCPlatformWindowRef t_owner; |
219 | | - if ((p_options & MCA_OPTION_SHEET) != 0) |
220 | | - t_owner = MCtopstackptr -> getwindow(); |
221 | | - else |
222 | | - t_owner = nil; |
| 231 | + t_owner = compute_sheet_owner(p_options); |
223 | 232 |
|
224 | 233 | MCPlatformBeginFileDialog(kMCPlatformFileDialogKindSave, t_owner, p_title, p_prompt, t_types, t_type_count, p_initial); |
225 | 234 |
|
@@ -251,10 +260,7 @@ int MCA_ask_file(MCExecPoint& ep, const char *p_title, const char *p_prompt, con |
251 | 260 | int MCA_ask_file_with_types(MCExecPoint& ep, const char *p_title, const char *p_prompt, char * const p_types[], uint4 p_type_count, const char *p_initial, unsigned int p_options) |
252 | 261 | { |
253 | 262 | MCPlatformWindowRef t_owner; |
254 | | - if ((p_options & MCA_OPTION_SHEET) != 0) |
255 | | - t_owner = MCtopstackptr -> getwindow(); |
256 | | - else |
257 | | - t_owner = nil; |
| 263 | + t_owner = compute_sheet_owner(p_options); |
258 | 264 |
|
259 | 265 | MCPlatformBeginFileDialog(kMCPlatformFileDialogKindSave, t_owner, p_title, p_prompt, p_types, p_type_count, p_initial); |
260 | 266 |
|
|
0 commit comments