mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fix heap corruption (#862)
This commit is contained in:
parent
138b7d9c94
commit
dd98e245fe
@ -79,28 +79,19 @@ void LinearColorSmoothing::handleSettingsUpdate(const settings::type& type, cons
|
|||||||
|
|
||||||
int LinearColorSmoothing::write(const std::vector<ColorRgb> &ledValues)
|
int LinearColorSmoothing::write(const std::vector<ColorRgb> &ledValues)
|
||||||
{
|
{
|
||||||
|
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||||
|
_targetValues = ledValues;
|
||||||
|
|
||||||
// received a new target color
|
// received a new target color
|
||||||
if (_previousValues.empty())
|
if (_previousValues.empty())
|
||||||
{
|
{
|
||||||
// not initialized yet
|
// not initialized yet
|
||||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
|
||||||
_targetValues = ledValues;
|
|
||||||
|
|
||||||
_previousTime = QDateTime::currentMSecsSinceEpoch();
|
_previousTime = QDateTime::currentMSecsSinceEpoch();
|
||||||
_previousValues = ledValues;
|
_previousValues = ledValues;
|
||||||
|
|
||||||
//Debug( _log, "Start Smoothing timer: settlingTime: %d ms, interval: %d ms (%u Hz), updateDelay: %u frames", _settlingTime, _updateInterval, unsigned(1000.0/_updateInterval), _outputDelay );
|
//Debug( _log, "Start Smoothing timer: settlingTime: %d ms, interval: %d ms (%u Hz), updateDelay: %u frames", _settlingTime, _updateInterval, unsigned(1000.0/_updateInterval), _outputDelay );
|
||||||
QMetaObject::invokeMethod(_timer, "start", Qt::QueuedConnection, Q_ARG(int, _updateInterval));
|
QMetaObject::invokeMethod(_timer, "start", Qt::QueuedConnection, Q_ARG(int, _updateInterval));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//std::cout << "LinearColorSmoothing::write> "; LedDevice::printLedValues ( ledValues );
|
|
||||||
|
|
||||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
|
||||||
memcpy(_targetValues.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
|
||||||
|
|
||||||
//std::cout << "LinearColorSmoothing::write> _targetValues: "; LedDevice::printLedValues ( _targetValues );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -127,7 +118,7 @@ void LinearColorSmoothing::updateLeds()
|
|||||||
//Debug(_log, "elapsed Time [%d], _targetTime [%d] - now [%d], deltaTime [%d]", now -_previousTime, _targetTime, now, deltaTime);
|
//Debug(_log, "elapsed Time [%d], _targetTime [%d] - now [%d], deltaTime [%d]", now -_previousTime, _targetTime, now, deltaTime);
|
||||||
if (deltaTime < 0)
|
if (deltaTime < 0)
|
||||||
{
|
{
|
||||||
memcpy(_previousValues.data(), _targetValues.data(), _targetValues.size() * sizeof(ColorRgb));
|
_previousValues = _targetValues;
|
||||||
_previousTime = now;
|
_previousTime = now;
|
||||||
|
|
||||||
queueColors(_previousValues);
|
queueColors(_previousValues);
|
||||||
|
Loading…
Reference in New Issue
Block a user