okra pushed a commit to branch master.

http://git.enlightenment.org/apps/ephoto.git/commit/?id=94fddb9f36b0e4a35495476ede54751d2418689a

commit 94fddb9f36b0e4a35495476ede54751d2418689a
Author: Stephen Houston <stephen@lenovo.fedora>
Date:   Tue Apr 5 19:30:25 2016 -0500

    Ephoto: Work around some bugs with editing.
---
 src/bin/ephoto.h                |  8 +++---
 src/bin/ephoto_bcg.c            | 11 ++++----
 src/bin/ephoto_color.c          | 11 ++++----
 src/bin/ephoto_cropper.c        |  4 +--
 src/bin/ephoto_filters.c        | 10 ++++----
 src/bin/ephoto_hsv.c            | 11 ++++----
 src/bin/ephoto_red_eye.c        | 22 ++++++++++------
 src/bin/ephoto_single_browser.c | 57 +++++++++++++++++++++++------------------
 8 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h
index cf7170b..54ce1de 100644
--- a/src/bin/ephoto.h
+++ b/src/bin/ephoto.h
@@ -76,10 +76,10 @@ void ephoto_single_browser_path_pending_set(Evas_Object 
*obj,
 void ephoto_single_browser_path_pending_unset(Evas_Object *obj);
 void ephoto_single_browser_path_created(Evas_Object *obj, Ephoto_Entry *entry);
 void ephoto_single_browser_image_data_update(Evas_Object *main,
-    Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w,
-    int h);
-void ephoto_single_browser_cancel_editing(Evas_Object *main,
-    Evas_Object *image);
+    Evas_Object *image, unsigned int *image_data, int w, int h);
+void ephoto_single_browser_image_data_done(Evas_Object *main,
+    unsigned int *image_data, int w, int h);
+void ephoto_single_browser_cancel_editing(Evas_Object *main);
 /* smart callbacks called: "back" - the user wants to go back to the previous
  * screen. */
 
diff --git a/src/bin/ephoto_bcg.c b/src/bin/ephoto_bcg.c
index 5e92640..3204cf5 100644
--- a/src/bin/ephoto_bcg.c
+++ b/src/bin/ephoto_bcg.c
@@ -92,7 +92,7 @@ _ephoto_bcg_adjust_brightness(Ephoto_BCG *ebcg, int 
brightness,
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image,
        im_data_new, ebcg->w, ebcg->h);
    free(im_data);
    return im_data_new;
@@ -147,7 +147,7 @@ _ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast,
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image,
        im_data_new, ebcg->w, ebcg->h);
    free(im_data);
    return im_data_new;
@@ -198,7 +198,7 @@ _ephoto_bcg_adjust_gamma(Ephoto_BCG *ebcg, double gamma,
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image,
        im_data_new, ebcg->w, ebcg->h);
    free(im_data);
    return im_data_new;
@@ -278,8 +278,7 @@ _bcg_apply(void *data, int type EINA_UNUSED,
        evas_object_image_data_get(elm_image_object_get(ebcg->image),
        EINA_FALSE);
    evas_object_image_size_get(elm_image_object_get(ebcg->image), &w, &h);
-   ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_TRUE,
-       image_data, w, h);
+   ephoto_single_browser_image_data_done(ebcg->main, image_data, w, h);
    ephoto_editor_del(ebcg->editor);
 
    return ECORE_CALLBACK_PASS_ON;
