- if ( !strPath.IsEmpty() && m_pContainer->GetPath() != strPath ) {
- // do change the path
- m_bChanged = true;
- 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
- m_bChanged = false;
- m_strName = strEntry;
+ if ( !strPath.empty() )
+ {
+ if ( m_pContainer->GetPath() != strPath )
+ {
+ // we do change the path so restore it later
+ 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 .wc_str() below and
+ adding the following code to the config sample OnInit under
+ Windows:
+
+ pConfig->SetPath(wxT("MySettings"));
+ pConfig->SetPath(wxT(".."));
+ int value;
+ pConfig->Read(wxT("MainWindowX"), & value);
+ */
+ m_strOldPath = m_pContainer->GetPath().wc_str();
+ if ( *m_strOldPath.c_str() != wxCONFIG_PATH_SEPARATOR )
+ m_strOldPath += wxCONFIG_PATH_SEPARATOR;
+ m_pContainer->SetPath(strPath);
+ }