From 490c172b35c9f48d95b4c1a38003a00520ba27b8 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 18 Mar 2015 02:05:02 +0200 Subject: [PATCH] Delete the GLFWView object at exit Also destroy the glfwWindow we create. This leak was probably harmless but a nice cleanup helps us debug other serious memory leaks. --- linux/main.cpp | 5 +++-- platform/default/glfw_view.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/linux/main.cpp b/linux/main.cpp index 697941164..4d5474c02 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -13,7 +14,7 @@ #include -GLFWView *view = nullptr; +std::unique_ptr view; void quit_handler(int) { if (view) { @@ -62,7 +63,7 @@ int main(int argc, char *argv[]) { sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, NULL); - view = new GLFWView(); + view = mbgl::util::make_unique(); mbgl::SQLiteCache cache("/tmp/mbgl-cache.db"); mbgl::DefaultFileSource fileSource(&cache); diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 601ae0ec2..fd9c701f9 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -11,6 +11,7 @@ GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) { } GLFWView::~GLFWView() { + glfwDestroyWindow(window); glfwTerminate(); }