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

@ -43,13 +43,9 @@ BoblightClientConnection::BoblightClientConnection(Hyperion* hyperion, QTcpSocke
} }
BoblightClientConnection::~BoblightClientConnection() BoblightClientConnection::~BoblightClientConnection()
{
if (_priority < 255)
{ {
// clear the current channel // clear the current channel
_hyperion->clear(_priority); _hyperion->clear(_priority);
_priority = 255;
}
delete _socket; delete _socket;
} }
@ -82,13 +78,9 @@ void BoblightClientConnection::readData()
} }
void BoblightClientConnection::socketClosed() void BoblightClientConnection::socketClosed()
{
if (_priority < 255)
{ {
// clear the current channel // clear the current channel
_hyperion->clear(_priority); _hyperion->clear(_priority);
_priority = 255;
}
emit connectionClosed(this); emit connectionClosed(this);
} }
@ -164,7 +156,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
rgb.blue = blue; rgb.blue = blue;
// send current color values to hyperion if this is the last led assuming leds values are send in order of id // 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); _hyperion->setInput(_priority, _ledColors);
} }
@ -187,15 +179,12 @@ void BoblightClientConnection::handleMessage(const QString & message)
bool rc; bool rc;
int prio = messageParts[2].toInt(&rc); int prio = messageParts[2].toInt(&rc);
if (rc && prio != _priority) if (rc && prio != _priority)
{
if (_priority < 255)
{ {
// clear the current channel // clear the current channel
_hyperion->clear(_priority); _hyperion->clear(_priority);
// register new priority // register new priority
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString())); _hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
}
_priority = prio; _priority = prio;
return; return;
@ -205,10 +194,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
else if (messageParts[0] == "sync") else if (messageParts[0] == "sync")
{ {
// send current color values to hyperion // send current color values to hyperion
if (_priority < 255)
{
_hyperion->setInput(_priority, _ledColors); _hyperion->setInput(_priority, _ledColors);
}
return; return;
} }
} }
@ -216,12 +202,6 @@ void BoblightClientConnection::handleMessage(const QString & message)
Debug(_log, "unknown boblight message: %s", QSTRING_CSTR(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() void BoblightClientConnection::sendLightMessage()
{ {
char buffer[256]; char buffer[256];

View File

@ -63,7 +63,7 @@ private:
/// ///
/// @param message The boblight message to send /// @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 /// 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); hyperion->moveToThread(hyperionThread);
// setup thread management // setup thread management
connect(hyperionThread, &QThread::started, hyperion, &Hyperion::start); connect(hyperionThread, &QThread::started, hyperion, &Hyperion::start);
connect(hyperionThread, &QThread::finished, hyperionThread, &QObject::deleteLater);
connect(hyperion, &Hyperion::started, this, &HyperionIManager::handleStarted); connect(hyperion, &Hyperion::started, this, &HyperionIManager::handleStarted);
connect(hyperion, &Hyperion::finished, this, &HyperionIManager::handleFinished); connect(hyperion, &Hyperion::finished, this, &HyperionIManager::handleFinished);
connect(hyperion, &Hyperion::finished, hyperionThread, &QThread::quit, Qt::DirectConnection); connect(hyperion, &Hyperion::finished, hyperionThread, &QThread::quit, Qt::DirectConnection);