]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fileconf.cpp
wxTheColourDatabase->Find() can fail.
[wxWidgets.git] / src / common / fileconf.cpp
index 5e84cf2c415d4d1a310e47690fc9ffec73ff919e..2e4468252f2ebe63e57aa318e7a38718ef3db1ba 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
+// For compilers that support precompilation, includes "wx.h".
 #include  "wx/wxprec.h"
 
 #ifdef    __BORLANDC__
-  #pragma hdrstop
+    #pragma hdrstop
 #endif  //__BORLANDC__
 
 #if wxUSE_CONFIG && wxUSE_FILECONFIG
 
 #ifndef   WX_PRECOMP
-  #include  "wx/string.h"
-  #include  "wx/intl.h"
+    #include  "wx/dynarray.h"
+    #include  "wx/string.h"
+    #include  "wx/intl.h"
 #endif  //WX_PRECOMP
 
 #include  "wx/app.h"
-#include  "wx/dynarray.h"
 #include  "wx/file.h"
 #include  "wx/log.h"
 #include  "wx/textfile.h"
@@ -394,7 +395,7 @@ void wxFileConfig::Init()
     {
         wxTextFile fileGlobal(m_strGlobalFile);
 
-        if ( fileGlobal.Open(m_conv/*ignored in ANSI build*/) )
+        if ( fileGlobal.Open(*m_conv/*ignored in ANSI build*/) )
         {
             Parse(fileGlobal, false /* global */);
             SetRootPath();
@@ -409,7 +410,7 @@ void wxFileConfig::Init()
     if ( !m_strLocalFile.empty() && wxFile::Exists(m_strLocalFile) )
     {
         wxTextFile fileLocal(m_strLocalFile);
-        if ( fileLocal.Open(m_conv/*ignored in ANSI build*/) )
+        if ( fileLocal.Open(*m_conv/*ignored in ANSI build*/) )
         {
             Parse(fileLocal, true /* local */);
             SetRootPath();
@@ -432,7 +433,7 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
                            strLocal, strGlobal,
                            style),
               m_strLocalFile(strLocal), m_strGlobalFile(strGlobal),
-              m_conv(conv)
+              m_conv(conv.Clone())
 {
     // Make up names for files if empty
     if ( m_strLocalFile.empty() && (style & wxCONFIG_USE_LOCAL_FILE) )
@@ -476,7 +477,7 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
 #if wxUSE_STREAMS
 
 wxFileConfig::wxFileConfig(wxInputStream &inStream, const wxMBConv& conv)
-            : m_conv(conv)
+            : m_conv(conv.Clone())
 {
     // always local_file when this constructor is called (?)
     SetStyle(GetStyle() | wxCONFIG_USE_LOCAL_FILE);
@@ -571,6 +572,8 @@ wxFileConfig::~wxFileConfig()
     Flush();
 
     CleanUp();
+
+    delete m_conv;
 }
 
 // ----------------------------------------------------------------------------
@@ -1012,7 +1015,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
   {
     wxString line = p->Text();
     line += wxTextFile::GetEOL();
-    if ( !file.Write(line, m_conv) )
+    if ( !file.Write(line, *m_conv) )
     {
       wxLogError(_("can't write user configuration file."));
       return false;