bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/apps/extra.git/commit/?id=fe62d65bca504a7fddc23901b0f7486e8b5ee793

commit fe62d65bca504a7fddc23901b0f7486e8b5ee793
Author: Marcel Hollerbach <marcel-hollerb...@t-online.de>
Date:   Thu Feb 16 18:07:05 2017 +0100

    extra: only override progress if we are not muted
    
    otherwise we could never reach the done callback which wants to be
    waited for.
---
 src/bin/extra_util.c       |  1 +
 src/lib/extra.c            | 40 +++++++++++++++++++++++++++++++---------
 src/lib/extra_api_helper.c |  2 +-
 src/lib/extra_private.h    |  1 +
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/bin/extra_util.c b/src/bin/extra_util.c
index a2d6a83..834ff47 100644
--- a/src/bin/extra_util.c
+++ b/src/bin/extra_util.c
@@ -175,6 +175,7 @@ _small_preview_done_cb(void *data)
         evas_object_show(p->image);
         free(preview);
      }
+   p->req = NULL;
    evas_object_show(p->image);
    evas_object_hide(p->progress);
 }
diff --git a/src/lib/extra.c b/src/lib/extra.c
index 1aa19d2..42de822 100644
--- a/src/lib/extra.c
+++ b/src/lib/extra.c
@@ -19,6 +19,7 @@ Eina_List *_background_list = NULL;
 #define sec_strdup(v) v ? eina_strbuf_string_steal(v) : NULL
 
 void _extra_theme_cache_load();
+static Eina_Bool extra_request_may_override(Extra_Request *req, Extra_Progress 
*progress);
 
 #define GEN_FILE_NAME(buf, t) eina_strbuf_append_printf(buf, "%s-%d.edj", 
t->id, t->version);
 
@@ -420,7 +421,10 @@ extra_theme_preview_download(Extra_Progress *progress, 
Extra_Theme *theme)
 
    if (priv->preview)
      {
-        priv->preview->progress = *progress;
+        if (extra_request_may_override(priv->preview, progress))
+          return priv->preview;
+        else
+          return NULL;
      }
 
    remote = _extra_preview_remote_generate("themes", theme->id);
@@ -461,10 +465,12 @@ extra_theme_download(Extra_Progress *progress, 
Extra_Theme *theme)
    EINA_SAFETY_ON_NULL_RETURN_VAL(progress, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(theme, NULL);
 
-   if (priv->main)
+   if (priv->preview)
      {
-        priv->main->progress = *progress;
-        return priv->main;
+        if (extra_request_may_override(priv->preview, progress))
+          return priv->preview;
+        else
+          return NULL;
      }
 
    urlstr = extra_theme_download_url_get(theme);
@@ -685,10 +691,12 @@ extra_background_download(Extra_Progress *progress, 
Extra_Background *background
    EINA_SAFETY_ON_NULL_RETURN_VAL(progress, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(background, NULL);
 
-   if (priv->main)
+   if (priv->preview)
      {
-        memcpy(&priv->preview->progress, progress, sizeof(Extra_Progress));
-        return priv->main;
+        if (extra_request_may_override(priv->preview, progress))
+          return priv->preview;
+        else
+          return NULL;
      }
 
    urlstr = extra_background_download_url_get(background);
@@ -732,8 +740,10 @@ extra_background_preview_download(Extra_Progress 
*progress, Extra_Background *ba
 
    if (priv->preview)
      {
-        memcpy(&priv->preview->progress, progress, sizeof(Extra_Progress));
-        return priv->preview;
+        if (extra_request_may_override(priv->preview, progress))
+          return priv->preview;
+        else
+          return NULL;
      }
 
    remote = _extra_preview_remote_generate("backgrounds", background->id);
@@ -764,7 +774,19 @@ extra_request_mute(Extra_Request *req)
 {
    if(!req) return;
 
+   req->muted = EINA_TRUE;
+
    req->progress.data = NULL;
    req->progress.progress_cb = NULL;
    req->progress.done_cb = NULL;
 }
+
+static Eina_Bool
+extra_request_may_override(Extra_Request *req, Extra_Progress *progress)
+{
+   if (!req->muted) return EINA_FALSE;
+
+   memcpy(&req->progress, progress, sizeof(Extra_Progress));
+
+   return EINA_TRUE;
+}
diff --git a/src/lib/extra_api_helper.c b/src/lib/extra_api_helper.c
index b03f7fd..fc3bd3f 100644
--- a/src/lib/extra_api_helper.c
+++ b/src/lib/extra_api_helper.c
@@ -274,7 +274,7 @@ _download_check_progress_cb(void *data EINA_UNUSED, const 
char *file,
      }
    else
      {
-        INF("Everything is ok\n");
+        INF("Everything is ok %s %ld\n", file, dltotal);
         ecore_file_download_abort(job->cache);
         _download_job_free(job);
      }
diff --git a/src/lib/extra_private.h b/src/lib/extra_private.h
index 9412489..02be01f 100644
--- a/src/lib/extra_private.h
+++ b/src/lib/extra_private.h
@@ -40,6 +40,7 @@ typedef struct {
 
 struct _Extra_Request
 {
+   Eina_Bool muted;
    Extra_Progress progress;
 };
 

-- 


Reply via email to