]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[script] Default to text color alpha of 1 if nothing was passed
authorCharlie Brej <cbrej@cs.man.ac.uk>
Tue, 20 Apr 2010 13:00:01 +0000 (14:00 +0100)
committerCharlie Brej <cbrej@cs.man.ac.uk>
Tue, 20 Apr 2010 13:00:01 +0000 (14:00 +0100)
If NULL or no variable was passed, the aplha variable would be read as NaN
which gets clamped to 0 so the text would be completely transparent.

src/plugins/splash/script/script-lib-image.c

index b017dbdf8cc6411a08fe8c56e6c5352bc0503212..12c3278f35b44816648b4488096287786da52529 100644 (file)
@@ -163,19 +163,20 @@ static script_return_t image_text (script_state_t *state,
   
   char *text = script_obj_hash_get_string (state->local, "text");
   
-  /* These colour values are currently unused, but will be once label supports them */
+  float alpha;
   float red = CLAMP(script_obj_hash_get_number (state->local, "red"), 0, 1);
   float green = CLAMP(script_obj_hash_get_number (state->local, "green"), 0, 1);
   float blue = CLAMP(script_obj_hash_get_number (state->local, "blue"), 0, 1);
-  float alpha = 1;
 
   alpha_obj = script_obj_hash_peek_element (state->local, "alpha");
 
-  if (alpha_obj)
+  if (script_obj_is_number (alpha_obj))
     {
       alpha = CLAMP(script_obj_as_number (alpha_obj), 0, 1);
-      script_obj_unref(alpha_obj);
     }
+  else
+    alpha = 1;
+  script_obj_unref(alpha_obj);
 
   if (!text) return script_return_obj_null ();