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

ossia / score / 33560887155

01 Sep 2026 09:24PM UTC coverage: 24.648% (+0.7%) from 23.997%
33560887155

Pull #2179

github

web-flow
Merge ecc0a2ad3 into 50d28933c
Pull Request #2179: Survive a build that does not have every plug-in

408 of 757 new or added lines in 47 files covered. (53.9%)

15 existing lines in 12 files now uncovered.

55851 of 226593 relevant lines covered (24.65%)

61526.39 hits per line

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

69.7
/src/plugins/score-lib-process/Process/ProcessFactory.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 "ProcessFactory.hpp"
4

5
#include <Process/OpaqueProcess.hpp>
6

7
#include <Process/HeaderDelegate.hpp>
8
#include <Process/LayerPresenter.hpp>
9
#include <Process/LayerView.hpp>
10
#include <Process/Process.hpp>
11
#include <Process/ProcessList.hpp>
12

13
#include <score/model/path/PathSerialization.hpp>
14

15
#include <QPainter>
16
#include <QTextOption>
17

18
#include <wobjectimpl.h>
19
namespace Process
20
{
21
ProcessModelFactory::~ProcessModelFactory() { }
102,717✔
22

23
Descriptor ProcessModelFactory::descriptor(const ProcessModel& m) const noexcept
122✔
24
{
25
  return descriptor(m.effect());
122✔
26
}
27

28
LayerFactory::~LayerFactory() { }
20,100✔
29

30
std::optional<double> LayerFactory::recommendedHeight() const noexcept
12✔
31
{
32
  return std::nullopt;
12✔
33
}
34

35
ProcessFactoryList::~ProcessFactoryList() { }
1,214✔
36

37
LayerFactoryList::~LayerFactoryList() { }
606✔
38

39
class DefaultLayerView final : public LayerView
40
{
41
public:
42
  DefaultLayerView(QGraphicsItem* parent)
4✔
43
      : LayerView(parent)
2✔
44
  {
2✔
45
  }
2✔
46
  void paint_impl(QPainter* p) const override
×
47
  {
48
    QTextOption o;
×
49
    o.setAlignment(Qt::AlignCenter);
×
50
    p->setPen(Qt::white);
×
51
    p->drawText(boundingRect(), m_txt, o);
×
52
  }
×
53
  QString m_txt;
54
};
55

56
class DefaultLayerPresenter final : public LayerPresenter
57
{
58
  Process::LayerView* m_view{};
59

60
public:
61
  DefaultLayerPresenter(
2✔
62
      const Process::ProcessModel& model, Process::LayerView* v, const Context& ctx,
63
      QObject* parent)
64
      : LayerPresenter{model, v, ctx, parent}
2✔
65
      , m_view{v}
2✔
66
  {
2✔
67
    auto vi = dynamic_cast<DefaultLayerView*>(v);
2✔
68
    vi->m_txt = model.metadata().getName();
2✔
69
    connect(&model.metadata(), &score::ModelMetadata::NameChanged, this, [=](auto t) {
2✔
70
      vi->m_txt = t;
×
71
      vi->update();
×
72
    });
×
73
  }
2✔
74

75
  ~DefaultLayerPresenter() override { }
4✔
76

77
  void setWidth(qreal width, qreal defaultWidth) override { m_view->setWidth(width); }
17✔
78
  void setHeight(qreal height) override { m_view->setHeight(height); }
17✔
79

80
  void putToFront() override { m_view->setVisible(true); }
2✔
81
  void putBehind() override { m_view->setVisible(false); }
×
82

83
  void on_zoomRatioChanged(ZoomRatio) override { }
5✔
84
  void parentGeometryChanged() override { }
18✔
85
};
86
LayerPresenter* LayerFactory::makeLayerPresenter(
2✔
87
    const ProcessModel& m, LayerView* v, const Context& context, QObject* parent) const
88
{
89
  return new DefaultLayerPresenter{m, v, context, parent};
2✔
90
}
×
91

92
LayerView* LayerFactory::makeLayerView(
2✔
93
    const ProcessModel& view, const Process::Context& context,
94
    QGraphicsItem* parent) const
95
{
96
  return new DefaultLayerView{parent};
2✔
97
}
×
98

99
Process::MiniLayer*
100
LayerFactory::makeMiniLayer(const ProcessModel& view, QGraphicsItem* parent) const
×
101
{
102
  return nullptr;
×
103
}
104

105
score::ResizeableItem* LayerFactory::makeItem(
41✔
106
    const ProcessModel&, const Process::Context& ctx, QGraphicsItem* parent) const
107
{
108
  return nullptr;
41✔
109
}
110

111
bool LayerFactory::hasCodeEditor(
×
112
    const ProcessModel&, const score::DocumentContext& ctx) const noexcept
113
{
114
  return false;
×
115
}
116
QWidget* LayerFactory::makeCodeEditor(
×
117
    const ProcessModel&, const score::DocumentContext& ctx, QWidget* parent) const
118
{
119
  return nullptr;
×
120
}
121

122
QWidget* LayerFactory::makeScriptUI(
×
123
    ProcessModel&, const score::DocumentContext& ctx, QWidget* parent) const
124
{
125
  return nullptr;
×
126
}
127

128
bool LayerFactory::hasExternalUI(
383✔
129
    const ProcessModel&, const score::DocumentContext& ctx) const noexcept
130
{
131
  return false;
383✔
132
}
133
QWidget* LayerFactory::makeExternalUI(
×
134
    ProcessModel&, const score::DocumentContext& ctx, QWidget* parent) const
135
{
136
  return nullptr;
×
137
}
138

139
HeaderDelegate* LayerFactory::makeHeaderDelegate(
290✔
140
    const ProcessModel& model, const Process::Context& ctx, QGraphicsItem* parent) const
141
{
142
  return new DefaultHeaderDelegate{model, ctx};
290✔
143
}
×
144
FooterDelegate* LayerFactory::makeFooterDelegate(
331✔
145
    const ProcessModel& model, const Process::Context& ctx) const
146
{
147
  return new DefaultFooterDelegate{model, ctx};
331✔
148
}
×
149

150
bool LayerFactory::matches(const ProcessModel& p) const
×
151
{
152
  return matches(p.concreteKey());
×
153
}
154

155
bool LayerFactory::isFallback() const noexcept
23,930✔
156
{
157
  return false;
23,930✔
158
}
159

UNCOV
160
bool LayerFactory::matches(const UuidKey<Process::ProcessModel>& p) const
×
161
{
162
  return false;
×
163
}
164

165
ProcessFactoryList::object_type* ProcessFactoryList::loadMissing(
7✔
166
    const UuidKey<Process::ProcessModel>& key, const VisitorVariant& vis,
167
    const score::DocumentContext& ctx, QObject* parent) const
168
{
169
  // No factory for this process: keep it as an opaque stand-in rather than
170
  // dropping it, so that saving from here does not delete it from the document
171
  // for everyone who does have the plug-in.
172
  switch(vis.identifier)
7✔
173
  {
174
    case DataStream::type(): {
175
      auto& des = static_cast<DataStream::Deserializer&>(vis.visitor);
1✔
176
      return new OpaqueProcessModel{key, des, parent};
1✔
177
    }
178
    case JSONObject::type(): {
179
      auto& des = static_cast<JSONObject::Deserializer&>(vis.visitor);
6✔
180
      return new OpaqueProcessModel{key, des, parent};
6✔
181
    }
182
  }
183
  return nullptr;
×
184
}
7✔
185

186
LayerFactory* LayerFactoryList::findDefaultFactory(const ProcessModel& proc) const
2,037✔
187
{
188
  if(auto* fac = findDefaultFactory(proc.concreteKey()))
2,037✔
189
    return fac;
1,993✔
190

191
  // Only a process standing in for an absent plug-in gets the fallback. Plenty
192
  // of ordinary processes have no layer either, and are deliberately not drawn
193
  // in a slot: handing them one would start rendering them.
194
  if(dynamic_cast<const OpaqueProcessModel*>(&proc))
44✔
195
    return fallbackFactory();
14✔
196
  return nullptr;
30✔
197
}
2,037✔
198

199
LayerFactory*
200
LayerFactoryList::findDefaultFactory(const UuidKey<ProcessModel>& proc) const
2,055✔
201
{
202
  for(auto& fac : *this)
26,014✔
203
  {
204
    if(fac.isFallback())
25,967✔
205
      continue;
2,053✔
206
    if(fac.matches(proc))
23,914✔
207
      return &fac;
2,008✔
208
  }
209
  return nullptr;
47✔
210
}
2,055✔
211

212
LayerFactory* LayerFactoryList::fallbackFactory() const
15✔
213
{
214
  for(auto& fac : *this)
30✔
215
  {
216
    if(fac.isFallback())
30✔
217
      return &fac;
15✔
218
  }
NEW
219
  return nullptr;
×
220
}
15✔
221

222
QString ProcessModelFactory::customConstructionData() const noexcept
340✔
223
{
224
  return {};
340✔
225
}
226
}
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