[california/wip/727860-rgb-string] Proposed fix
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/727860-rgb-string] Proposed fix
- Date: Sat, 12 Apr 2014 02:33:07 +0000 (UTC)
commit 8aa424a6d1f19f547205c37df76acb4ae656058c
Author: Jim Nelson <jim yorba org>
Date: Fri Apr 11 19:32:44 2014 -0700
Proposed fix
src/util/util-gfx.vala | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/util/util-gfx.vala b/src/util/util-gfx.vala
index 53e09d5..e9c83a5 100644
--- a/src/util/util-gfx.vala
+++ b/src/util/util-gfx.vala
@@ -16,7 +16,13 @@ public const Gdk.RGBA RGBA_BLACK = { 0.0, 0.0, 0.0, 0.0 };
* The string can be in any of the forms that Gdk.Color.parse accepts. If unable to parse the
* string, the { link default_rgb} is returned and { link used_default} is set to true.
*/
-public Gdk.Color rgb_string_to_rgb(string rgb_string, Gdk.Color default_rgb, out bool used_default) {
+public Gdk.Color rgb_string_to_rgb(string? rgb_string, Gdk.Color default_rgb, out bool used_default) {
+ if (String.is_empty(rgb_string)) {
+ used_default = true;
+
+ return default_rgb;
+ }
+
Gdk.Color rgb;
if (!Gdk.Color.parse(rgb_string, out rgb)) {
debug("Unable to parse RGB color \"%s\"", rgb_string);
@@ -37,7 +43,13 @@ public Gdk.Color rgb_string_to_rgb(string rgb_string, Gdk.Color default_rgb, out
* The string can be in any of the forms that Gdk.Color.parse accepts. If unable to parse the
* string, the { link default_rgba} is returned and { link used_default} is set to true.
*/
-public Gdk.RGBA rgb_string_to_rgba(string rgb_string, Gdk.RGBA default_rgba, out bool used_default) {
+public Gdk.RGBA rgb_string_to_rgba(string? rgb_string, Gdk.RGBA default_rgba, out bool used_default) {
+ if (String.is_empty(rgb_string)) {
+ used_default = true;
+
+ return default_rgba;
+ }
+
Gdk.Color rgb;
if (!Gdk.Color.parse(rgb_string, out rgb)) {
debug("Unable to parse RGB color \"%s\"", rgb_string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]