Various Fixes/Updates (#1549)

* Update FindWindowsSDK.cmake

* cmake support libcec without version

* Ensure Light-Ids are strings

* Fix type - do not have dbus as requried

* Fixing #1544

* Cleanup

* CleanupFix #1551

* Consistently return instance number with JSON replies (#1504)

* hyperion-remote- Fix extracting reply for configGet request

* Qt 6.6 - Fix iterator finds

* Fix test_image2ledsmap

* Ensure window.currentHyperionInstanceName is set, cleanup system/log clipboard report

* Address protobuf cmake warning

* Update License

* Update ChangeLog

* Address CodeQL and clang findings
This commit is contained in:
LordGrey
2023-01-16 11:01:28 +00:00
committed by GitHub
parent f665f1e1b6
commit fa7a5b6b56
23 changed files with 187 additions and 102 deletions

View File

@@ -19,6 +19,7 @@
// Utility includes
#include <utils/Logger.h>
#include <utils/WeakConnect.h>
namespace {
constexpr std::chrono::milliseconds DEFAULT_DISCOVER_TIMEOUT{ 500 };
@@ -103,24 +104,6 @@ private slots:
void onServiceRemoved(const QMdnsEngine::Service& service);
private:
template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);
QMetaObject::Connection* conn_delete = new QMetaObject::Connection();
*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}
/// The logger instance for mDNS-Service
Logger* _log;

View File

@@ -51,7 +51,7 @@ namespace NetUtils {
{
if ((port <= 0 || port > MAX_PORT) && port != -1)
{
Error(log, "Invalid port [%d] for host: (%s)! - Port must be in range [0 - %d]", port, QSTRING_CSTR(host), MAX_PORT);
Error(log, "Invalid port [%d] for host: (%s)! - Port must be in range [1 - %d]", port, QSTRING_CSTR(host), MAX_PORT);
return false;
}
return true;

View File

@@ -0,0 +1,63 @@
#ifndef WEAKCONNECT_H
#define WEAKCONNECT_H
#include <type_traits>
// Qt includes
#include <QObject>
template <typename Func1, typename Func2, typename std::enable_if_t<std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
typename QtPrivate::FunctionPointer<Func2>::Object* receiver,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, receiver, slot);
QMetaObject::Connection* conn_delete = new QMetaObject::Connection();
*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}
template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);
QMetaObject::Connection* conn_delete = new QMetaObject::Connection();
*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}
template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
typename QtPrivate::FunctionPointer<Func2>::Object* receiver,
Func2 slot)
{
Q_UNUSED(receiver);
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);
QMetaObject::Connection* conn_delete = new QMetaObject::Connection();
*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}
#endif // WEAKCONNECT_H

View File

@@ -19,7 +19,7 @@
///
namespace hyperion {
void handleInitialEffect(Hyperion* hyperion, const QJsonObject& FGEffectConfig)
static void handleInitialEffect(Hyperion* hyperion, const QJsonObject& FGEffectConfig)
{
#define FGCONFIG_ARRAY fgColorConfig.toArray()
@@ -63,12 +63,12 @@ namespace hyperion {
#undef FGCONFIG_ARRAY
}
ColorOrder createColorOrder(const QJsonObject &deviceConfig)
static ColorOrder createColorOrder(const QJsonObject &deviceConfig)
{
return stringToColorOrder(deviceConfig["colorOrder"].toString("rgb"));
}
RgbTransform createRgbTransform(const QJsonObject& colorConfig)
static RgbTransform createRgbTransform(const QJsonObject& colorConfig)
{
const double backlightThreshold = colorConfig["backlightThreshold"].toDouble(0.0);
const bool backlightColored = colorConfig["backlightColored"].toBool(false);
@@ -81,7 +81,7 @@ namespace hyperion {
return RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, static_cast<uint8_t>(brightness), static_cast<uint8_t>(brightnessComp));
}
OkhsvTransform createOkhsvTransform(const QJsonObject& colorConfig)
static OkhsvTransform createOkhsvTransform(const QJsonObject& colorConfig)
{
const double saturationGain = colorConfig["saturationGain"].toDouble(1.0);
const double brightnessGain = colorConfig["brightnessGain"].toDouble(1.0);
@@ -89,7 +89,7 @@ namespace hyperion {
return OkhsvTransform(saturationGain, brightnessGain);
}
RgbChannelAdjustment createRgbChannelAdjustment(const QJsonObject& colorConfig, const QString& channelName, int defaultR, int defaultG, int defaultB)
static RgbChannelAdjustment createRgbChannelAdjustment(const QJsonObject& colorConfig, const QString& channelName, int defaultR, int defaultG, int defaultB)
{
const QJsonArray& channelConfig = colorConfig[channelName].toArray();
return RgbChannelAdjustment(
@@ -100,7 +100,7 @@ namespace hyperion {
);
}
ColorAdjustment* createColorAdjustment(const QJsonObject & adjustmentConfig)
static ColorAdjustment* createColorAdjustment(const QJsonObject & adjustmentConfig)
{
const QString id = adjustmentConfig["id"].toString("default");
@@ -120,7 +120,7 @@ namespace hyperion {
return adjustment;
}
MultiColorAdjustment * createLedColorsAdjustment(int ledCnt, const QJsonObject & colorConfig)
static MultiColorAdjustment * createLedColorsAdjustment(int ledCnt, const QJsonObject & colorConfig)
{
// Create the result, the transforms are added to this
MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt);
@@ -184,7 +184,7 @@ namespace hyperion {
* @param deviceOrder The default RGB channel ordering
* @return The constructed ledstring
*/
LedString createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder)
static LedString createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder)
{
LedString ledString;
const QString deviceOrderStr = colorOrderToString(deviceOrder);
@@ -215,7 +215,7 @@ namespace hyperion {
return ledString;
}
QSize getLedLayoutGridSize(const QJsonArray& ledConfigArray)
static QSize getLedLayoutGridSize(const QJsonArray& ledConfigArray)
{
std::vector<int> midPointsX;
std::vector<int> midPointsY;

View File

@@ -57,7 +57,9 @@ public:
break;
}
case QJsonValue::Object:
ret = getDefaultValue(value.toObject().find("default").value());
{
ret = getDefaultValue(value.toObject().value("default"));
}
break;
case QJsonValue::Bool:
return value.toBool() ? "True" : "False";