[contextualprocess] Cleanup destructors
- ValueCheck shouldn't own the pointer, since it's just a QPair and there are temporary copies made (e.g. in ContextualProcessBinding::append() ) and we get double-deletes. - Do deletion by hand; going full unique_ptr would be a bit overkill.
This commit is contained in:
parent
87e2f13dc2
commit
23a23a01f1
@ -30,10 +30,6 @@
|
|||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Passing a CommandList to ValueCheck gives ownership of the CommandList to
|
|
||||||
* the ValueCheck, which will delete the CommandList when needed.
|
|
||||||
*/
|
|
||||||
struct ValueCheck : public QPair<QString, CalamaresUtils::CommandList*>
|
struct ValueCheck : public QPair<QString, CalamaresUtils::CommandList*>
|
||||||
{
|
{
|
||||||
ValueCheck( const QString& value, CalamaresUtils::CommandList* commands )
|
ValueCheck( const QString& value, CalamaresUtils::CommandList* commands )
|
||||||
@ -43,7 +39,9 @@ struct ValueCheck : public QPair<QString, CalamaresUtils::CommandList*>
|
|||||||
|
|
||||||
~ValueCheck()
|
~ValueCheck()
|
||||||
{
|
{
|
||||||
delete second;
|
// We don't own the commandlist, the binding holding this valuecheck
|
||||||
|
// does, so don't delete. This is closely tied to (temporaries created
|
||||||
|
// by) pass-by-value in QList::append().
|
||||||
}
|
}
|
||||||
|
|
||||||
QString value() const { return first; }
|
QString value() const { return first; }
|
||||||
@ -62,8 +60,7 @@ struct ContextualProcessBinding
|
|||||||
/**
|
/**
|
||||||
* @brief add commands to be executed when @p value is matched.
|
* @brief add commands to be executed when @p value is matched.
|
||||||
*
|
*
|
||||||
* Ownership of the CommandList passes to the ValueCheck held
|
* Ownership of the CommandList passes to this binding.
|
||||||
* by this binding.
|
|
||||||
*/
|
*/
|
||||||
void append( const QString& value, CalamaresUtils::CommandList* commands )
|
void append( const QString& value, CalamaresUtils::CommandList* commands )
|
||||||
{
|
{
|
||||||
@ -95,6 +92,10 @@ struct ContextualProcessBinding
|
|||||||
ContextualProcessBinding::~ContextualProcessBinding()
|
ContextualProcessBinding::~ContextualProcessBinding()
|
||||||
{
|
{
|
||||||
wildcard = nullptr;
|
wildcard = nullptr;
|
||||||
|
for ( const auto& c : checks )
|
||||||
|
{
|
||||||
|
delete c.commands();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextualProcessJob::ContextualProcessJob( QObject* parent )
|
ContextualProcessJob::ContextualProcessJob( QObject* parent )
|
||||||
|
Loading…
Reference in New Issue
Block a user