cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject git commit: CB-6924 Fixed memory leak in WP page navigation
Date Tue, 17 Jun 2014 18:06:27 GMT
Repository: cordova-wp8
Updated Branches:
  refs/heads/master 829beb988 -> 0c5f0e393


CB-6924 Fixed memory leak in WP page navigation

Occurred when navigating back and forth from native to hybrid page.


Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/0c5f0e39
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/0c5f0e39
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/0c5f0e39

Branch: refs/heads/master
Commit: 0c5f0e393db026633afd89fec0684c0021d19df6
Parents: 829beb9
Author: Staci Cooper <smcooper@us.ibm.com>
Authored: Tue Jun 17 13:43:54 2014 -0400
Committer: Staci Cooper <smcooper@us.ibm.com>
Committed: Tue Jun 17 13:43:54 2014 -0400

----------------------------------------------------------------------
 wp8/template/cordovalib/ConsoleHelper.cs    |  9 +++++++++
 wp8/template/cordovalib/CordovaView.xaml.cs | 10 ++++++++++
 2 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/0c5f0e39/wp8/template/cordovalib/ConsoleHelper.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/ConsoleHelper.cs b/wp8/template/cordovalib/ConsoleHelper.cs
index cf79d23..3443821 100644
--- a/wp8/template/cordovalib/ConsoleHelper.cs
+++ b/wp8/template/cordovalib/ConsoleHelper.cs
@@ -71,6 +71,15 @@ namespace WPCordovaClassLib.CordovaLib
             }
         }
 
+        public void DetachHandler()
+        {
+            if (hasListener)
+            {
+                PhoneApplicationService.Current.Closing -= OnServiceClosing;
+                hasListener = false;
+            }
+        }
+
         public bool HandleCommand(string commandStr)
         {
             string output = commandStr.Substring("ConsoleLog/".Length);

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/0c5f0e39/wp8/template/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaView.xaml.cs b/wp8/template/cordovalib/CordovaView.xaml.cs
index 1872a91..0514aa6 100644
--- a/wp8/template/cordovalib/CordovaView.xaml.cs
+++ b/wp8/template/cordovalib/CordovaView.xaml.cs
@@ -513,7 +513,17 @@ namespace WPCordovaClassLib
 
         private void CordovaBrowser_Unloaded(object sender, RoutedEventArgs e)
         {
+            IBrowserDecorator console;
+            if (browserDecorators.TryGetValue("ConsoleLog", out console))
+            {
+                ((ConsoleHelper)console).DetachHandler();
+            }
 
+            PhoneApplicationService service = PhoneApplicationService.Current;
+            service.Activated -= new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(AppActivated);
+            service.Launching -= new EventHandler<LaunchingEventArgs>(AppLaunching);
+            service.Deactivated -= new EventHandler<DeactivatedEventArgs>(AppDeactivated);
+            service.Closing -= new EventHandler<ClosingEventArgs>(AppClosing);
         }
 
         private void CordovaBrowser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs
e)


Mime
View raw message