Reduce nesting

This commit is contained in:
Thomas Goyne 2015-03-11 12:58:23 -08:00
parent a5c87908e1
commit ff874fadf9

View file

@ -763,6 +763,12 @@ namespace {
try { try {
LuaThreadedCall(L, 3, 2, from_wx(StrDisplay(c)), c->parent, true); LuaThreadedCall(L, 3, 2, from_wx(StrDisplay(c)), c->parent, true);
}
catch (agi::UserCancelException const&) {
subsobj->Cancel();
stackcheck.check_stack(0);
return;
}
auto lines = subsobj->ProcessingComplete(StrDisplay(c)); auto lines = subsobj->ProcessingComplete(StrDisplay(c));
@ -785,7 +791,8 @@ namespace {
if (lua_istable(L, -1)) { if (lua_istable(L, -1)) {
std::set<AssDialogue*> sel; std::set<AssDialogue*> sel;
lua_for_each(L, [&] { lua_for_each(L, [&] {
if (lua_isnumber(L, -1)) { if (!lua_isnumber(L, -1))
return;
int cur = lua_tointeger(L, -1); int cur = lua_tointeger(L, -1);
if (cur < 1 || cur > (int)lines.size()) { if (cur < 1 || cur > (int)lines.size()) {
wxLogError("Selected row %d is out of bounds (must be 1-%u)", cur, lines.size()); wxLogError("Selected row %d is out of bounds (must be 1-%u)", cur, lines.size());
@ -801,7 +808,6 @@ namespace {
sel.insert(diag); sel.insert(diag);
if (!active_line || active_idx == cur) if (!active_line || active_idx == cur)
active_line = diag; active_line = diag;
}
}); });
AssDialogue *new_active = c->selectionController->GetActiveLine(); AssDialogue *new_active = c->selectionController->GetActiveLine();
@ -839,11 +845,6 @@ namespace {
stackcheck.check_stack(0); stackcheck.check_stack(0);
} }
catch (agi::UserCancelException const&) {
subsobj->Cancel();
}
stackcheck.check_stack(0);
}
bool LuaCommand::IsActive(const agi::Context *c) bool LuaCommand::IsActive(const agi::Context *c)
{ {