[EFL][WK2] Free ewk context data on program exit.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 18:02:34 +0000 (18:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 18:02:34 +0000 (18:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94808

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-08-23
Reviewed by Kenneth Rohde Christiansen.

Make sure the default Ewk_Context gets freed
on program exit.

The patch also fixes leaking of WKContextRef
inside Ewk_Context which should have been
adopted.

* UIProcess/API/efl/ewk_context.cpp:
(_Ewk_Context::_Ewk_Context):
(ewk_context_default_get):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126448 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/ewk_context.cpp

index e0461a0..a8d8b32 100644 (file)
@@ -1,3 +1,21 @@
+2012-08-23  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [EFL][WK2] Free ewk context data on program exit.
+        https://bugs.webkit.org/show_bug.cgi?id=94808
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Make sure the default Ewk_Context gets freed
+        on program exit.
+
+        The patch also fixes leaking of WKContextRef
+        inside Ewk_Context which should have been
+        adopted.
+
+        * UIProcess/API/efl/ewk_context.cpp:
+        (_Ewk_Context::_Ewk_Context):
+        (ewk_context_default_get):
+
 2012-08-23  Adrienne Walker  <enne@google.com>
 
         Convert ScrollableArea ASSERT_NOT_REACHED virtuals
index d645375..71504f6 100644 (file)
@@ -70,18 +70,18 @@ struct _Ewk_Context {
     WKRetainPtr<WKSoupRequestManagerRef> requestManager;
     URLSchemeHandlerMap urlSchemeHandlers;
 
-    _Ewk_Context(WKContextRef contextRef)
+    _Ewk_Context(WKRetainPtr<WKContextRef> contextRef)
         : context(contextRef)
         , cookieManager(0)
-        , requestManager(WKContextGetSoupRequestManager(contextRef))
+        , requestManager(WKContextGetSoupRequestManager(contextRef.get()))
     {
 #if ENABLE(BATTERY_STATUS)
-        WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(contextRef);
+        WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(contextRef.get());
         batteryProvider = BatteryProvider::create(wkBatteryManager);
 #endif
 
 #if ENABLE(VIBRATION)
-        WKVibrationRef wkVibrationRef = WKContextGetVibration(contextRef);
+        WKVibrationRef wkVibrationRef = WKContextGetVibration(contextRef.get());
         vibrationProvider = VibrationProvider::create(wkVibrationRef);
 #endif
 
@@ -198,16 +198,11 @@ void ewk_context_url_scheme_request_received(Ewk_Context* ewkContext, Ewk_Url_Sc
     handler.callback(schemeRequest, handler.userData);
 }
 
-static inline Ewk_Context* createDefaultEwkContext()
-{
-    return new Ewk_Context(WKContextCreate());
-}
-
 Ewk_Context* ewk_context_default_get()
 {
-    static Ewk_Context* defaultContext = createDefaultEwkContext();
+    static Ewk_Context defaultContext(adoptWK(WKContextCreate()));
 
-    return defaultContext;
+    return &defaultContext;
 }
 
 Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData)