Conditions with priority 255 removed in Boblight

Signal/Slot connection finished/deleteLater removed between HyperionDeamon/HyperionIManager

Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
Paulchen-Panther 2019-08-01 19:10:15 +02:00
parent 1960f7652d
commit 2e8014bdbb
No known key found for this signature in database
GPG Key ID: 84E3B692456B6840
3 changed files with 11 additions and 32 deletions

View File

@ -44,12 +44,8 @@ BoblightClientConnection::BoblightClientConnection(Hyperion* hyperion, QTcpSocke
BoblightClientConnection::~BoblightClientConnection()
{
if (_priority < 255)
{
// clear the current channel
_hyperion->clear(_priority);
_priority = 255;
}
// clear the current channel
_hyperion->clear(_priority);
delete _socket;
}
@ -83,12 +79,8 @@ void BoblightClientConnection::readData()
void BoblightClientConnection::socketClosed()
{
if (_priority < 255)
{
// clear the current channel
_hyperion->clear(_priority);
_priority = 255;
}
// clear the current channel
_hyperion->clear(_priority);
emit connectionClosed(this);
}
@ -164,7 +156,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
rgb.blue = blue;
// send current color values to hyperion if this is the last led assuming leds values are send in order of id
if ((ledIndex == _ledColors.size() -1) && _priority < 255)
if (ledIndex == _ledColors.size() -1)
{
_hyperion->setInput(_priority, _ledColors);
}
@ -188,14 +180,11 @@ void BoblightClientConnection::handleMessage(const QString & message)
int prio = messageParts[2].toInt(&rc);
if (rc && prio != _priority)
{
if (_priority < 255)
{
// clear the current channel
_hyperion->clear(_priority);
// clear the current channel
_hyperion->clear(_priority);
// register new priority
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
}
// register new priority
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
_priority = prio;
return;
@ -205,10 +194,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
else if (messageParts[0] == "sync")
{
// send current color values to hyperion
if (_priority < 255)
{
_hyperion->setInput(_priority, _ledColors);
}
_hyperion->setInput(_priority, _ledColors);
return;
}
}
@ -216,12 +202,6 @@ void BoblightClientConnection::handleMessage(const QString & message)
Debug(_log, "unknown boblight message: %s", QSTRING_CSTR(message));
}
void BoblightClientConnection::sendMessage(const QByteArray & message)
{
//std::cout << "send boblight message: " << message;
_socket->write(message);
}
void BoblightClientConnection::sendLightMessage()
{
char buffer[256];

View File

@ -63,7 +63,7 @@ private:
///
/// @param message The boblight message to send
///
void sendMessage(const QByteArray &message);
void sendMessage(const QByteArray &message) { _socket->write(message); };
///
/// Send a lights message the to connected client

View File

@ -68,7 +68,6 @@ bool HyperionIManager::startInstance(const quint8& inst, const bool& block)
hyperion->moveToThread(hyperionThread);
// setup thread management
connect(hyperionThread, &QThread::started, hyperion, &Hyperion::start);
connect(hyperionThread, &QThread::finished, hyperionThread, &QObject::deleteLater);
connect(hyperion, &Hyperion::started, this, &HyperionIManager::handleStarted);
connect(hyperion, &Hyperion::finished, this, &HyperionIManager::handleFinished);
connect(hyperion, &Hyperion::finished, hyperionThread, &QThread::quit, Qt::DirectConnection);