From 9fbe5b2ece81c646f1f3d60f1d280a9241ba8937 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Wed, 19 Feb 2014 14:51:46 -0800 Subject: [PATCH] properly deregister render observers --- ios/MBXViewController.mm | 2 ++ macosx/main.mm | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm index bea95d2bb..8d734459c 100644 --- a/ios/MBXViewController.mm +++ b/ios/MBXViewController.mm @@ -141,6 +141,8 @@ class MBXMapView - (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + mapView->settings.sync(); } diff --git a/macosx/main.mm b/macosx/main.mm index c4f3c87a5..7c2f0cc1e 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -56,7 +56,7 @@ public: glfwSetCharCallback(window, character); glfwSetKeyCallback(window, key); - [[NSNotificationCenter defaultCenter] addObserverForName:MBXNeedsRenderNotification + renderObserver = [[NSNotificationCenter defaultCenter] addObserverForName:MBXNeedsRenderNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock: ^ (NSNotification * notification) { @@ -198,6 +198,7 @@ public: } ~MapView() { + [[NSNotificationCenter defaultCenter] removeObserver:renderObserver]; glfwTerminate(); } @@ -214,6 +215,8 @@ public: GLFWwindow *window; llmr::Settings_MacOSX settings; llmr::Map map; + + id renderObserver; }; MapView *mapView;