Skip to content

Commit 16a72c0

Browse files
committed
Ensure stable response
1 parent 0fcdfa6 commit 16a72c0

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

assets/webconfig/js/content_remote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ $(document).ready(function () {
6161

6262
// Update the channel adjustments
6363
function updateChannelAdjustments() {
64-
if (!window.serverInfo.adjustment) return;
64+
if (!window.serverInfo.adjustment || window.serverInfo.adjustment.length === 0) return;
6565

6666
$('.crtbody').html("");
6767
const sColor = sortProperties(window.serverSchema.properties.color.properties.channelAdjustment.items.properties);

include/api/JsonInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class JsonInfo
3030
static QJsonArray getActiveEffects(const Hyperion* hyperion);
3131
static QJsonArray getActiveColors(const Hyperion* hyperion);
3232
static QJsonArray getTransformationInfo(const Hyperion* hyperion);
33-
static QJsonObject getSystemInfo(const Hyperion* hyperion);
33+
static QJsonObject getSystemInfo();
3434
QJsonObject discoverSources (const QString& sourceType, const QJsonObject& params);
3535

3636
static QJsonObject getConfiguration(const QList<quint8>& instanceIds = {}, const QStringList& instanceFilteredTypes = {}, const QStringList& globalFilterTypes = {} );

libsrc/api/JsonAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ void JsonAPI::handleDeleteEffectCommand(const QJsonObject &message, const JsonAp
626626

627627
void JsonAPI::handleSysInfoCommand(const QJsonObject & /*unused*/, const JsonApiCommand& cmd)
628628
{
629-
sendSuccessDataReply(JsonInfo::getSystemInfo(_hyperion.get()), cmd);
629+
sendSuccessDataReply(JsonInfo::getSystemInfo(), cmd);
630630
}
631631

632632
void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const JsonApiCommand& cmd)

libsrc/api/JsonInfo.cpp

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
QJsonObject JsonInfo::getInfo(const Hyperion* hyperion, Logger* log)
2424
{
2525
QJsonObject info {};
26+
2627
// Global information
2728
info["ledDevices"] = JsonInfo::getAvailableLedDevices();
2829
info["cec"] = JsonInfo::getCecInfo();
@@ -35,32 +36,40 @@ QJsonObject JsonInfo::getInfo(const Hyperion* hyperion, Logger* log)
3536
info["components"] = JsonInfo::getComponents(hyperion);
3637

3738
// Instance specific information
39+
info["priorities"] = JsonInfo::getPrioritiestInfo(hyperion);
40+
info["adjustment"] = JsonInfo::getAdjustmentInfo(hyperion, log);
41+
info["activeLedColor"] = JsonInfo::getActiveColors(hyperion);
42+
#if defined(ENABLE_EFFECTENGINE)
43+
info["activeEffects"] = JsonInfo::getActiveEffects(hyperion);
44+
#endif
3845
if (hyperion != nullptr)
3946
{
40-
info["priorities"] = JsonInfo::getPrioritiestInfo(hyperion);
4147
info["priorities_autoselect"] = hyperion->sourceAutoSelectEnabled();
42-
info["adjustment"] = JsonInfo::getAdjustmentInfo(hyperion, log);
4348
info["videomode"] = QString(videoMode2String(hyperion->getCurrentVideoMode()));
44-
45-
info["imageToLedMappingType"] = ImageProcessor::mappingTypeToStr(hyperion->getLedMappingType());
49+
info["imageToLedMappingType"] = ImageProcessor::mappingTypeToStr(0);
4650
info["leds"] = hyperion->getSetting(settings::LEDS).array();
47-
info["activeLedColor"] = JsonInfo::getActiveColors(hyperion);
48-
#if defined(ENABLE_EFFECTENGINE)
49-
info["activeEffects"] = JsonInfo::getActiveEffects(hyperion);
50-
#endif
51+
}
52+
else
53+
{
54+
info["priorities_autoselect"] = false;
55+
info["videomode"] = QString(videoMode2String(VideoMode::VIDEO_2D));
56+
info["imageToLedMappingType"] = ImageProcessor::mappingTypeToStr(0);
57+
info["leds"] = QJsonArray();
5158
}
5259

5360
// BEGIN | The following entries are deprecated but used to ensure backward compatibility with hyperion Classic or up to Hyperion 2.0.16
5461
info["hostname"] = QHostInfo::localHostName();
55-
if (hyperion != nullptr)
56-
{
57-
info["transform"] = JsonInfo::getTransformationInfo(hyperion);
58-
}
62+
info["transform"] = JsonInfo::getTransformationInfo(hyperion);
5963
return info;
6064
}
6165

6266
QJsonArray JsonInfo::getAdjustmentInfo(const Hyperion* hyperion, Logger* log)
6367
{
68+
if (hyperion == nullptr)
69+
{
70+
return QJsonArray();
71+
}
72+
6473
QJsonArray adjustmentArray;
6574
for (const QString &adjustmentId : hyperion->getAdjustmentIds())
6675
{
@@ -136,7 +145,12 @@ QJsonArray JsonInfo::getAdjustmentInfo(const Hyperion* hyperion, Logger* log)
136145

137146
QJsonArray JsonInfo::getPrioritiestInfo(const Hyperion* hyperion)
138147
{
139-
return getPrioritiestInfo(hyperion->getCurrentPriority(), hyperion->getPriorityInfo());
148+
if (hyperion == nullptr)
149+
{
150+
return QJsonArray();
151+
}
152+
153+
return getPrioritiestInfo(hyperion->getCurrentPriority(), hyperion->getPriorityInfo());
140154
}
141155

142156
QJsonArray JsonInfo::getPrioritiestInfo(int currentPriority, const PriorityMuxer::InputsMap& activeInputs)
@@ -300,7 +314,7 @@ QJsonObject JsonInfo::getGrabbers(const Hyperion* hyperion)
300314
{
301315
QJsonObject grabbers;
302316

303-
quint8 idx {0};
317+
quint8 idx { GLOABL_INSTANCE_ID };
304318
if (hyperion != nullptr)
305319
{
306320
idx = hyperion->getInstanceIndex();
@@ -456,6 +470,12 @@ QJsonArray JsonInfo::getTransformationInfo(const Hyperion* hyperion)
456470
{
457471
// TRANSFORM INFORMATION (DEFAULT VALUES)
458472
QJsonArray transformArray;
473+
474+
if (hyperion == nullptr)
475+
{
476+
return transformArray;
477+
}
478+
459479
for (const QString &transformId : hyperion->getAdjustmentIds())
460480
{
461481
QJsonObject transform;
@@ -493,6 +513,12 @@ QJsonArray JsonInfo::getActiveEffects(const Hyperion* hyperion)
493513
{
494514
// ACTIVE EFFECT INFO
495515
QJsonArray activeEffects;
516+
517+
if (hyperion == nullptr)
518+
{
519+
return activeEffects;
520+
}
521+
496522
#if defined(ENABLE_EFFECTENGINE)
497523
for (const ActiveEffectDefinition &activeEffectDefinition : hyperion->getActiveEffects())
498524
{
@@ -515,6 +541,12 @@ QJsonArray JsonInfo::getActiveColors(const Hyperion* hyperion)
515541
{
516542
// ACTIVE STATIC LED COLOR
517543
QJsonArray activeLedColors;
544+
545+
if (hyperion == nullptr)
546+
{
547+
return activeLedColors;
548+
}
549+
518550
const Hyperion::InputInfo &priorityInfo = hyperion->getPriorityInfo(hyperion->getCurrentPriority());
519551
if (priorityInfo.componentId == hyperion::COMP_COLOR && !priorityInfo.ledColors.empty())
520552
{
@@ -555,7 +587,7 @@ QJsonArray JsonInfo::getActiveColors(const Hyperion* hyperion)
555587
return activeLedColors;
556588
}
557589

558-
QJsonObject JsonInfo::getSystemInfo(const Hyperion* hyperion)
590+
QJsonObject JsonInfo::getSystemInfo()
559591
{
560592
QJsonObject info;
561593

0 commit comments

Comments
 (0)