I 'm not sure what your question exactly is but, trust me, this event gets sent alright.
Another event you might want to check out would be WORKSPACE_CHANGED...
Mandrav, you're the main creator of codeblocks (so you know what you're saying) and yes is been called right
I found the bug, and was actually on this function
===========================================================
void AutoVersioning::OnProjectLoadingHook(cbProject* project, TiXmlElement* elem, bool loading)
{
if(loading)
{
wxMessageBox(_T("Loading: ") + project->GetTitle());
// TODO (KILLERBOT) : should we have default values, in case something would be missing ?
// OPTI : we could choose not to write out default values in the xml --> smaller cbp
avConfig Config;
m_IsCurrentProjectVersioned = false; // default not active unless we find xml for it
const TiXmlElement* Node = elem->FirstChildElement("AutoVersioning");
if (Node)
{
m_IsCurrentProjectVersioned = true;
TiXmlHandle Handle(const_cast<TiXmlElement*>(Node));
if(const TiXmlElement* pElem = Handle.FirstChildElement("Scheme").ToElement())
{
int Help = 0;
if(pElem->QueryIntAttribute("minor_max", &Help) == TIXML_SUCCESS)
{
Config.Scheme.MinorMax = static_cast<long>(Help);
}
if(pElem->QueryIntAttribute("build_max", &Help) == TIXML_SUCCESS)
{
Config.Scheme.BuildMax = static_cast<long>(Help);
}
if(pElem->QueryIntAttribute("rev_max", &Help) == TIXML_SUCCESS)
{
Config.Scheme.RevisionMax = static_cast<long>(Help);
}
if(pElem->QueryIntAttribute("rev_rand_max", &Help) == TIXML_SUCCESS)
{
Config.Scheme.RevisionRandMax = static_cast<long>(Help);
}
if(pElem->QueryIntAttribute("build_times_to_increment_minor", &Help) == TIXML_SUCCESS)
{
Config.Scheme.BuildTimesToIncrementMinor = static_cast<long>(Help);
}
}
if(const TiXmlElement* pElem = Handle.FirstChildElement("Settings").ToElement())
{
Config.Settings.Language = pElem->Attribute("language");
Config.Settings.SvnDirectory = pElem->Attribute("svn_directory");
Config.Settings.HeaderPath = pElem->Attribute("header_path");
int Help = 0;
if(pElem->QueryIntAttribute("autoincrement", &Help) == TIXML_SUCCESS)
{
Config.Settings.Autoincrement = Help?true:false;
}
if(pElem->QueryIntAttribute("date_declarations", &Help) == TIXML_SUCCESS)
{
Config.Settings.DateDeclarations = Help?true:false;
}
if(pElem->QueryIntAttribute("do_auto_increment", &Help) == TIXML_SUCCESS)
{
Config.Settings.DoAutoIncrement = Help?true:false;
}
if(pElem->QueryIntAttribute("ask_to_increment", &Help) == TIXML_SUCCESS)
{
Config.Settings.AskToIncrement = Help?true:false;
}
if(pElem->QueryIntAttribute("svn", &Help) == TIXML_SUCCESS)
{
Config.Settings.Svn = Help?true:false;
}
}
if(const TiXmlElement* pElem = Handle.FirstChildElement("Changes_Log").ToElement())
{
Config.ChangesLog.AppTitle = pElem->Attribute("app_title");
Config.ChangesLog.ChangesLogPath = pElem->Attribute("changeslog_path");
int Help = 0;
if(pElem->QueryIntAttribute("show_changes_editor", &Help) == TIXML_SUCCESS)
{
Config.ChangesLog.ShowChangesEditor = Help?true:false;
}
}
}
avVersionState VersionState;
m_versionHeaderPath = FileNormalize(cbC2U(Config.Settings.HeaderPath.c_str()),project->GetBasePath());
avHeader VersionHeader;
if(VersionHeader.LoadFile(m_versionHeaderPath))
{
VersionState.Values.Major = VersionHeader.GetValue(_("MAJOR"));
VersionState.Values.Minor = VersionHeader.GetValue(_("MINOR"));
VersionState.Values.Build = VersionHeader.GetValue(_("BUILD"));
VersionState.Values.Revision = VersionHeader.GetValue(_("REVISION"));
VersionState.Values.BuildCount = VersionHeader.GetValue(_("BUILDS_COUNT"));
VersionState.Status.SoftwareStatus = cbU2C(VersionHeader.GetString(_("STATUS")));
VersionState.Status.Abbreviation = cbU2C(VersionHeader.GetString(_("STATUS_SHORT")));
VersionState.BuildHistory = VersionHeader.GetValue(_("BUILD_HISTORY"));
}
m_ProjectMap[project] = Config;
m_ProjectMapVersionState[project] = VersionState;
m_Project = project; //Here is the bug }
else
{
wxMessageBox(_T("Saving: ") + project->GetTitle());
// Hook called when saving project file.
// since rev4332, the project keeps a copy of the <Extensions> element
// and re-uses it when saving the project (so to avoid losing entries in it
// if plugins that use that element are not loaded atm).
// so, instead of blindly inserting the element, we must first check it's
// not already there (and if it is, clear its contents)
if(m_IsCurrentProjectVersioned)
{
TiXmlElement* node = elem->FirstChildElement("AutoVersioning");
if (!node)
{
node = elem->InsertEndChild(TiXmlElement("AutoVersioning"))->ToElement();
}
node->Clear();
//Used this instead of GetConfig() since if the project is not activated
//before saving, then the m_Project is not updated.
//This will happen when having multiple projects opened.
avConfig NewConfig = m_ProjectMap[project];
TiXmlElement Scheme("Scheme");
Scheme.SetAttribute("minor_max", NewConfig.Scheme.MinorMax);
Scheme.SetAttribute("build_max", NewConfig.Scheme.BuildMax);
Scheme.SetAttribute("rev_max", NewConfig.Scheme.RevisionMax);
Scheme.SetAttribute("rev_rand_max", NewConfig.Scheme.RevisionRandMax);
Scheme.SetAttribute("build_times_to_increment_minor", NewConfig.Scheme.BuildTimesToIncrementMinor);
node->InsertEndChild(Scheme);
TiXmlElement Settings("Settings");
Settings.SetAttribute("autoincrement", NewConfig.Settings.Autoincrement);
Settings.SetAttribute("date_declarations", NewConfig.Settings.DateDeclarations);
Settings.SetAttribute("do_auto_increment", NewConfig.Settings.DoAutoIncrement);
Settings.SetAttribute("ask_to_increment", NewConfig.Settings.AskToIncrement);
Settings.SetAttribute("language", NewConfig.Settings.Language.c_str());
Settings.SetAttribute("svn", NewConfig.Settings.Svn);
Settings.SetAttribute("svn_directory", NewConfig.Settings.SvnDirectory.c_str());
Settings.SetAttribute("header_path", NewConfig.Settings.HeaderPath.c_str());
node->InsertEndChild(Settings);
TiXmlElement ChangesLog("Changes_Log");
ChangesLog.SetAttribute("show_changes_editor", NewConfig.ChangesLog.ShowChangesEditor);
ChangesLog.SetAttribute("app_title", NewConfig.ChangesLog.AppTitle.c_str());
ChangesLog.SetAttribute("changeslog_path", NewConfig.ChangesLog.ChangesLogPath.c_str());
node->InsertEndChild(ChangesLog);
}
// TODO (KILLERBOT) : what if we decide to not version anymore : how to remove ??
}
}// OnProjectLoadingHook
===========================================================
well that statement ( m_Project = project;) should be only called when the project is activated not when loading oops :oops:
Now, I have found other bug
, the configuration stored on the project file is not working (to not say loading) fine when loading a workspace instead of a project directly. Im currently checking this.