From d553bb1149800daf16dcb92bc0608fe6248e1dab Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 28 Jul 2020 10:58:34 -0400 Subject: root_menu move tag cache init check to pictureflow plugin let pictureflow decide if the tag cache is ready instead of core Change-Id: I2ab9b375d773dbbc28ea41fbf7bb6fb361ace8fd --- apps/plugins/pictureflow/pictureflow.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'apps/plugins/pictureflow') diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index ba3ae3018f..d1da10ee09 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -530,6 +530,26 @@ static void draw_progressbar(int step, int count, char *msg); static void draw_splashscreen(unsigned char * buf_tmp, size_t buf_tmp_size); static void free_all_slide_prio(int prio); +static bool check_database(bool prompt) +{ + bool needwarn = true; + struct tagcache_stat *stat = rb->tagcache_get_stat(); + while ( !(stat->initialized && stat->ready) ) + { + if (needwarn) + rb->splash(0, ID2P(LANG_TAGCACHE_BUSY)); + if (!prompt) + return false; + else if (rb->action_userabort(HZ/5)) + return false; + + needwarn = false; + stat = rb->tagcache_get_stat(); + rb->yield(); + } + return true; +} + static bool confirm_quit(void) { const struct text_message prompt = @@ -3821,6 +3841,17 @@ enum plugin_status plugin_start(const void *parameter) void * buf; size_t buf_size; + bool prompt = (parameter && ((char *) parameter)[0] == ACTIVITY_MAINMENU); + + if (!check_database(prompt)) + { + if (prompt) + return PLUGIN_OK; + else + error_wait("Please enable database"); + + return PLUGIN_ERROR; + } atexit(cleanup); -- cgit v1.2.3