Fix Memory leak in BlackBorderProcessor

This commit is contained in:
LordGrey
2023-12-28 18:12:47 +01:00
parent 592e61de2c
commit 0c87869339
2 changed files with 4 additions and 12 deletions

View File

@@ -24,7 +24,7 @@ namespace hyperion
Q_OBJECT
public:
BlackBorderProcessor(Hyperion* hyperion, QObject* parent);
~BlackBorderProcessor() override;
///
/// Return the current (detected) border
/// @return The current border
@@ -141,7 +141,7 @@ namespace hyperion
QString _detectionMode;
/// The black-border detector
BlackBorderDetector* _detector;
std::unique_ptr<BlackBorderDetector> _detector;
/// The current detected border
BlackBorder _currentBorder;

View File

@@ -35,12 +35,7 @@ BlackBorderProcessor::BlackBorderProcessor(Hyperion* hyperion, QObject* parent)
// listen for component state changes
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &BlackBorderProcessor::handleCompStateChangeRequest);
_detector = new BlackBorderDetector(_oldThreshold);
}
BlackBorderProcessor::~BlackBorderProcessor()
{
delete _detector;
_detector = std::make_unique<BlackBorderDetector>(_oldThreshold);
}
void BlackBorderProcessor::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
@@ -66,10 +61,7 @@ void BlackBorderProcessor::handleSettingsUpdate(settings::type type, const QJson
if (fabs(_oldThreshold - newThreshold) > std::numeric_limits<double>::epsilon())
{
_oldThreshold = newThreshold;
delete _detector;
_detector = new BlackBorderDetector(newThreshold);
_detector = std::make_unique<BlackBorderDetector>(_oldThreshold);
}
Debug(Logger::getInstance("BLACKBORDER", "I"+QString::number(_hyperion->getInstanceIndex())), "Set mode to: %s", QSTRING_CSTR(_detectionMode));