[vlmc-devel] Settings: Close settings file after reading from it

Hugo Beauzée-Luyssen git at videolan.org
Sun Mar 30 17:48:40 CEST 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Mar 30 16:53:20 2014 +0300| [fa9a97206bbbe56800da34e4a0adb319db13a176] | committer: Hugo Beauzée-Luyssen

Settings: Close settings file after reading from it

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=fa9a97206bbbe56800da34e4a0adb319db13a176
---

 src/Settings/Settings.cpp |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/Settings/Settings.cpp b/src/Settings/Settings.cpp
index 6b7ec0a..eaa687f 100644
--- a/src/Settings/Settings.cpp
+++ b/src/Settings/Settings.cpp
@@ -105,6 +105,11 @@ bool
 Settings::load()
 {
     QDomDocument    doc("root");
+    if ( m_settingsFile->open( QFile::ReadOnly ) == false )
+    {
+        vlmcWarning() << "Failed to open settings file" << m_settingsFile->fileName();
+        return false;
+    }
     if ( doc.setContent( m_settingsFile ) == false )
     {
         vlmcWarning() << "Failed to load settings file" << m_settingsFile->fileName();
@@ -114,6 +119,7 @@ Settings::load()
     if ( element.isNull() == true )
     {
         vlmcWarning() << "Invalid settings node";
+        m_settingsFile->close();
         return false ;
     }
     QDomElement s = element.firstChildElement( "setting" );
@@ -132,6 +138,7 @@ Settings::load()
         }
         s = s.nextSiblingElement();
     }
+    m_settingsFile->close();
     return true;
 }
 



More information about the Vlmc-devel mailing list