ecore_wl2_window: copy available rotation info.
authorHosang Kim <hosang12.kim@samsung.com>
Wed, 27 May 2020 14:05:30 +0000 (10:05 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 31 May 2020 21:33:06 +0000 (06:33 +0900)
Summary:
ecore_wl2_window doesn't copy rotation information.
If passed pointer is destroyed, rotation information disappears.
So add memory allocating for managing information.

Reviewers: CHAN, devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11891

src/lib/ecore_wl2/ecore_wl2_window.c

index 711539f..d522977 100644 (file)
@@ -1341,6 +1341,9 @@ ecore_wl2_window_free(Ecore_Wl2_Window *window)
    window->input_region = NULL;
    //
 
+   if (window->wm_rot.available_rots) free(window->wm_rot.available_rots);
+   window->wm_rot.available_rots = NULL;
+
    display->windows =
      eina_inlist_remove(display->windows, EINA_INLIST_GET(window));
 
@@ -2330,13 +2333,28 @@ ecore_wl2_window_preferred_rotation_get(Ecore_Wl2_Window *window)
 EAPI void
 ecore_wl2_window_available_rotations_set(Ecore_Wl2_Window *window, const int *rots, unsigned int count)
 {
+   unsigned int i = 0;
    EINA_SAFETY_ON_NULL_RETURN(window);
 
    // TIZEN_ONLY
    _tizen_rotation_available_angles_set(window, rots, count);
    //
+
+   if (window->wm_rot.available_rots)
+     {
+        free(window->wm_rot.available_rots);
+        window->wm_rot.available_rots = NULL;
+     }
    window->wm_rot.count = count;
-   window->wm_rot.available_rots = (int *)rots;
+
+   if (count >= 1)
+     {
+        window->wm_rot.available_rots = calloc(count, sizeof(int));
+        if (!window->wm_rot.available_rots) return;
+
+        for (; i < count; i++)
+          window->wm_rot.available_rots[i] = ((int *)rots)[i];
+     }
 }
 
 EAPI Eina_Bool