• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 35347425313

18 Sep 2026 12:57PM UTC coverage: 39.907% (+0.005%) from 39.902%
35347425313

push

github

jcelerier
bitfocus: reload the protocol settings of a saved device

The configuration a module was set up with never came back: the settings
widget only restored it when the settings still carried a live handler,
which never survives a save, and it appended the widget values to the
stored list instead of replacing them. A document therefore accumulated
duplicate keys whose trailing - empty - copy won in reconnect(), so a
configured webhook url was lost both in the dialog and in the module.

Restore the values once the module answers with its fields, whichever
path the settings came in through, and write each key once.
Deduplicating on load repairs the documents that already doubled.

The module path was also stored absolute, which only resolves on the
machine the device was created on: relativize it against the library
like every other file score references.

Along the way: keep the name of a device that already has one instead of
resetting it to the module's short name on every edit, keep the values of
fields the widget does not know how to render, and stop restarting the
module process when its own entry is picked again in the device list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

12 of 75 new or added lines in 4 files covered. (16.0%)

39 existing lines in 6 files now uncovered.

114929 of 287991 relevant lines covered (39.91%)

77343.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.49
/src/plugins/score-plugin-protocols/Protocols/Bitfocus/BitfocusSpecificSettingsSerialization.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "BitfocusSpecificSettings.hpp"
4

5
#include <State/Value.hpp>
6
#include <State/ValueSerialization.hpp>
7

8
#include <Protocols/NetworkWidgets/Serialization.hpp>
9

10
#include <score/serialization/BoostVariant2Serialization.hpp>
11
#include <score/serialization/DataStreamVisitor.hpp>
12
#include <score/serialization/JSONVisitor.hpp>
13
#include <score/tools/FilePath.hpp>
14

15
#include <set>
16
#include <vector>
17

NEW
18
QString Protocols::BitfocusSpecificSettings::enumeratorLabel() const
×
19
{
NEW
20
  const QString& prod = product.isEmpty() ? name : product;
×
NEW
21
  return brand.isEmpty() ? prod : brand + ": " + prod;
×
22
}
23

24
void Protocols::BitfocusSpecificSettings::deduplicateConfiguration()
4✔
25
{
26
  std::set<QString> seen;
4✔
27
  std::erase_if(configuration, [&seen](const auto& kv) {
4✔
NEW
28
    return !seen.insert(kv.first).second;
×
29
  });
30
}
4✔
31

32
template <>
33
void DataStreamReader::read(const Protocols::BitfocusSpecificSettings& n)
3✔
34
{
35
  m_stream << score::relativizeFilePath(n.path) << n.entrypoint << n.id << n.name
6✔
36
           << n.brand << n.product << n.nodeVersion << n.apiVersion << n.configuration
3✔
37
           << n.description;
3✔
38
  insertDelimiter();
3✔
39
}
3✔
40

41
template <>
42
void DataStreamWriter::write(Protocols::BitfocusSpecificSettings& n)
2✔
43
{
44
  m_stream >> n.path >> n.entrypoint >> n.id >> n.name >> n.brand >> n.product
2✔
45
      >> n.nodeVersion >> n.apiVersion >> n.configuration >> n.description;
2✔
46
  n.path = score::locateFilePath(n.path);
2✔
47
  n.deduplicateConfiguration();
2✔
48
  checkDelimiter();
2✔
49
}
2✔
50

51
template <>
52
void JSONReader::read(const Protocols::BitfocusSpecificSettings& n)
3✔
53
{
54
  obj["Path"] = score::relativizeFilePath(n.path);
3✔
55
  obj["Entrypoint"] = n.entrypoint;
3✔
56
  obj["Identifier"] = n.id;
3✔
57
  obj["Name"] = n.name;
3✔
58
  obj["Brand"] = n.brand;
3✔
59
  obj["Product"] = n.product;
3✔
60
  obj["NodeVersion"] = n.nodeVersion;
3✔
61
  obj["APIVersion"] = n.apiVersion;
3✔
62
  obj["Configuration"] = n.configuration;
3✔
63
  obj["Description"] = n.description;
3✔
64
}
3✔
65

66
template <>
67
void JSONWriter::write(Protocols::BitfocusSpecificSettings& n)
2✔
68
{
69
  n.path <<= obj["Path"];
2✔
70
  n.path = score::locateFilePath(n.path);
2✔
71
  n.entrypoint <<= obj["Entrypoint"];
2✔
72
  n.id <<= obj["Identifier"];
2✔
73
  n.name <<= obj["Name"];
2✔
74
  n.brand <<= obj["Brand"];
2✔
75
  n.product <<= obj["Product"];
2✔
76
  n.nodeVersion <<= obj["NodeVersion"];
2✔
77
  n.apiVersion <<= obj["APIVersion"];
2✔
78
  n.configuration <<= obj["Configuration"];
2✔
79
  n.description <<= obj["Description"];
2✔
80
  n.deduplicateConfiguration();
2✔
81
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc