[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: RFR: JDK-8313164: src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp GetRGBPixels
From:       Alexey Ivanov <aivanov () openjdk ! org>
Date:       2023-07-28 12:14:03
Message-ID: NMSKzc_wcpgVS0eSK5uy76LSHGCR6iq9aCsEiN9ObnA=.53f26d77-f438-44c4-a5df-b8c522a20491 () github ! com
[Download RAW message or body]

On Fri, 28 Jul 2023 08:02:22 GMT, Matthias Baesken <mbaesken@openjdk.org> wrote:

> > src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp line 207:
> > 
> > > 205:         ::DeleteDC(hdcScreen);
> > > 206:         throw std::bad_alloc();
> > > 207:     }
> > 
> > I wonder if we can catch `std::bad_alloc` to release the resources and to \
> > re-throw the exception. 
> > Since a C++ exception is thrown, using try-catch for clean-up seems reasonable, \
> > this would avoid duplicating the clean-up code in three places or so.
> 
> Hi Alexey,  probably we could do this. Do you think it is worth the effort (we \
> would have a big try catch block instead, but would centralize the  ::Delete* \
> calls) ?

Since you've already integrated, it's not worth redoing in my opinion.

Error handling in C and C++ code is always prone to repetitive sequence of calls; in \
this particular case exceptions are already used, and it looks that handling that \
exception could have had a benefit of reducing code duplication.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15038#discussion_r1277472496


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic