diff options
author | Neil <nyamatongwe@gmail.com> | 2022-12-09 14:20:43 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2022-12-09 14:20:43 +1100 |
commit | 1c56d4698f60e82c2f7c0a0a9a7d2a9ae1efdce4 (patch) | |
tree | a23890a80a7ad26da551478741f21e24a613e101 /src/ViewStyle.cxx | |
parent | 9ed25fbd994d700d0f059a56844c3f170a77d2a3 (diff) | |
download | scintilla-mirror-1c56d4698f60e82c2f7c0a0a9a7d2a9ae1efdce4.tar.gz |
More safety for potentially empty unwraps with ElementColourForced returning a
ColourRGBA which is opaque black if the element not found.
Diffstat (limited to 'src/ViewStyle.cxx')
-rw-r--r-- | src/ViewStyle.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 19a7b5275..b8fe0c0d6 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -617,6 +617,15 @@ ColourOptional ViewStyle::ElementColour(Element element) const { return {}; } +ColourRGBA ViewStyle::ElementColourForced(Element element) const { + // Like ElementColour but never returns empty - when not found return opaque black. + // This method avoids warnings for unwrapping potentially empty optionals from + // Visual C++ Code Analysis + const ColourOptional colour = ElementColour(element); + constexpr ColourRGBA opaqueBlack(0, 0, 0, 0xff); + return colour.value_or(opaqueBlack); +} + bool ViewStyle::ElementAllowsTranslucent(Element element) const { return elementAllowsTranslucent.count(element) > 0; } |