Fix double-delete.
The JSON_SETTINGS stuff makes copies of the JOBSET_DESTINATION. That ends poorly when it contains just a naked C++ pointer. Fixes https://gitlab.com/kicad/code/kicad/-/issues/21227
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <reporter.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
const int jobsFileSchemaVersion = 1;
|
||||
|
||||
@@ -140,8 +141,6 @@ JOBSET_DESTINATION::~JOBSET_DESTINATION()
|
||||
delete reporter;
|
||||
|
||||
m_lastRunReporters.clear();
|
||||
|
||||
delete m_outputHandler;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,11 +148,11 @@ void JOBSET_DESTINATION::InitOutputHandler()
|
||||
{
|
||||
if( m_type == JOBSET_DESTINATION_T::FOLDER )
|
||||
{
|
||||
m_outputHandler = new JOBS_OUTPUT_FOLDER();
|
||||
m_outputHandler = std::make_shared<JOBS_OUTPUT_FOLDER>( );
|
||||
}
|
||||
else if( m_type == JOBSET_DESTINATION_T::ARCHIVE )
|
||||
{
|
||||
m_outputHandler = new JOBS_OUTPUT_ARCHIVE();
|
||||
m_outputHandler = std::make_shared<JOBS_OUTPUT_ARCHIVE>( );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ struct KICOMMON_API JOBSET_DESTINATION
|
||||
wxString m_id;
|
||||
JOBSET_DESTINATION_T m_type;
|
||||
wxString m_description;
|
||||
JOBS_OUTPUT_HANDLER* m_outputHandler;
|
||||
std::shared_ptr<JOBS_OUTPUT_HANDLER> m_outputHandler;
|
||||
std::vector<wxString> m_only;
|
||||
|
||||
wxString GetDescription() const;
|
||||
|
||||
@@ -139,7 +139,7 @@ bool DIALOG_DESTINATION::TransferDataFromWindow()
|
||||
if( m_destination->m_type == JOBSET_DESTINATION_T::ARCHIVE )
|
||||
{
|
||||
JOBS_OUTPUT_ARCHIVE* archive =
|
||||
static_cast<JOBS_OUTPUT_ARCHIVE*>( m_destination->m_outputHandler );
|
||||
static_cast<JOBS_OUTPUT_ARCHIVE*>( m_destination->m_outputHandler.get() );
|
||||
|
||||
archive->SetFormat( JOBS_OUTPUT_ARCHIVE::FORMAT::ZIP );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user