elm_test: Fix bug in GLView test
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 14 Oct 2015 09:00:24 +0000 (18:00 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 14 Oct 2015 11:19:30 +0000 (20:19 +0900)
Scenario:
  const char * accel = accel_get();
  accel_set("gl:depth");

Now accel may not be valid anymore since the original
Eina_Stringshare might have been destroyed. So there was
no point in saving the const char * pointer. It was not valid
after the call to set(). This is a bit confusing here. Returning
char* would be clear: the caller would own the data.

src/bin/test_glview.c

index ceaf7cc..31c76cf 100644 (file)
@@ -624,7 +624,7 @@ test_glview(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
    gldata_init(gld);
 
    // add a Z-depth buffer to the window and try to use GL
-   accel = elm_config_accel_preference_get();
+   accel = eina_stringshare_add(elm_config_accel_preference_get());
    elm_config_accel_preference_set("gl:depth");
 
    // new window - do the usual and give it a name, title and delete handler
@@ -633,6 +633,7 @@ test_glview(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
 
    // restore previous accel preference
    elm_config_accel_preference_set(accel);
+   eina_stringshare_del(accel);
 
    bx = elm_box_add(win);
    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);