plugins: load view of hot plugged displays immediately

If we're already chugging along, and a new display
gets added make sure to load the view associated with
that display right away.

Using an unloaded view can lead to crashes.
This commit is contained in:
Ray Strode 2015-09-24 15:57:59 -04:00
parent 8d07bfd434
commit 74346ec268
6 changed files with 45 additions and 6 deletions

View file

@ -104,6 +104,7 @@ struct _ply_boot_splash_plugin
double now;
uint32_t is_animating : 1;
uint32_t is_visible : 1;
};
ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
@ -751,7 +752,14 @@ add_pixel_display (ply_boot_splash_plugin_t *plugin,
(ply_pixel_display_draw_handler_t)
on_draw, view);
ply_list_append_data (plugin->views, view);
if (plugin->is_visible) {
if (view_load (view))
ply_list_append_data (plugin->views, view);
else
view_free (view);
} else {
ply_list_append_data (plugin->views, view);
}
}
static void
@ -811,6 +819,8 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
return false;
}
plugin->is_visible = true;
ply_trace ("starting boot animation");
start_animation (plugin);
@ -945,6 +955,8 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
{
assert (plugin != NULL);
plugin->is_visible = false;
if (plugin->loop != NULL) {
stop_animation (plugin);

View file

@ -1387,7 +1387,14 @@ add_pixel_display (ply_boot_splash_plugin_t *plugin,
(ply_pixel_display_draw_handler_t)
on_draw, view);
ply_list_append_data (plugin->views, view);
if (plugin->is_visible) {
if (view_load (view))
ply_list_append_data (plugin->views, view);
else
view_free (view);
} else {
ply_list_append_data (plugin->views, view);
}
}
static void

View file

@ -471,7 +471,8 @@ add_text_display (ply_boot_splash_plugin_t *plugin,
(ply_text_display_draw_handler_t)
on_draw, view);
ply_list_append_data (plugin->views, view);
if (plugin->is_animating)
view_start_animation (view);
}
static void

View file

@ -625,7 +625,14 @@ add_pixel_display (ply_boot_splash_plugin_t *plugin,
(ply_pixel_display_draw_handler_t)
on_draw, view);
ply_list_append_data (plugin->views, view);
if (plugin->is_visible) {
if (view_load (view))
ply_list_append_data (plugin->views, view);
else
view_free (view);
} else {
ply_list_append_data (plugin->views, view);
}
}
static void

View file

@ -478,6 +478,9 @@ add_text_display (ply_boot_splash_plugin_t *plugin,
on_draw, view);
ply_list_append_data (plugin->views, view);
if (plugin->is_animating)
view_start_animation (view);
}
static void
@ -559,7 +562,9 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
next_node = ply_list_get_next_node (plugin->views, node);
ply_text_progress_bar_set_percent_done (view->progress_bar, percent_done);
ply_text_progress_bar_draw (view->progress_bar);
if (plugin->is_animating)
ply_text_progress_bar_draw (view->progress_bar);
node = next_node;
}

View file

@ -995,7 +995,14 @@ add_pixel_display (ply_boot_splash_plugin_t *plugin,
ply_pixel_display_set_draw_handler (view->display,
(ply_pixel_display_draw_handler_t)
on_draw, view);
ply_list_append_data (plugin->views, view);
if (plugin->is_visible) {
if (view_load (view))
ply_list_append_data (plugin->views, view);
else
view_free (view);
} else {
ply_list_append_data (plugin->views, view);
}
}
static void