Skip to content

Commit

Permalink
Get missing defaults and save options when loading
Browse files Browse the repository at this point in the history
Follow-up to ref 60632d4.  Initial implementation would lose loaded
options when the module was reloaded, and would cause errors if the
loaded dictionary did not contain all of the option values.
  • Loading branch information
amyreese committed Sep 29, 2011
1 parent a69ec09 commit 1f76601
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions push.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,26 @@ class CPushMod : public CModule
if (status == MCString::MCS_SUCCESS)
{
PutModule("Options loaded from " + file_path);

// Restore any defaults that aren't in the loaded dictionary,
// and save loaded options to ZNC's data store
for (MCString::iterator i = defaults.begin(); i != defaults.end(); i++)
{
CString option = i->first;
MCString::iterator pos = options.find(option);

if (pos == options.end())
{
options[option] = defaults[option];
DelNV(option);
}
else
{
SetNV(option, options[option]);
}
}

authencode();
}
else
{
Expand Down

0 comments on commit 1f76601

Please sign in to comment.