safety for row stride calc failure
[framework/uifw/edbus.git] / src / lib / notification / notification.c
index d2c5b97..80e8844 100644 (file)
@@ -377,14 +377,26 @@ e_notification_image_new(void)
 EAPI Eina_Bool
 e_notification_image_init(E_Notification_Image *img, Evas_Object *obj)
 {
+   Eina_Bool rgb = EINA_TRUE;
    EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
-   evas_object_geometry_get(obj, NULL, NULL, &img->width, &img->height);
+   img->data = evas_object_image_data_convert(obj, EVAS_COLORSPACE_ARGB8888);
+   if (img->data) rgb = EINA_FALSE;
+   else img->data = evas_object_image_data_get(obj, EINA_FALSE);
+   if (!img->data) return EINA_FALSE;
+   evas_object_image_size_get(obj, &img->width, &img->height);
+   if ((!img->width) || (!img->height))
+     {
+        img->data = NULL;
+        img->width = img->height = 0;
+        return EINA_FALSE;
+     }
    img->has_alpha = !!evas_object_image_alpha_get(obj);
    img->channels = img->has_alpha ? 4 : 3;
    img->rowstride = evas_object_image_stride_get(obj);
-   img->data = evas_object_image_data_get(obj, EINA_FALSE);
-   evas_object_image_data_set(obj, img->data);
+   if (img->rowstride == 4 * img->width)
+     img->rowstride = img->channels * img->width;
+   if (rgb) evas_object_image_data_set(obj, img->data);
    return EINA_TRUE;
 }