app_server: Catch drawing (AGG) allocation exceptions.

Since _DispatchViewDrawingMessage sends single B_ERROR replies
in a number of generic cases, doing so here is probably fine;
it's much better than crashing, anyway.

This is the generalized case of PulkoMandy's earlier patch,
which only applied to one drawing operation. This now affects
all AGG calls.

Change-Id: I751439e43cc300b964ac4cf41c48c1df30baf0a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1863
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
This commit is contained in:
Augustin Cavalier 2019-09-14 01:14:54 -04:00 committed by waddlesplash
parent 174a50869d
commit d46af3075e
1 changed files with 15 additions and 1 deletions

View File

@ -2451,7 +2451,21 @@ fDesktop->LockSingleWindow();
}
default:
_DispatchViewDrawingMessage(code, link);
// The drawing code handles allocation failures using exceptions;
// so we need to account for that here.
try {
_DispatchViewDrawingMessage(code, link);
} catch (std::bad_alloc&) {
// Cancel any message we were in the middle of sending.
fLink.CancelMessage();
if (link.NeedsReply()) {
// As done in _DispatchViewDrawingMessage, send just a
// single status_t as the reply.
fLink.StartMessage(B_NO_MEMORY);
fLink.Flush();
}
}
break;
}
}