[CB-4905] CordovaJS on Windows8 has memoryleak on exec.js
diff --git a/lib/windows8/exec.js b/lib/windows8/exec.js
index c4858dd..a8717a3 100644
--- a/lib/windows8/exec.js
+++ b/lib/windows8/exec.js
@@ -42,7 +42,9 @@
module.exports = function (success, fail, service, action, args) {
var proxy = commandProxy.get(service, action),
- callbackId;
+ callbackId,
+ onSuccess,
+ onError;
if (proxy) {
callbackId = service + cordova.callbackId++;
@@ -51,11 +53,28 @@
cordova.callbacks[callbackId] = {success: success, fail: fail};
}
try {
- proxy(success, fail, args);
+ onSuccess = function (result) {
+ cordova.callbackSuccess(callbackId,
+ {
+ status: cordova.callbackStatus.OK,
+ message: result
+ });
+ };
+ onError = function (err) {
+ cordova.callbackError(callbackId,
+ {
+ status: cordova.callbackStatus.ERROR,
+ message: err
+ });
+ };
+ proxy(onSuccess, onError, args);
+
} catch (e) {
console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
}
} else {
- return (fail && fail("Missing Command Error"));
+ if (typeof fail === "function") {
+ fail("Missing Command Error");
+ }
}
};