Catch an exception when initializing JSWidget
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Fri, 23 Nov 2012 08:55:18 +0000 (09:55 +0100)
committerGerrit Code Review <gerrit2@kim11>
Fri, 23 Nov 2012 11:43:55 +0000 (20:43 +0900)
[Issue#] TWEB-427
[Feature] There can be exception when JSWidget tries to initializes
preferences object.
[Cause] WebProcess gets SIGABORT when initialize fails.
[Solution] Catch an exception. Allow to run normally.

[Verification] Run iframes.wgt widget from wrt-extra repository.
WebProcess should not fail when counter in widget hits ~160.
Verification requires patch from wrt-commons:
http://tizendev.org/gerrit/15863

Change-Id: Iaf9f5963d4a84cd9d518a7db1d57d350e8f64d46

src/standards/W3C/Widget/JSWidget.cpp

index fdb70ba..9daec95 100644 (file)
@@ -279,6 +279,10 @@ void JSWidget::initialize(JSContextRef context,
             LogError("You should register widget id in ON_WIDGET_START");
             return;
         }
+        Catch(DPL::Exception) {
+            LogError("Failed to create private object for JSWidget");
+            return;
+        }
 
     }
 }
@@ -286,14 +290,19 @@ void JSWidget::initialize(JSContextRef context,
 void JSWidget::finalize(JSObjectRef object)
 {
     LogDebug("entered");
+    LogDebug("Object: " << object);
     JSWidgetPrivateObject* priv =
         static_cast<JSWidgetPrivateObject*>(JSObjectGetPrivate(object));
 
-    JSValueUnprotect(priv->getContext(),
-                     priv->getObject()->preferencesObject);
+    if (priv) {
+        JSValueUnprotect(priv->getContext(),
+                         priv->getObject()->preferencesObject);
 
-    delete priv;
-    LogDebug("private object is released");
+        delete priv;
+        LogDebug("private object is released");
+    } else {
+        LogDebug("private object wasn't created");
+    }
 }
 
 void JSWidget::acquireGlobalContext(java_script_context_t global_context,