@@ -298,7 +297,7 @@ _bcg_cancel(void *data, int type EINA_UNUSED,
    ebcg->contrast = 0;
    ebcg->gamma = 1;
    _brightness_slider_changed(ebcg, ebcg->bslider, NULL);
-   ephoto_single_browser_cancel_editing(ebcg->main, ebcg->image);
+   ephoto_single_browser_cancel_editing(ebcg->main);
    ephoto_editor_del(ebcg->editor);
 
    return ECORE_CALLBACK_PASS_ON;
diff --git a/src/bin/ephoto_color.c b/src/bin/ephoto_color.c
index 73ddc70..282365f 100644
--- a/src/bin/ephoto_color.c
+++ b/src/bin/ephoto_color.c
@@ -89,7 +89,7 @@ _ephoto_color_adjust_red(Ephoto_Color *eco, int red, unsigned 
int *image_data)
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(eco->main, eco->image,
        im_data_new, eco->w, eco->h);
    free(im_data);
    return im_data_new;
@@ -138,7 +138,7 @@ _ephoto_color_adjust_green(Ephoto_Color *eco, int green,
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(eco->main, eco->image,
        im_data_new, eco->w, eco->h);
    free(im_data);
    return im_data_new;
@@ -187,7 +187,7 @@ _ephoto_color_adjust_blue(Ephoto_Color *eco, int blue,
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(eco->main, eco->image,
        im_data_new, eco->w, eco->h);
    free(im_data);
    return im_data_new;
@@ -263,8 +263,7 @@ _color_apply(void *data, int type EINA_UNUSED,
        evas_object_image_data_get(elm_image_object_get(eco->image),
            EINA_FALSE);
    evas_object_image_size_get(elm_image_object_get(eco->image), &w, &h);
-   ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE,
-       image_data, w, h);
+   ephoto_single_browser_image_data_done(eco->main, image_data, w, h);
    ephoto_editor_del(eco->editor);
 
    return ECORE_CALLBACK_PASS_ON;
@@ -283,7 +282,7 @@ _color_cancel(void *data, int type EINA_UNUSED,
    eco->green = 0;
    eco->blue = 0;
    _red_slider_changed(eco, eco->rslider, NULL);
-   ephoto_single_browser_cancel_editing(eco->main, eco->image);
+   ephoto_single_browser_cancel_editing(eco->main);
    ephoto_editor_del(eco->editor);
 
    return ECORE_CALLBACK_PASS_ON;
diff --git a/src/bin/ephoto_cropper.c b/src/bin/ephoto_cropper.c
index 10d89bd..61f0634 100644
--- a/src/bin/ephoto_cropper.c
+++ b/src/bin/ephoto_cropper.c
@@ -220,7 +220,7 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED,
    elm_table_unpack(ec->image_parent, ec->box);
    elm_layout_content_unset(ec->layout, "ephoto.swallow.image");
    elm_table_pack(ec->image_parent, ec->image, 0, 0, 1, 1);
-   ephoto_single_browser_image_data_update(ec->main, ec->image, EINA_TRUE,
+   ephoto_single_browser_image_data_done(ec->main,
        idata_new, nw, nh);
    evas_object_del(ec->cropper);
    evas_object_del(ec->layout);
@@ -237,7 +237,7 @@ _cancel_crop(void *data, Evas_Object *obj EINA_UNUSED,
    elm_table_unpack(ec->image_parent, ec->box);
    elm_layout_content_unset(ec->layout, "ephoto.swallow.image");
    elm_table_pack(ec->image_parent, ec->image, 0, 0, 1, 1);
-   ephoto_single_browser_cancel_editing(ec->main, ec->image);
+   ephoto_single_browser_cancel_editing(ec->main);
    evas_object_del(ec->cropper);
    evas_object_del(ec->layout);
    evas_object_del(ec->box);
diff --git a/src/bin/ephoto_filters.c b/src/bin/ephoto_filters.c
index 0b99ba2..aac912d 100644
--- a/src/bin/ephoto_filters.c
+++ b/src/bin/ephoto_filters.c
@@ -120,7 +120,7 @@ ephoto_filter_blur(Evas_Object *main, Evas_Object *image)
    free(gs);
    free(bs);
 
-   ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
+   ephoto_single_browser_image_data_update(main, image, im_data_new,
        w, h);
 }
 
@@ -175,7 +175,7 @@ ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image)
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
+   ephoto_single_browser_image_data_update(main, image, im_data_new,
        w, h);
 }
 
@@ -205,7 +205,7 @@ ephoto_filter_black_and_white(Evas_Object *main, 
Evas_Object *image)
           gray = (gray * a) / 255;
        im_data_new[i] = (a << 24) | (gray << 16) | (gray << 8) | gray;
      }
-   ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
+   ephoto_single_browser_image_data_update(main, image, im_data_new,
        w, h);
 }
 
@@ -239,7 +239,7 @@ ephoto_filter_old_photo(Evas_Object *main, Evas_Object 
*image)
        rr = _demul_color_alpha(rr, a);
        im_data_new[i] = (a << 24) | (rr << 16) | (gg << 8) | bb;
      }
-   ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
+   ephoto_single_browser_image_data_update(main, image, im_data_new,
        w, h);
 }
 
@@ -310,6 +310,6 @@ ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object 
*image)
             p1++;
          }
      }
-   ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
+   ephoto_single_browser_image_data_update(main, image, im_data_new,
        w, h);
 }
diff --git a/src/bin/ephoto_hsv.c b/src/bin/ephoto_hsv.c
index a25d4e2..cfa7a02 100644
--- a/src/bin/ephoto_hsv.c
+++ b/src/bin/ephoto_hsv.c
@@ -96,7 +96,7 @@ _ephoto_hsv_adjust_hue(Ephoto_HSV *ehsv, double hue, unsigned 
int *image_data)
          }
      }
    ehsv->hue = hue;
-   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image,
        im_data_new, ehsv->w, ehsv->h);
    free(im_data);
    return im_data_new;
@@ -152,7 +152,7 @@ _ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double 
saturation,
          }
      }
    ehsv->saturation = saturation;
-   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image,
        im_data_new, ehsv->w, ehsv->h);
    free(im_data);
    return im_data_new;
@@ -208,7 +208,7 @@ _ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value,
          }
      }
    ehsv->value = value;
-   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image,
        im_data_new, ehsv->w, ehsv->h);
    free(im_data);
    return im_data_new;
@@ -285,8 +285,7 @@ _hsv_apply(void *data, int type EINA_UNUSED,
        evas_object_image_data_get(elm_image_object_get(ehsv->image),
        EINA_FALSE);
    evas_object_image_size_get(elm_image_object_get(ehsv->image), &w, &h);
-   ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_TRUE,
-       image_data, w, h);
+   ephoto_single_browser_image_data_done(ehsv->main, image_data, w, h);
    ephoto_editor_del(ehsv->editor);
 
    return ECORE_CALLBACK_PASS_ON;
@@ -305,7 +304,7 @@ _hsv_cancel(void *data, int type EINA_UNUSED,
    ehsv->saturation = 0;
    ehsv->value = 0;
    _hue_slider_changed(ehsv, ehsv->hslider, NULL);
-   ephoto_single_browser_cancel_editing(ehsv->main, ehsv->image);
+   ephoto_single_browser_cancel_editing(ehsv->main);
    ephoto_editor_del(ehsv->editor);
 
    return ECORE_CALLBACK_PASS_ON;
diff --git a/src/bin/ephoto_red_eye.c b/src/bin/ephoto_red_eye.c
index 5f48f35..b1215df 100644
--- a/src/bin/ephoto_red_eye.c
+++ b/src/bin/ephoto_red_eye.c
@@ -113,7 +113,7 @@ _reye_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED,
           }
      }
    er->edited_im_data = im_data_new;
-   ephoto_single_browser_image_data_update(er->main, er->image, EINA_FALSE,
+   ephoto_single_browser_image_data_update(er->main, er->image,
        im_data_new, er->w, er->h);
    free(im_data);
 }
