[vlmc-devel] Core: Remove side effects from the destructor.

Hugo Beauzée-Luyssen git at videolan.org
Wed Jul 6 11:50:01 CEST 2016


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Jun 27 20:45:23 2016 +0200| [4430e3d49f30cff2c885ac10e17dc39f40034ca5] | committer: Hugo Beauzée-Luyssen

Core: Remove side effects from the destructor.

Invoking Settings::save() might cause logging, which requires a valid
Core instance. Doing so from the constructor isn't a good idea

> https://code.videolan.org/videolan/vlmc/commit/4430e3d49f30cff2c885ac10e17dc39f40034ca5
---

 src/Main/Core.cpp | 1 -
 src/Main/main.cpp | 9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
index 1dc3bcf..da822f2 100644
--- a/src/Main/Core.cpp
+++ b/src/Main/Core.cpp
@@ -64,7 +64,6 @@ Core::Core()
 
 Core::~Core()
 {
-    m_settings->save();
     delete m_library;
     delete m_undoStack;
     delete m_workflow;
diff --git a/src/Main/main.cpp b/src/Main/main.cpp
index dc03f9e..4890633 100644
--- a/src/Main/main.cpp
+++ b/src/Main/main.cpp
@@ -34,6 +34,7 @@
 #include "Project/Project.h"
 #include "Backend/IBackend.h"
 #include "Main/Core.h"
+#include "Settings/Settings.h"
 #ifdef WITH_GUI
 #include "Gui/MainWindow.h"
 #include "Gui/IntroDialog.h"
@@ -170,7 +171,9 @@ VLMCGuimain( int argc, char **argv )
 
     /* Main Window display */
     w.show();
-    return app.exec();
+    auto res = app.exec();
+    Core::instance()->settings()->save();
+    return res;
 }
 #endif
 /**
@@ -204,7 +207,9 @@ VLMCCoremain( int argc, char **argv )
     QCoreApplication::connect( p, &Project::projectLoaded, &renderer, &ConsoleRenderer::startRender );
     p->load( app.arguments()[1] );
 #endif
-    return app.exec();
+    auto res = app.exec();
+    Core::instance()->settings()->save();
+    return res;
 }
 
 int



More information about the Vlmc-devel mailing list