mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fixing outstanding issues (#1537)
* Correct stopEnableAttemptsTimer thread affinity * Restart correctly, if running as service * Add instance# in API response * Qt6 updates * Update fallthrough guide * Update Compile warning
This commit is contained in:
parent
10b755b2ec
commit
2217135336
@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
///
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
namespace Process {
|
||||
|
||||
void restartHyperion(bool asNewProcess=false);
|
||||
void restartHyperion(int exitCode = 0);
|
||||
QByteArray command_exec(const QString& cmd, const QByteArray& data = {});
|
||||
|
||||
}
|
||||
|
@ -990,7 +990,7 @@ void JsonAPI::handleConfigCommand(const QJsonObject &message, const QString &com
|
||||
{
|
||||
Debug(_log, "Restarting due to RPC command");
|
||||
|
||||
Process::restartHyperion();
|
||||
Process::restartHyperion(10);
|
||||
|
||||
sendSuccessReply(command + "-" + subcommand, tan);
|
||||
}
|
||||
@ -1425,7 +1425,7 @@ void JsonAPI::handleAuthorizeCommand(const QJsonObject &message, const QString &
|
||||
if (!token.isEmpty())
|
||||
{
|
||||
// userToken is longer
|
||||
if (token.count() > 36)
|
||||
if (token.size() > 36)
|
||||
{
|
||||
if (API::isUserTokenAuthorized(token))
|
||||
sendSuccessReply(command + "-" + subc, tan);
|
||||
@ -1435,7 +1435,7 @@ void JsonAPI::handleAuthorizeCommand(const QJsonObject &message, const QString &
|
||||
return;
|
||||
}
|
||||
// usual app token is 36
|
||||
if (token.count() == 36)
|
||||
if (token.size() == 36)
|
||||
{
|
||||
if (API::isTokenAuthorized(token))
|
||||
{
|
||||
@ -1449,7 +1449,7 @@ void JsonAPI::handleAuthorizeCommand(const QJsonObject &message, const QString &
|
||||
|
||||
// password
|
||||
// use password
|
||||
if (password.count() >= 8)
|
||||
if (password.size() >= 8)
|
||||
{
|
||||
QString userTokenRep;
|
||||
if (API::isUserAuthorized(password) && API::getUserToken(userTokenRep))
|
||||
|
@ -171,6 +171,7 @@ void JsonCB::setSubscriptionsTo(Hyperion* hyperion)
|
||||
void JsonCB::doCallback(const QString& cmd, const QVariant& data)
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj["instance"] = _hyperion->getInstanceIndex();
|
||||
obj["command"] = cmd;
|
||||
|
||||
if (data.userType() == QMetaType::QJsonArray)
|
||||
|
@ -537,7 +537,7 @@ void MFGrabber::process_image(const void *frameImageBuffer, int size)
|
||||
Error(_log, "Frame too small: %d != %d", size, _frameByteSize);
|
||||
else if (_threadManager != nullptr)
|
||||
{
|
||||
for (int i = 0; i < _threadManager->_threadCount; i++)
|
||||
for (unsigned long i = 0; i < _threadManager->_threadCount; i++)
|
||||
{
|
||||
if (!_threadManager->_threads[i]->isBusy())
|
||||
{
|
||||
|
@ -67,8 +67,6 @@ LedDevice::LedDevice(const QJsonObject& deviceConfig, QObject* parent)
|
||||
|
||||
LedDevice::~LedDevice()
|
||||
{
|
||||
this->stopEnableAttemptsTimer();
|
||||
this->stopRefreshTimer();
|
||||
}
|
||||
|
||||
void LedDevice::start()
|
||||
@ -97,6 +95,7 @@ void LedDevice::start()
|
||||
void LedDevice::stop()
|
||||
{
|
||||
Debug(_log, "Stop device");
|
||||
this->stopEnableAttemptsTimer();
|
||||
this->disable();
|
||||
this->stopRefreshTimer();
|
||||
Info(_log, " Stopped LedDevice '%s'", QSTRING_CSTR(_activeDeviceType));
|
||||
|
@ -95,9 +95,9 @@ void LedDeviceAdalight::prepareHeader()
|
||||
|
||||
case Adalight::AWA:
|
||||
_bufferLength += 7;
|
||||
[[clang::fallthrough]];
|
||||
[[fallthrough]];
|
||||
case Adalight::ADA:
|
||||
[[clang::fallthrough]];
|
||||
[[fallthrough]];
|
||||
default:
|
||||
totalLedCount -= 1;
|
||||
_ledBuffer.resize(static_cast<size_t>(_bufferLength), 0x00);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace Process {
|
||||
|
||||
void restartHyperion(bool asNewProcess)
|
||||
void restartHyperion(int exitCode)
|
||||
{
|
||||
Logger* log = Logger::getInstance("Process");
|
||||
Info(log, "Restarting hyperion ...");
|
||||
@ -18,7 +18,8 @@ void restartHyperion(bool asNewProcess)
|
||||
|
||||
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
|
||||
|
||||
QCoreApplication::quit();
|
||||
//Exit with non-zero code to ensure service deamon restarts hyperion
|
||||
QCoreApplication::exit(exitCode);
|
||||
}
|
||||
|
||||
QByteArray command_exec(const QString& /*cmd*/, const QByteArray& /*data*/)
|
||||
@ -42,9 +43,15 @@ QByteArray command_exec(const QString& /*cmd*/, const QByteArray& /*data*/)
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <csignal>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMetaObject>
|
||||
|
||||
namespace Process {
|
||||
|
||||
void restartHyperion(bool asNewProcess)
|
||||
|
||||
void restartHyperion(int exitCode)
|
||||
{
|
||||
Logger* log = Logger::getInstance("Process");
|
||||
Info(log, "Restarting hyperion ...");
|
||||
@ -60,10 +67,11 @@ void restartHyperion(bool asNewProcess)
|
||||
|
||||
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
|
||||
|
||||
QCoreApplication::quit();
|
||||
//Exit with non-zero code to ensure service deamon restarts hyperion
|
||||
QCoreApplication::exit(exitCode);
|
||||
}
|
||||
|
||||
QByteArray command_exec(const QString& cmd, const QByteArray& data)
|
||||
QByteArray command_exec(const QString& cmd, const QByteArray& /*data*/)
|
||||
{
|
||||
char buffer[128];
|
||||
QString result;
|
||||
@ -73,7 +81,7 @@ QByteArray command_exec(const QString& cmd, const QByteArray& data)
|
||||
{
|
||||
while (!feof(pipe.get()))
|
||||
{
|
||||
if (fgets(buffer, 128, pipe.get()) != NULL)
|
||||
if (fgets(buffer, 128, pipe.get()) != nullptr)
|
||||
result += buffer;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void SysTray::createTrayIcon()
|
||||
|
||||
restartAction = new QAction(tr("&Restart"), this);
|
||||
restartAction->setIcon(QPixmap(":/restart.svg"));
|
||||
connect(restartAction, &QAction::triggered, this , [=](){ Process::restartHyperion(); });
|
||||
connect(restartAction, &QAction::triggered, this , [=](){ Process::restartHyperion(11); });
|
||||
|
||||
colorAction = new QAction(tr("&Color"), this);
|
||||
colorAction->setIcon(QPixmap(":/color.svg"));
|
||||
|
Loading…
Reference in New Issue
Block a user