@@ -134,8 +134,12 @@ _reye_reset(void *data, int type EINA_UNUSED,
 
    elm_slider_value_set(er->rslider, 15);
    er->rad = 15;
-
-   ephoto_single_browser_image_data_update(er->main, er->image, EINA_FALSE,
+   if (er->edited_im_data)
+     {
+        free(er->edited_im_data);
+        er->edited_im_data = NULL;
+     }
+   ephoto_single_browser_image_data_update(er->main, er->image,
        er->original_im_data, er->w, er->h);
 
    return ECORE_CALLBACK_PASS_ON;
@@ -153,8 +157,7 @@ _reye_apply(void *data, int type EINA_UNUSED,
        evas_object_image_data_get(elm_image_object_get(er->image),
            EINA_FALSE);
    evas_object_image_size_get(elm_image_object_get(er->image), &w, &h);
-   ephoto_single_browser_image_data_update(er->main, er->image, EINA_TRUE,
-       image_data, w, h);
+   ephoto_single_browser_image_data_done(er->main, image_data, w, h);
    ephoto_editor_del(er->editor);
 
    return ECORE_CALLBACK_PASS_ON;
@@ -169,9 +172,12 @@ _reye_cancel(void *data, int type EINA_UNUSED,
    elm_slider_value_set(er->rslider, 15);
    er->rad = 15;
 
-   ephoto_single_browser_image_data_update(er->main, er->image, EINA_FALSE,
-       er->original_im_data, er->w, er->h);
-   ephoto_single_browser_cancel_editing(er->main, er->image);
+   ephoto_single_browser_cancel_editing(er->main);
+   if (er->edited_im_data)
+     {
+        free(er->edited_im_data);
+        er->edited_im_data = NULL;
+     }
    ephoto_editor_del(er->editor);
 
    return ECORE_CALLBACK_PASS_ON;
diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c
index 4c7a846..0e9bb92 100644
--- a/src/bin/ephoto_single_browser.c
+++ b/src/bin/ephoto_single_browser.c
@@ -1803,57 +1803,64 @@ ephoto_single_browser_path_created(Evas_Object *obj, 
Ephoto_Entry *entry)
 
 void
 ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image,
-    Eina_Bool finished, unsigned int *image_data, int w, int h)
+    unsigned int *image_data, int w, int h)
 {
    Ephoto_Single_Browser *sb = evas_object_data_get(main, "single_browser");
 
    if (sb->editing)
      {
-       if (sb->cropping)
-         {
-            evas_object_image_size_set(elm_image_object_get(image), w, h);
-            sb->cropping = EINA_FALSE;
-         }
        evas_object_image_data_set(elm_image_object_get(image), image_data);
        evas_object_image_data_update_add(elm_image_object_get(image), 0, 0, w,
            h);
+     }
+}
 
-       if (finished)
-         {
-             _update_bottom_bar(sb);
-            sb->edited_image_data = image_data;
-            sb->ew = w;
-            sb->eh = h;
-            sb->editing = EINA_FALSE;
-            _zoom_fit(sb);
-         }
+void
+ephoto_single_browser_image_data_done(Evas_Object *main,
+    unsigned int *image_data, int w, int h)
+{
+   Ephoto_Single_Browser *sb = evas_object_data_get(main, "single_browser");
+
+   if (sb->editing)
+     {
+        _ephoto_single_browser_recalc(sb);
+        Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
+        if (sb->cropping)
+             sb->cropping = EINA_FALSE;
+        evas_object_image_size_set(elm_image_object_get(v->image), w, h);
+        evas_object_image_data_set(elm_image_object_get(v->image), image_data);
+        evas_object_image_data_update_add(elm_image_object_get(v->image), 0, 
0, w,
+            h);
+
+        _update_bottom_bar(sb);
+        sb->edited_image_data = image_data;
+        sb->ew = w;
+        sb->eh = h;
+        sb->editing = EINA_FALSE;
+        _zoom_fit(sb);
      }
 }
 
 void
-ephoto_single_browser_cancel_editing(Evas_Object *main, Evas_Object *image)
+ephoto_single_browser_cancel_editing(Evas_Object *main)
 {
    Ephoto_Single_Browser *sb = evas_object_data_get(main, "single_browser");
 
    if (sb->editing)
      {
+        _ephoto_single_browser_recalc(sb);
+        Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
        if (sb->cropping)
           sb->cropping = EINA_FALSE;
        if (sb->edited_image_data)
          {
-            evas_object_image_size_set(elm_image_object_get(image), sb->ew,
+            evas_object_image_size_set(elm_image_object_get(v->image), sb->ew,
                 sb->eh);
-            evas_object_image_data_set(elm_image_object_get(image),
+            evas_object_image_data_set(elm_image_object_get(v->image),
                 sb->edited_image_data);
-            evas_object_image_data_update_add(elm_image_object_get(image), 0,
+            evas_object_image_data_update_add(elm_image_object_get(v->image), 
0,
                 0, sb->ew, sb->eh);
          }
-        else
-         {
-            const char *group = _get_edje_group(sb->entry->path);
-             elm_image_file_set(image, sb->entry->path, group);
-         }
-
        sb->editing = EINA_FALSE;
        _zoom_fit(sb);
      }

-- 


Reply via email to