Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit b5e7df2

Browse files
authored
Merge pull request #5313 from runrevmark/bugfix-19479
[[ Bug 19479 ]] Make modals close automatically on Cmd-.
2 parents 1303825 + 97c05b2 commit b5e7df2

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

docs/notes/bugfix-19479.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Cmd-. does not affect modal dialogs
2+
3+
Previously using the abort-script keyboard combination (Cmd-. on Mac) would
4+
cause an abort error to be thrown. However, this would be silently swallowed
5+
by any modal command (or equivalent) meaning that unusable modal dialogs
6+
would be uncloseable, requiring the need to restart the IDE / engine.
7+
8+
This has been fixed by making Cmd-. cause an automatic 'close this stack'
9+
when it occurs in a modal loop and allowInterrupts is true, and the current
10+
stack has cantAbort set to false.
11+

engine/src/stack2.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,7 @@ Exec_stat MCStack::openrect(const MCRectangle &rel, Window_mode wm, MCStack *par
24732473
// MW-2011-01-12: [[ Bug 9282 ]] Set to true if the props need restoring.
24742474
bool t_restore_props;
24752475

2476+
Exec_stat t_stat = ES_NORMAL;
24762477
if (opened && flags & F_VISIBLE)
24772478
{
24782479
// MW-2011-08-19: [[ Redraw ]] Set the update region to everything.
@@ -2522,22 +2523,40 @@ Exec_stat MCStack::openrect(const MCRectangle &rel, Window_mode wm, MCStack *par
25222523
// If opening the dialog failed for some reason, this will return false.
25232524
if (mode_openasdialog())
25242525
{
2525-
while (opened && (mode == WM_MODAL || mode == WM_SHEET) && !MCquit)
2526+
while (opened &&
2527+
(mode == WM_MODAL || mode == WM_SHEET) &&
2528+
!MCquit &&
2529+
!MCabortscript)
25262530
{
25272531
MCU_resetprops(True);
25282532
// MW-2011-09-08: [[ Redraw ]] Make sure we flush any updates.
25292533
MCRedrawUpdateScreen();
25302534
MCscreen->siguser();
2531-
MCscreen->wait(REFRESH_INTERVAL, True, True);
2535+
if (MCscreen->wait(REFRESH_INTERVAL, True, True))
2536+
{
2537+
MCeerror->add(EE_WAIT_ABORT, 0, 0);
2538+
t_stat = ES_ERROR;
2539+
break;
2540+
}
25322541
}
25332542
mode_closeasdialog();
25342543
if (MCquit)
25352544
MCabortscript = False;
25362545
}
25372546

2538-
// Make sure the mode is reset to closed so dialogs can be reopened.
2539-
mode = WM_CLOSED;
2540-
2547+
// If there was no error, make sure the mode is reset to closed so
2548+
// it can be reopened. Otherwise, do the equivalent of 'close this
2549+
// stack'.
2550+
if (t_stat != ES_ERROR)
2551+
{
2552+
mode = WM_CLOSED;
2553+
}
2554+
else
2555+
{
2556+
close();
2557+
checkdestroy();
2558+
}
2559+
25412560
t_restore_props = true;
25422561
}
25432562
else
@@ -2572,7 +2591,8 @@ Exec_stat MCStack::openrect(const MCRectangle &rel, Window_mode wm, MCStack *par
25722591
}
25732592
if (reopening)
25742593
MClockmessages = oldlock;
2575-
return ES_NORMAL;
2594+
2595+
return t_stat;
25762596

25772597

25782598
}

0 commit comments

Comments
 (0)