- if ( !strPath.IsEmpty() ) {
- // do change the path
- m_bChanged = TRUE;
- m_strName = strEntry.Right(wxCONFIG_PATH_SEPARATOR);
- m_strOldPath = m_pContainer->GetPath();
- m_strOldPath += wxCONFIG_PATH_SEPARATOR;
- m_pContainer->SetPath(strPath);
+ 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);
+ }
+
+ // in any case, use the just the name, not full path
+ m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR);