#include "wx/textfile.h"
#include "wx/utils.h"
#include "wx/utils.h"
+#include "wx/math.h"
#include <stdlib.h>
-#include <math.h>
#include <ctype.h>
#include <limits.h> // for INT_MAX
m_bRecordDefaults = false;
}
+wxConfigBase::~wxConfigBase()
+{
+ // required here for Darwin
+}
+
wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
{
wxConfigBase *pOld = ms_pConfig;
wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR);
// except in the special case of "/keyname" when there is nothing before "/"
- if ( strPath.IsEmpty() &&
- ((!strEntry.IsEmpty()) && strEntry[0] == wxCONFIG_PATH_SEPARATOR) )
+ if ( strPath.empty() &&
+ ((!strEntry.empty()) && strEntry[0] == wxCONFIG_PATH_SEPARATOR) )
{
strPath = wxCONFIG_PATH_SEPARATOR;
}
- if ( !strPath.IsEmpty() && m_pContainer->GetPath() != strPath ) {
- // do change the path
- m_bChanged = true;
+ if ( !strPath.empty() )
+ {
+ if ( m_pContainer->GetPath() != strPath )
+ {
+ // do change the path
+ m_bChanged = true;
+
+ /* JACS: work around a memory bug that causes an assert
+ when using wxRegConfig, related to reference-counting.
+ Can be reproduced by removing (const wxChar*) below and
+ adding the following code to the config sample OnInit under
+ Windows:
+
+ pConfig->SetPath(wxT("MySettings"));
+ pConfig->SetPath(wxT(".."));
+ int value;
+ pConfig->Read(_T("MainWindowX"), & value);
+ */
+ m_strOldPath = (const wxChar*) m_pContainer->GetPath();
+ if ( *m_strOldPath.c_str() != wxCONFIG_PATH_SEPARATOR )
+ m_strOldPath += wxCONFIG_PATH_SEPARATOR;
+ m_pContainer->SetPath(strPath);
+ }
+
+ // in any case, use the just the name, not full path
m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR);
- m_strOldPath = m_pContainer->GetPath();
- if ( m_strOldPath.Len() == 0 ||
- m_strOldPath.Last() != wxCONFIG_PATH_SEPARATOR )
- m_strOldPath += wxCONFIG_PATH_SEPARATOR;
- m_pContainer->SetPath(strPath);
}
else {
// it's a name only, without path - nothing to do
case '\\':
// backslash can be used to suppress special meaning of % and $
- if ( n != str.Len() && (str[n + 1] == wxT('%') || str[n + 1] == wxT('$')) ) {
+ if ( n != str.Len() - 1 &&
+ (str[n + 1] == wxT('%') || str[n + 1] == wxT('$')) ) {
strResult += str[++n];
break;
strCurrent.Empty();
}
- else if ( !strCurrent.IsEmpty() ) {
+ else if ( !strCurrent.empty() ) {
aParts.push_back(strCurrent);
strCurrent.Empty();
}