[haiku-commits] haiku: hrev53486 - src/servers/app

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 14 Sep 2019 13:26:02 -0400 (EDT)

hrev53486 adds 1 changeset to branch 'master'
old head: 174a50869d85940edbd424260f0aa743657f3e19
new head: d46af3075e7b583d267bc86a526815c82d49d113
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=d46af3075e7b+%5E174a50869d85

----------------------------------------------------------------------------

d46af3075e7b: 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@xxxxxx>

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53486
Commit:      d46af3075e7b583d267bc86a526815c82d49d113
URL:         https://git.haiku-os.org/haiku/commit/?id=d46af3075e7b
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Sep 14 05:14:54 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Sep 14 17:25:58 2019 UTC

----------------------------------------------------------------------------

1 file changed, 15 insertions(+), 1 deletion(-)
src/servers/app/ServerWindow.cpp | 16 +++++++++++++++-

----------------------------------------------------------------------------

diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index fcc0f9a24b..8cc29442ca 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -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;
        }
 }


Other related posts:

  • » [haiku-commits] haiku: hrev53486 - src/servers/app - waddlesplash