mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: crash when dialog.showMessageBoxSync with missing buttons (#41043)
* fix: crash when dialog.showMessageBoxSync missing buttons Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * chore: feedback from review Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -76,15 +76,16 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
|
||||
[[ns_buttons objectAtIndex:settings.default_id] setKeyEquivalent:@"\r"];
|
||||
}
|
||||
|
||||
// Bind cancel id button to escape key if there is more than one button
|
||||
if (button_count > 1 && settings.cancel_id >= 0 &&
|
||||
settings.cancel_id < button_count) {
|
||||
[[ns_buttons objectAtIndex:settings.cancel_id] setKeyEquivalent:@"\e"];
|
||||
}
|
||||
if (button_count > 1 && settings.cancel_id >= 0) {
|
||||
// Bind cancel id button to escape key if there is more than one button.
|
||||
if (settings.cancel_id < button_count) {
|
||||
[[ns_buttons objectAtIndex:settings.cancel_id] setKeyEquivalent:@"\e"];
|
||||
}
|
||||
|
||||
// TODO(@codebytere): This behavior violates HIG & should be deprecated.
|
||||
if (settings.cancel_id >= 0 && settings.cancel_id == settings.default_id) {
|
||||
[[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
|
||||
// TODO(@codebytere): This behavior violates HIG & should be deprecated.
|
||||
if (settings.cancel_id == settings.default_id) {
|
||||
[[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
|
||||
}
|
||||
}
|
||||
|
||||
if (!settings.checkbox_label.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user