[WK2] Fix location bug and crash issue for GoogleMap
authorSeonae Kim <sunaeluv.kim@samsung.com>
Wed, 22 Aug 2012 06:11:36 +0000 (15:11 +0900)
committerSeonae Kim <sunaeluv.kim@samsung.com>
Fri, 24 Aug 2012 03:55:06 +0000 (12:55 +0900)
[Title] Fix location bug and crash issue for GoogleMap
[Issue#] WEB-1617, WEB-1621
[Problem] 1. getCurrentPosition API returns 0,0
          2. Browser crashed while reloading web page
[Cause] 1. The result value of PositionChangedCallback is zero
        2. EwkGeolocation is not checked
[Solution] Add conditional statement to confirm the callback parameter

Change-Id: If48462c6a92f3e9e8ed06dfdf0b7a7c016443873

Source/WebKit2/UIProcess/API/efl/ewk_geolocation.cpp

index b883431..71533d2 100755 (executable)
@@ -47,6 +47,9 @@ struct _Ewk_Geolocation_Permission_Data {
 
 static void ewkGeolocationPositionChangedCallback(double latitude, double longitude, double altitude, time_t timestamp, void *user_data)
 {
+    if(!timestamp)
+        return;
+
     WKRetainPtr<WKGeolocationPositionRef> position(AdoptWK, WKGeolocationPositionCreate(timestamp, latitude, longitude, 0.0f));
     WKGeolocationManagerProviderDidChangePosition(static_cast<WKGeolocationManagerRef>(user_data), position.get());
 }
@@ -61,6 +64,9 @@ Ewk_Geolocation* ewkGeolocationCreateGeolocation()
 
 void ewkGeolocationDeleteGeolocation(Ewk_Geolocation* ewkGeolocation)
 {
+    if (ewkGeolocation->started)
+        ewkGeolocationStopLocationManager(ewkGeolocation);
+
     delete ewkGeolocation;
 }
 
@@ -82,6 +88,8 @@ void ewkGeolocationDeletePermission(Ewk_Geolocation_Permission_Data* permissionD
 
 bool ewkGeolocationStartLocationManager(WKGeolocationManagerRef geolocationManager, Ewk_Geolocation* ewkGeolocation)
 {
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkGeolocation, false);
+
     location_error_e ret = static_cast<location_error_e>(location_manager_create(LOCATIONS_METHOD_HYBRID, &ewkGeolocation->locationManager));
     if (ret != LOCATIONS_ERROR_NONE)
         return false;
@@ -105,6 +113,8 @@ bool ewkGeolocationStartLocationManager(WKGeolocationManagerRef geolocationManag
 
 void ewkGeolocationStopLocationManager(Ewk_Geolocation* ewkGeolocation)
 {
+    EINA_SAFETY_ON_NULL_RETURN(ewkGeolocation);
+
     if (!ewkGeolocation->started)
         return;
 
@@ -119,6 +129,8 @@ void ewkGeolocationStopLocationManager(Ewk_Geolocation* ewkGeolocation)
     ret = static_cast<location_error_e>(location_manager_destroy(ewkGeolocation->locationManager));
     if (ret != LOCATIONS_ERROR_NONE)
         return;
+
+    ewkGeolocation->started = false;
 }
 #endif