From 31b27f302f18c8a7dc8b852c6778f1734f97c9e1 Mon Sep 17 00:00:00 2001
From: Michel Rasquin <michel.rasquin@cenaero.be>
Date: Fri, 25 Aug 2017 10:10:20 +0200
Subject: [PATCH] Fix calls to PView destructor for memory dealloc

---
 Common/Gmsh.cpp | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp
index cec3d9828a..103dee45b6 100644
--- a/Common/Gmsh.cpp
+++ b/Common/Gmsh.cpp
@@ -240,19 +240,15 @@ int GmshFinalize()
 {
 #if defined(HAVE_POST)
   // Delete all PViewData stored in static list of PView class
-  for(unsigned int i = 0; i < PView::list.size(); i++) {
-    delete PView::list[i];
-  }
-  PView::list.clear();
+  while(PView::list.size()>0) delete PView::list[PView::list.size()-1];
   std::vector<PView*>().swap(PView::list);
 
   // Delete static _interpolationSchemes of PViewData class
   PViewData::removeAllInterpolationSchemes();
 #endif
+  
   // Delete all Gmodels
-  for(unsigned int i = 0; i < GModel::list.size(); i++)
-    delete GModel::list[i];
-  GModel::list.clear();
+  while(GModel::list.size()>0) delete GModel::list[GModel::list.size()-1];
   std::vector<GModel*>().swap(GModel::list);
 
   return 1;
-- 
GitLab