[Kdenlive-devel] [PATCH 21/37] newFile: Use QPointer

Mikko Rapeli mikko.rapeli at iki.fi
Thu Jun 28 13:52:59 UTC 2012


Fixes crashes if parent is destroyed. Found by krazy. Details at:
http://blogs.kde.org/node/3919

Also delete dialog on exit paths.
---
 src/mainwindow.cpp |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c28579e..b64eba7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1870,12 +1870,16 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
             if (!closeCurrentDocument())
                 return;
     } else {
-        ProjectSettings *w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
-        if (w->exec() != QDialog::Accepted)
+        QPointer<ProjectSettings> w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
+        if (w->exec() != QDialog::Accepted) {
+            delete w;
             return;
+        }
         if (!KdenliveSettings::activatetabs())
-            if (!closeCurrentDocument())
+            if (!closeCurrentDocument()) {
+                delete w;
                 return;
+            }
         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
             slotSwitchVideoThumbs();
         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
-- 
1.7.10.4





More information about the Kdenlive mailing list