Prevent jobs from affecting each other via reporters when running jobsets from CLI.

(cherry picked from commit 44a3bb9274845593db733464aa3f68288e3eb150)

Co-authored-by: Alex Shvartzkop <dudesuchamazing@gmail.com>
This commit is contained in:
dsa-t 2025-08-22 17:42:16 +03:00
parent 5576d1ed9c
commit 01991fed53
3 changed files with 38 additions and 18 deletions

View File

@ -211,6 +211,17 @@ REPORTER& WXLOG_REPORTER::GetInstance()
}
REPORTER& REDIRECT_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
REPORTER::Report( aText, aSeverity );
if( m_redirectTarget )
m_redirectTarget->Report( aText, aSeverity );
return *this;
}
REPORTER& STATUSBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
REPORTER::Report( aText, aSeverity );

View File

@ -131,7 +131,10 @@ public:
/**
* Returns true if the reporter client is non-empty.
*/
virtual bool HasMessage() const = 0;
virtual bool HasMessage() const
{
return m_severityMask != 0;
}
/**
* Returns true if the reporter has one or more messages matching the specified
@ -226,8 +229,6 @@ public:
REPORTER& Report( const wxString& aText,
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override { return false; }
};
@ -246,8 +247,6 @@ public:
static REPORTER& GetInstance();
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override { return false; }
};
@ -266,8 +265,6 @@ public:
static REPORTER& GetInstance();
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override { return false; }
};
@ -283,8 +280,17 @@ public:
static REPORTER& GetInstance();
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
};
bool HasMessage() const override { return false; }
class KICOMMON_API REDIRECT_REPORTER : public REPORTER
{
public:
REDIRECT_REPORTER( REPORTER* aRedirectTarget ) : m_redirectTarget( aRedirectTarget ) {}
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
REPORTER* m_redirectTarget;
};

View File

@ -240,28 +240,31 @@ bool JOBS_RUNNER::RunJobsForDestination( JOBSET_DESTINATION* aDestination, bool
job.m_job->SetTempOutputDirectory( tempDirPath );
REPORTER* reporterToUse = &m_reporter;
REPORTER* targetReporter = &m_reporter;
if( reporterToUse == &NULL_REPORTER::GetInstance() )
if( targetReporter == &NULL_REPORTER::GetInstance() )
{
aDestination->m_lastRunReporters[job.m_id] = std::make_shared<JOBSET_OUTPUT_REPORTER>( tempDirPath,
m_progressReporter );
reporterToUse = aDestination->m_lastRunReporters[job.m_id].get();
aDestination->m_lastRunReporters[job.m_id] =
std::make_shared<JOBSET_OUTPUT_REPORTER>( tempDirPath, m_progressReporter );
targetReporter = aDestination->m_lastRunReporters[job.m_id].get();
}
int result = CLI::EXIT_CODES::SUCCESS;
// Use a redirect reporter so we don't have error flags set after running previous jobs
REDIRECT_REPORTER isolatedReporter( targetReporter );
int result = CLI::EXIT_CODES::SUCCESS;
if( iface < KIWAY::KIWAY_FACE_COUNT )
{
result = m_kiway->ProcessJob( iface, job.m_job.get(), reporterToUse, m_progressReporter );
result = m_kiway->ProcessJob( iface, job.m_job.get(), &isolatedReporter,
m_progressReporter );
}
else
{
// special jobs
if( job.m_job->GetType() == "special_execute" )
{
result = runSpecialExecute( &job, reporterToUse, m_project );
{
result = runSpecialExecute( &job, &isolatedReporter, m_project );
}
else if( job.m_job->GetType() == "special_copyfiles" )
{