Bug #13676 2008-04-23 15:39

jgm

OnCompiler(Started,Finished) event.GetProject() returns null

When the compiler plugin sends the OnCompilerStarted and OnCompilerFinished events to other plugins, the project pointer populated on CodeBlocksEvent GetProject() is null (0)

Here I provide a simple test code to see the value returned by event.GetProject on both functions
=======================================
void AutoVersioning::OnCompilerStarted(CodeBlocksEvent& event)
{
    wxString print;
    print.Printf(_T("m_Project: %d event.GetProject: %d"),m_Project, event.GetProject());
    wxMessageBox(print, _T("OnCompilerStarted"));

    if (m_Project && IsAttached() && m_IsVersioned[event.GetProject()])
    {
		if (m_Modified)
		{
			const bool doAutoIncrement = GetConfig().Settings.DoAutoIncrement;
			const bool askToIncrement = GetConfig().Settings.AskToIncrement;
			if (doAutoIncrement && askToIncrement)
			{
				if (wxMessageBox(_("Do you want to increment the version?"),_T(""),wxYES_NO) == wxYES)
				{
					CommitChanges();
				}
			}
			else if(doAutoIncrement)
			{
				CommitChanges();
			}
		}
    }
} // end of OnCompilerStarted

void AutoVersioning::OnCompilerFinished(CodeBlocksEvent& event)
{
    wxString print;
    print.Printf(_T("m_Project: %d event.GetProject: %d"),m_Project, event.GetProject());
    wxMessageBox(print, _T("OnCompilerFinished"));

    if (m_Project && IsAttached() && m_IsVersioned[event.GetProject()])
	{
		++(GetVersionState().Values.BuildCount);
	}
}
=======================================

You could use the autoversioning plugin to test, and the following configuration for a dummy project file.
=======================================
<AutoVersioning>
				<Scheme minor_max="10" build_max="0" rev_max="0" rev_rand_max="10" build_times_to_increment_minor="100" />
				<Settings autoincrement="1" date_declarations="1" do_auto_increment="1" ask_to_increment="0" language="C++" svn="0" svn_directory="" header_path="include/version.h" />
				<Changes_Log show_changes_editor="0" app_title="released version %M.%m.%b of %p" changeslog_path="ChangesLog.txt" />
			</AutoVersioning>
=======================================

Just create a project file with the above autoversioning plug in configuration and edit a source file on the project so autoversioning detects changes, and  before compiling it will try to increment the version values, but like event.GetProject() is null it can't.
Category
Compiler
Group
 
Status
Closed
Close date
2008-04-23 17:11
Assigned to
biplab
biplab 2008-04-23 17:11

This bug is now fixed in HEAD.

Thank you for reporting it.