Don't allow default copy c'tor to copy arrays of pointers.

Fixes KICAD-SJ2.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21408

(cherry picked from commit d91cce930f83723869b39cfa13896e8fb34a2937)
This commit is contained in:
Jeff Young 2025-08-01 21:19:29 +01:00
parent b907fe412f
commit 3bdeb84b51
4 changed files with 51 additions and 71 deletions

View File

@ -135,15 +135,6 @@ JOBSET_DESTINATION::JOBSET_DESTINATION( const wxString& id, JOBSET_DESTINATION_T
}
JOBSET_DESTINATION::~JOBSET_DESTINATION()
{
for( auto& [name, reporter] : m_lastRunReporters )
delete reporter;
m_lastRunReporters.clear();
}
void JOBSET_DESTINATION::InitOutputHandler()
{
if( m_type == JOBSET_DESTINATION_T::FOLDER )

View File

@ -21,15 +21,52 @@
#ifndef JOBS_FILE_H
#define JOBS_FILE_H
#include <reporter.h>
#include <bitmaps/bitmaps_list.h>
#include <jobs/job.h>
#include <jobs/jobs_output.h>
#include <settings/json_settings.h>
#include <settings/parameters.h>
#include <widgets/wx_progress_reporters.h>
#include <ctime>
#include <memory>
class REPORTER;
class JOBSET_OUTPUT_REPORTER : public WX_STRING_REPORTER
{
public:
JOBSET_OUTPUT_REPORTER( const wxString& aTempDirPath, PROGRESS_REPORTER* aProgressReporter ) :
m_tempDirPath( aTempDirPath ),
m_progressReporter( aProgressReporter )
{
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity ) override
{
wxString text( aText );
if( aSeverity == RPT_SEVERITY_DEBUG && !m_includeDebug )
return *this;
if( aSeverity == RPT_SEVERITY_ACTION )
text.Replace( m_tempDirPath, wxEmptyString );
if( m_progressReporter )
{
m_progressReporter->Report( text );
m_progressReporter->KeepRefreshing();
}
return WX_STRING_REPORTER::Report( text, aSeverity );
}
private:
wxString m_tempDirPath;
bool m_includeDebug;
PROGRESS_REPORTER* m_progressReporter;
};
struct KICOMMON_API JOBSET_JOB
{
@ -79,26 +116,24 @@ struct KICOMMON_API JOBSET_DESTINATION
JOBSET_DESTINATION( const wxString& id, JOBSET_DESTINATION_T type );
~JOBSET_DESTINATION();
void InitOutputHandler();
wxString GetDescription() const;
void SetDescription( const wxString& aDescription );
bool operator==( const JOBSET_DESTINATION& rhs ) const;
public:
wxString m_id;
JOBSET_DESTINATION_T m_type;
wxString m_description;
std::shared_ptr<JOBS_OUTPUT_HANDLER> m_outputHandler;
std::vector<wxString> m_only;
wxString GetDescription() const;
void SetDescription( const wxString& aDescription );
///< Transient property, not stored for now
std::optional<bool> m_lastRunSuccess;
std::unordered_map<wxString, std::optional<bool>> m_lastRunSuccessMap;
std::unordered_map<wxString, REPORTER*> m_lastRunReporters;
bool operator==( const JOBSET_DESTINATION& rhs ) const;
std::unordered_map<wxString, std::shared_ptr<JOBSET_OUTPUT_REPORTER>> m_lastRunReporters;
};

View File

@ -147,19 +147,11 @@ public:
wxString jobId = jobs[itemIndex].m_id;
if( m_destination->m_lastRunReporters.contains( jobId ) )
{
WX_STRING_REPORTER* reporter =
static_cast<WX_STRING_REPORTER*>( m_destination->m_lastRunReporters[jobId] );
if( reporter )
m_textCtrlOutput->SetValue( reporter->GetMessages() );
}
m_textCtrlOutput->SetValue( m_destination->m_lastRunReporters.at( jobId )->GetMessages() );
else
{
m_textCtrlOutput->SetValue( _( "No output messages" ) );
}
}
}
private:
JOBSET* m_jobsFile;

View File

@ -134,41 +134,6 @@ int JOBS_RUNNER::runSpecialCopyFiles( const JOBSET_JOB* aJob, PROJECT* aProject
}
class JOBSET_OUTPUT_REPORTER : public WX_STRING_REPORTER
{
public:
JOBSET_OUTPUT_REPORTER( const wxString& aTempDirPath, PROGRESS_REPORTER* aProgressReporter ) :
m_tempDirPath( aTempDirPath ),
m_progressReporter( aProgressReporter )
{
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity ) override
{
wxString text( aText );
if( aSeverity == RPT_SEVERITY_DEBUG && !m_includeDebug )
return *this;
if( aSeverity == RPT_SEVERITY_ACTION )
text.Replace( m_tempDirPath, wxEmptyString );
if( m_progressReporter )
{
m_progressReporter->Report( text );
m_progressReporter->KeepRefreshing();
}
return WX_STRING_REPORTER::Report( text, aSeverity );
}
private:
wxString m_tempDirPath;
bool m_includeDebug;
PROGRESS_REPORTER* m_progressReporter;
};
bool JOBS_RUNNER::RunJobsForDestination( JOBSET_DESTINATION* aDestination, bool aBail )
{
bool genOutputs = true;
@ -181,10 +146,6 @@ bool JOBS_RUNNER::RunJobsForDestination( JOBSET_DESTINATION* aDestination, bool
tmp.AppendDir( KIID().AsString() );
aDestination->m_lastRunSuccessMap.clear();
for( auto& [name, reporter] : aDestination->m_lastRunReporters )
delete reporter;
aDestination->m_lastRunReporters.clear();
wxString tempDirPath = tmp.GetFullPath();
@ -269,8 +230,9 @@ bool JOBS_RUNNER::RunJobsForDestination( JOBSET_DESTINATION* aDestination, bool
if( reporterToUse == &NULL_REPORTER::GetInstance() )
{
reporterToUse = new JOBSET_OUTPUT_REPORTER( tempDirPath, m_progressReporter );
aDestination->m_lastRunReporters[job.m_id] = reporterToUse;
aDestination->m_lastRunReporters[job.m_id] = std::make_shared<JOBSET_OUTPUT_REPORTER>( tempDirPath,
m_progressReporter );
reporterToUse = aDestination->m_lastRunReporters[job.m_id].get();
}
int result = CLI::EXIT_CODES::SUCCESS;