summary refs log tree commit diff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-04-23 19:05:54 -0400
committerJoseph Donofry <joedonofry@gmail.com>2020-04-23 19:05:54 -0400
commit87c06f0fc9098831b80830bc69b230da379a498d (patch)
tree7024eb9c93f644ed91d1a0df3537ec646e06f0e3 /src/Utils.cpp
parentChange how decrypt value is retrieved from settings (diff)
parentMerge branch 'master' into decrypt-sidebar (diff)
downloadnheko-87c06f0fc9098831b80830bc69b230da379a498d.tar.xz
Merge branch 'decrypt-sidebar' of ssh://github.com/Nheko-Reborn/nheko into decrypt-sidebar
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index 46472401..cd615c24 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -541,6 +541,7 @@ utils::generateContrastingHexColor(const QString &input, const QString &backgrou // If the contrast doesn't meet our criteria, // try again and again until they do by modifying first // the lightness and then the saturation of the color. + int iterationCount = 9; while (contrast < 5) { // if our lightness is at it's bounds, try changing // saturation instead. @@ -587,6 +588,11 @@ utils::generateContrastingHexColor(const QString &input, const QString &backgrou } } } + + // don't loop forever, just give up at some point! + // Someone smart may find a better solution + if (--iterationCount < 0) + break; } // get the hex value of the generated color.