From c39b2ec80a2307e8731a8b671743dfd8fb1dce15 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Tue, 24 Jan 2017 17:45:35 +0100
Subject: [PATCH] BUG: Mantis-1338: ImportImageDialog was not deleted

---
 .../MonteverdiGui/src/mvdI18nMainWindow.cxx        | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx b/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx
index 3aad4081be..499e6a8bb1 100644
--- a/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx
+++ b/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx
@@ -181,14 +181,23 @@ I18nMainWindow
 ::BuildGDALOverviews( const QStringList & filenames )
 {
   ImportImagesDialog * importDialog = new ImportImagesDialog( filenames, this );
+  // The import dialog should be deleted before leaving this function
 
   if( importDialog->GetEffectiveCount()<1 )
+    {
+    delete importDialog;
+    importDialog = NULL;
     return true;
+    }
 
   int result = importDialog->exec();
 
   if( result== QDialog::Rejected )
+    {
+    delete importDialog;
+    importDialog = NULL;
     return false;
+    }
 
   if( result==QDialog::Accepted )
     {
@@ -205,6 +214,11 @@ I18nMainWindow
     Import( builder );
     }
 
+  if (importDialog)
+    {
+    delete importDialog;
+    importDialog = NULL;
+    }
   return true;
 }
 
-- 
GitLab