Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10807/src/classes
Modified Files:
Profile.cpp ConfigSourcesAll.cpp
Log Message:
ensure that we overwrite any existing value when saving the profile/config
values (before we always wrote to the profile with least priority even if a
higher priority profile already contained the value and so the save value was
ignored)
Index: Profile.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/Profile.cpp,v
retrieving revision 1.169
retrieving revision 1.170
diff -b -u -2 -r1.169 -r1.170
--- Profile.cpp 16 Jan 2006 20:32:27 -0000 1.169
+++ Profile.cpp 8 Apr 2006 01:30:05 -0000 1.170
@@ -67,5 +67,5 @@
/** Name for the subgroup level used for suspended profiles. Must
never appear as part of a profile path name. */
-#define SUSPEND_PATH _T("__suspended__")
+extern const char SUSPEND_PATH[] = _T("__suspended__");
/// flags for readEntry
Index: ConfigSourcesAll.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/ConfigSourcesAll.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -u -2 -r1.11 -r1.12
--- ConfigSourcesAll.cpp 16 Jan 2006 20:32:26 -0000 1.11
+++ ConfigSourcesAll.cpp 8 Apr 2006 01:30:05 -0000 1.12
@@ -411,13 +411,5 @@
ConfigSource *config)
{
- if ( !config )
- {
- CHECK( !m_sources.empty(), false,
- _T("can't write to profile if no config sources exist") );
-
- List::iterator i = m_sources.end();
- config = *((--i).operator->());
- }
-
+ // construct the full path
const String key = data.GetKey();
String fullpath;
@@ -434,4 +426,44 @@
_T("config path must not start with /M") );
+
+ // find where to write the data to
+ if ( !config )
+ {
+ // we need to find the first config source in which this value is already
+ // present as writing it should overwrite any existing value and for this
+ // it has to be written to higher priority config source
+
+ // we also have to check for the normal entries if we're writing a
+ // suspended one
+ extern const char SUSPEND_PATH[]; // from Profile.cpp
+ String fullpathUnsusp;
+ size_t posSusp = fullpath.find(SUSPEND_PATH);
+ if ( posSusp != String::npos )
+ {
+ // +1 for the slash
+ fullpathUnsusp = fullpath;
+ fullpathUnsusp.erase(posSusp, strlen(SUSPEND_PATH) + 1);
+ }
+
+ // note that this loop terminates with config set to the last source if
+ // the element is not found anywhere, just as desired
+ const List::iterator end = m_sources.end();
+ for ( List::iterator i = m_sources.begin(); i != end; ++i )
+ {
+ config = *i;
+ if ( config->HasEntry(fullpath) ||
+ !(fullpathUnsusp.empty() && config->HasEntry(fullpathUnsusp)) )
+ {
+ // write to this one to overwrite the existing entry
+ break;
+ }
+ }
+
+ CHECK( config, false,
+ _T("can't write to profile if no config sources exist") );
+ }
+
+
+ // finally do write it
return data.GetType() == LookupData::LD_LONG
? config->Write(fullpath, data.GetLong())
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates