]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Don't try to start/stop animation twice in a row
authorRay Strode <rstrode@redhat.com>
Thu, 30 Oct 2008 19:56:05 +0000 (15:56 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 30 Oct 2008 19:56:05 +0000 (15:56 -0400)
Protect against multiple calls to start/stop animation.
This prevents crashes if the user presses escape when
the animation is already stopped, and prevents
super fast animations if --show-splash gets called twice
in a row.

src/plugins/splash/fade-in/plugin.c
src/plugins/splash/pulser/plugin.c
src/plugins/splash/solar/plugin.c
src/plugins/splash/spinfinity/plugin.c
src/plugins/splash/text/plugin.c

index 7d595b3dc678ec70faa1028754ab3bbc794aca1b..e5101ad708cab21b0ed33f32ceaf4bdaae0f9d3f 100644 (file)
@@ -81,6 +81,8 @@ struct _ply_boot_splash_plugin
 
   double start_time;
   double now;
+
+  uint32_t is_animating : 1;
 };
 
 ply_boot_splash_plugin_t *
@@ -303,6 +305,9 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
     
+  if (plugin->is_animating)
+     return;
+
   ply_event_loop_watch_for_timeout (plugin->loop, 
                                     1.0 / FRAMES_PER_SECOND,
                                     (ply_event_loop_timeout_handler_t)
@@ -310,6 +315,8 @@ start_animation (ply_boot_splash_plugin_t *plugin)
 
   plugin->start_time = ply_get_timestamp ();
   draw_background (plugin, NULL);
+
+  plugin->is_animating = true;
 }
 
 static void
@@ -320,6 +327,11 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (!plugin->is_animating)
+     return;
+
+  plugin->is_animating = false;
+
   for (i = 0; i < 10; i++)
     {
       ply_frame_buffer_fill_with_hex_color_at_opacity (plugin->frame_buffer,
index d46ef349df3cb551245f99e49cfd474d0610a64b..089edb9dee519f7531c2090b3ec1886d25f2dd56 100644 (file)
@@ -67,6 +67,7 @@ struct _ply_boot_splash_plugin
   ply_text_pulser_t *pulser;
 
   uint32_t keyboard_input_is_hidden : 1;
+  uint32_t is_animating : 1;
 };
 void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
                          ply_event_loop_t         *loop);
@@ -119,6 +120,9 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (plugin->is_animating)
+     return;
+
   ply_window_set_color_hex_value (plugin->window,
                                   PLY_WINDOW_COLOR_BROWN,
                                   PLYMOUTH_BACKGROUND_END_COLOR);
@@ -142,6 +146,8 @@ start_animation (ply_boot_splash_plugin_t *plugin)
                          plugin->window,
                          window_width / 2.0 - width / 2.0,
                          window_height / 2.0 - height / 2.0);
+
+  plugin->is_animating = true;
 }
 
 static void
@@ -150,6 +156,11 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (!plugin->is_animating)
+     return;
+
+  plugin->is_animating = false;
+
   ply_text_pulser_stop (plugin->pulser);
 }
 
index 371ea84421a399233d0de0c0e9a6cf7b14f045eb..419f273969dbe1af1f6d89dceb2f7a72fdc36b25 100644 (file)
@@ -183,6 +183,7 @@ struct _ply_boot_splash_plugin
 
   uint32_t root_is_mounted : 1;
   uint32_t is_visible : 1;
+  uint32_t is_animating : 1;
 };
 
 static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
@@ -768,6 +769,9 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (plugin->is_animating)
+     return;
+
   ply_frame_buffer_get_size (plugin->frame_buffer, &area);
 
   plugin->now = ply_get_timestamp ();
@@ -775,6 +779,7 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   on_timeout (plugin);
   ply_window_draw_area (plugin->window, area.x, area.y, area.width, area.height);
 
+  plugin->is_animating = true;
 }
 
 static void
@@ -787,6 +792,11 @@ stop_animation (ply_boot_splash_plugin_t *plugin,
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (!plugin->is_animating)
+     return;
+
+  plugin->is_animating = false;
+
   if (plugin->loop != NULL)
     {
       ply_event_loop_stop_watching_for_timeout (plugin->loop,
@@ -805,7 +815,6 @@ stop_animation (ply_boot_splash_plugin_t *plugin,
       free_sprite (sprite);
     }
   ply_list_remove_all_nodes (plugin->sprites);
-
 }
 
 static void
index a55196f842b35e760ea91eab4e80d20f3f8a0751..b63e9b1a09a493d79234ac6b32309f18314be44b 100644 (file)
@@ -86,6 +86,7 @@ struct _ply_boot_splash_plugin
 
   uint32_t root_is_mounted : 1;
   uint32_t is_visible : 1;
+  uint32_t is_animating : 1;
 };
 
 static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
@@ -183,6 +184,9 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (plugin->is_animating)
+     return;
+
   draw_background (plugin, NULL);
   draw_logo (plugin);
 
@@ -198,6 +202,8 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   ply_progress_bar_show (plugin->progress_bar,
                          plugin->window,
                          0, area.height - ply_progress_bar_get_height (plugin->progress_bar));
+
+  plugin->is_animating = true;
 }
 
 static void
@@ -209,6 +215,11 @@ stop_animation (ply_boot_splash_plugin_t *plugin,
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (!plugin->is_animating)
+     return;
+
+  plugin->is_animating = false;
+
   ply_progress_bar_hide (plugin->progress_bar);
   ply_throbber_stop (plugin->throbber, trigger);
 
index 5e93da1e5cc5166370c959905c596a7e40b2ca52..500ca9126cc7d3ac04dcfbe81fdb85da96dcc2bc 100644 (file)
@@ -68,6 +68,7 @@ struct _ply_boot_splash_plugin
   ply_text_progress_bar_t *progress_bar;
 
   uint32_t keyboard_input_is_hidden : 1;
+  uint32_t is_animating : 1;
 };
 void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
                          ply_event_loop_t         *loop);
@@ -120,6 +121,9 @@ start_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (plugin->is_animating)
+     return;
+
   ply_window_set_color_hex_value (plugin->window,
                                   PLY_WINDOW_COLOR_BLACK,
                                   0x000000);
@@ -147,6 +151,8 @@ start_animation (ply_boot_splash_plugin_t *plugin)
 
   ply_text_progress_bar_show (plugin->progress_bar,
                               plugin->window);
+
+  plugin->is_animating = true;
 }
 
 static void
@@ -155,6 +161,12 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
   assert (plugin != NULL);
   assert (plugin->loop != NULL);
 
+  if (!plugin->is_animating)
+     return;
+
+  plugin->is_animating = false;
+
+
   ply_text_progress_bar_hide (plugin->progress_bar);
 }