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

ossia / score / 30213925900

26 Jul 2026 06:03PM UTC coverage: 15.298% (-0.01%) from 15.311%
30213925900

push

github

jcelerier
3rdparty: bump libossia for the network-context poll fix

Brings in ossia/libossia#913: SDL joystick init no longer requires haptic
support (which the Emscripten SDL2 port does not have), and
network_context::poll() restarts the io_context, without which the
WebAssembly polling path stops after its first tick.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019oPj1zRcxSQX7FNni7EHM6

30400 of 198713 relevant lines covered (15.3%)

997.67 hits per line

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

83.23
/src/lib/core/application/ApplicationInterface.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 "ApplicationInterface.hpp"
4

5
#include <score/command/Validity/ValidityCheckerList.hpp>
6
#include <score/graphics/BackgroundRenderer.hpp>
7
#include <score/model/ComponentSerialization.hpp>
8
#include <score/model/ObjectEditor.hpp>
9
#include <score/plugins/ProjectSettings/ProjectSettingsFactory.hpp>
10
#include <score/plugins/documentdelegate/DocumentDelegateFactory.hpp>
11
#include <score/plugins/panel/PanelDelegateFactory.hpp>
12
#include <score/plugins/qt_interfaces/CommandFactory_QtInterface.hpp>
13
#include <score/plugins/qt_interfaces/FactoryFamily_QtInterface.hpp>
14
#include <score/plugins/qt_interfaces/FactoryInterface_QtInterface.hpp>
15
#include <score/plugins/qt_interfaces/GUIApplicationPlugin_QtInterface.hpp>
16
#include <score/plugins/settingsdelegate/SettingsDelegateFactory.hpp>
17

18
#include <core/application/ApplicationRegistrar.hpp>
19
#include <core/messages/MessagesPanel.hpp>
20
#include <core/plugin/PluginManager.hpp>
21
#include <core/presenter/CoreApplicationPlugin.hpp>
22
#include <core/undo/Panel/UndoPanelFactory.hpp>
23
#include <core/undo/UndoApplicationPlugin.hpp>
24
#include <core/view/Window.hpp>
25

26
#include <QGuiApplication>
27
#include <QModelIndex>
28

29
#if defined(__EMSCRIPTEN__)
30
#include <QMainWindow>
31

32
#include <qpa/qwindowsysteminterface.h>
33
#endif
34
namespace score
35
{
36
ApplicationInterface* ApplicationInterface::m_instance;
37
ApplicationInterface::~ApplicationInterface() = default;
40✔
38

39
ApplicationInterface::ApplicationInterface()
40✔
40
{
40✔
41
  qRegisterMetaType<QModelIndex>();
40✔
42
  qRegisterMetaType<ObjectIdentifierVector>("ObjectIdentifierVector");
40✔
43
  qRegisterMetaType<Selection>("Selection");
40✔
44
  qRegisterMetaType<Id<score::DocumentModel>>("Id<DocumentModel>");
40✔
45
  qRegisterMetaType<QVector<int>>();
40✔
46
  qRegisterMetaType<QPair<QString, QString>>();
40✔
47
}
40✔
48

49
ApplicationInterface& ApplicationInterface::instance()
110,252✔
50
{
51
  return *m_instance;
110,252✔
52
}
53

54
GUIApplicationInterface& GUIApplicationInterface::instance()
160✔
55
{
56
  return *static_cast<GUIApplicationInterface*>(ApplicationInterface::m_instance);
160✔
57
}
58

59
GUIApplicationInterface::~GUIApplicationInterface() { }
36✔
60

61
static void loadDefaultPlugins(
36✔
62
    const score::GUIApplicationContext& ctx, score::GUIApplicationRegistrar& r,
63
    score::Settings& settings, score::Presenter& presenter)
64
{
65
  using namespace score;
66
  r.registerFactory(std::make_unique<DocumentDelegateList>());
36✔
67
  r.registerFactory(std::make_unique<ValidityCheckerList>());
36✔
68
  r.registerFactory(std::make_unique<BackgroundRendererList>());
36✔
69
#if defined(SCORE_SERIALIZABLE_COMPONENTS)
70
  r.registerFactory(std::make_unique<SerializableComponentFactoryList>());
71
#endif
72
  r.registerFactory(std::make_unique<ObjectEditorList>());
36✔
73
  auto panels = std::make_unique<PanelDelegateFactoryList>();
36✔
74
  panels->insert(std::make_unique<UndoPanelDelegateFactory>());
36✔
75
  panels->insert(std::make_unique<MessagesPanelDelegateFactory>());
36✔
76
  r.registerFactory(std::move(panels));
36✔
77
  r.registerFactory(std::make_unique<DocumentPluginFactoryList>());
36✔
78
  r.registerFactory(std::make_unique<SettingsDelegateFactoryList>());
36✔
79

80
  r.registerGUIApplicationPlugin(new CoreApplicationPlugin{ctx, presenter});
36✔
81

82
  if(bool(presenter.view()))
36✔
83
    r.registerGUIApplicationPlugin(new UndoApplicationPlugin{ctx});
8✔
84
}
36✔
85

86
void GUIApplicationInterface::loadPluginData(
36✔
87
    score::Settings& settings, score::Presenter& presenter)
88
{
89
  auto& ctx = presenter.applicationContext();
36✔
90
  score::GUIApplicationRegistrar registrar{
36✔
91
      presenter.components(), ctx, presenter.menuManager(), presenter.toolbarManager(),
36✔
92
      presenter.actionManager()};
36✔
93
  loadDefaultPlugins(ctx, registrar, settings, presenter);
36✔
94

95
  score::PluginLoader::loadPlugins(registrar, ctx);
36✔
96

97
  // Now rehash our various hash tables
98
  presenter.optimize();
36✔
99

100
  // Load the settings
101
  QSettings s;
36✔
102
  for(auto& elt : ctx.interfaces<score::SettingsDelegateFactoryList>())
468✔
103
  {
104
    settings.setupSettingsPlugin(s, ctx, elt);
432✔
105
  }
106

107
  if(presenter.view())
36✔
108
  {
109
    presenter.setupGUI();
8✔
110
  }
8✔
111
  for(score::ApplicationPlugin* app_plug : ctx.applicationPlugins())
216✔
112
  {
113
    app_plug->initialize();
180✔
114
  }
115
  for(score::GUIApplicationPlugin* app_plug : ctx.guiApplicationPlugins())
548✔
116
  {
117
    app_plug->initialize();
512✔
118
  }
119

120
  if(presenter.view())
36✔
121
  {
122
    for(auto& panel_fac : ctx.interfaces<score::PanelDelegateFactoryList>())
96✔
123
    {
124
      registrar.registerPanel(panel_fac);
88✔
125
    }
126

127
    auto& panels = registrar.components().panels;
8✔
128
    std::sort(panels.begin(), panels.end(), [](const auto& lhs, const auto& rhs) {
224✔
129
      return lhs->defaultPanelStatus().priority < rhs->defaultPanelStatus().priority;
216✔
130
    });
131

132
    for(auto it = panels.rbegin(); it != panels.rend(); ++it)
96✔
133
    {
134
      presenter.view()->setupPanel((*it).get());
88✔
135
    }
88✔
136
    presenter.view()->allPanelsAdded();
8✔
137
  }
8✔
138
}
36✔
139

140
void GUIApplicationInterface::registerPlugin(Plugin_QtInterface& p)
1✔
141
{
142
  auto plugin = &p;
1✔
143
  auto presenter = qApp->findChild<score::Presenter*>();
1✔
144
  if(!presenter)
1✔
145
    return;
×
146
  auto& components = presenter->components();
1✔
147
  auto& context = this->context();
1✔
148

149
  score::GUIApplicationRegistrar registrar{
1✔
150
      presenter->components(), context, presenter->menuManager(),
1✔
151
      presenter->toolbarManager(), presenter->actionManager()};
1✔
152

153
  if(auto i = dynamic_cast<score::FactoryList_QtInterface*>(plugin))
1✔
154
  {
155
    for(auto&& elt : i->factoryFamilies())
×
156
    {
157
      registrar.registerFactory(std::move(elt));
×
158
    }
159
  }
×
160

161
  std::vector<score::ApplicationPlugin*> ap;
1✔
162
  std::vector<score::GUIApplicationPlugin*> gap;
1✔
163
  if(auto i = dynamic_cast<score::ApplicationPlugin_QtInterface*>(plugin))
1✔
164
  {
165
    if(auto plug = i->make_applicationPlugin(context))
×
166
    {
167
      ap.push_back(plug);
×
168
      registrar.registerApplicationPlugin(plug);
×
169
    }
×
170

171
    if(auto plug = i->make_guiApplicationPlugin(context))
×
172
    {
173
      gap.push_back(plug);
×
174
      registrar.registerGUIApplicationPlugin(plug);
×
175
    }
×
176
  }
×
177

178
  if(auto commands_plugin = dynamic_cast<score::CommandFactory_QtInterface*>(plugin))
1✔
179
  {
180
    auto [key, cmds] = commands_plugin->make_commands();
×
181
    registrar.registerCommands(key, std::move(cmds));
×
182
  }
×
183

184
  ossia::small_vector<score::InterfaceBase*, 8> settings_ifaces;
1✔
185
  ossia::small_vector<score::InterfaceBase*, 8> panels_ifaces;
1✔
186
  if(auto factories_plugin = dynamic_cast<score::FactoryInterface_QtInterface*>(plugin))
1✔
187
  {
188
    for(auto& factory_family : registrar.components().factories)
38✔
189
    {
190
      ossia::small_vector<score::InterfaceBase*, 8> ifaces;
37✔
191
      const score::ApplicationContext& base_ctx = context;
37✔
192
      // Register core factories
193
      for(auto&& new_factory :
37✔
194
          factories_plugin->factories(base_ctx, factory_family.first))
37✔
195
      {
196
        ifaces.push_back(new_factory);
×
197
        factory_family.second->insert(std::unique_ptr<InterfaceBase>(new_factory));
×
198
      }
199

200
      // Register GUI factories
201
      for(auto&& new_factory :
38✔
202
          factories_plugin->guiFactories(context, factory_family.first))
37✔
203
      {
204
        ifaces.push_back(new_factory);
1✔
205
        factory_family.second->insert(std::unique_ptr<InterfaceBase>(new_factory));
1✔
206
      }
207

208
      if(dynamic_cast<score::SettingsDelegateFactoryList*>(factory_family.second.get()))
37✔
209
      {
210
        settings_ifaces = std::move(ifaces);
1✔
211
      }
1✔
212
      else if(dynamic_cast<score::PanelDelegateFactoryList*>(
36✔
213
                  factory_family.second.get()))
36✔
214
      {
215
        panels_ifaces = std::move(ifaces);
1✔
216
      }
1✔
217
    }
37✔
218
  }
1✔
219

220
  for(auto plug : ap)
1✔
221
    plug->initialize();
×
222
  for(auto plug : gap)
1✔
223
    plug->initialize();
×
224

225
  QSettings s;
1✔
226
  auto& settings = presenter->settings();
1✔
227
  for(auto& elt : settings_ifaces)
1✔
228
  {
229
    auto set = dynamic_cast<score::SettingsDelegateFactory*>(elt);
×
230
    SCORE_ASSERT(set);
×
231
    settings.setupSettingsPlugin(s, context, *set);
×
232
  }
233

234
  if(presenter->view())
1✔
235
  {
236
    for(auto& panel_fac : panels_ifaces)
2✔
237
    {
238
      auto p = static_cast<score::PanelDelegateFactory*>(panel_fac)->make(context);
1✔
239
      // A factory may decline (missing hardware, headless environment); a
240
      // null panel in the list crashes every later panels() iteration.
241
      if(!p)
1✔
242
      {
243
        qWarning() << "loadPluginData: panel factory made no panel:"
2✔
244
                   << typeid(*panel_fac).name();
1✔
245
        continue;
1✔
246
      }
247
      p->setModel(std::nullopt); // TODO why not current document
×
248
      components.panels.push_back(std::move(p));
×
249
      presenter->view()->setupPanel(components.panels.back().get());
×
250
    }
1✔
251
  }
1✔
252
}
1✔
253

254
void GUIApplicationInterface::requestExit()
2✔
255
{
256
  // The presenter is gone in headless setups and during late teardown;
257
  // exit requests arriving then have nothing left to close.
258
  if(auto pres = qApp->findChild<score::Presenter*>())
2✔
259
    pres->exit();
2✔
260
}
2✔
261

262
void GUIApplicationInterface::forceExit()
1✔
263
{
264
  requestExit();
1✔
265
  QTimer::singleShot(500, [] { QCoreApplication::quit(); });
1✔
266
}
1✔
267

268
GUIApplicationContext::GUIApplicationContext(
36✔
269
    const ApplicationSettings& a, const ApplicationComponents& b, DocumentManager& c,
270
    MenuManager& d, ToolbarManager& e, ActionManager& f,
271
    const std::vector<std::unique_ptr<SettingsDelegateModel>>& g, QMainWindow* mw)
272
    : score::ApplicationContext{a, b, c, g}
36✔
273
    , docManager{c}
36✔
274
    , menus{d}
36✔
275
    , toolbars{e}
36✔
276
    , actions{f}
36✔
277
    , mainWindow{mw}
36✔
278
{
279
  if(auto win = qobject_cast<score::View*>(mw))
36✔
280
  {
281
    documentTabWidget = win->centralTabs;
8✔
282
  }
8✔
283
}
×
284

285
SCORE_LIB_BASE_EXPORT const ApplicationContext& AppContext()
303✔
286
{
287
  return ApplicationInterface::instance().context();
303✔
288
}
289

290
SCORE_LIB_BASE_EXPORT const GUIApplicationContext& GUIAppContext()
160✔
291
{
292
  return GUIApplicationInterface::instance().context();
160✔
293
}
294

295
SCORE_LIB_BASE_EXPORT const ApplicationComponents& AppComponents()
109,949✔
296
{
297
  return ApplicationInterface::instance().components();
109,949✔
298
}
299

300
#if defined(__EMSCRIPTEN__)
301
SCORE_LIB_BASE_EXPORT void reclaimMainWindowFocus()
302
{
303
  QMainWindow* mw = GUIAppContext().mainWindow;
304
  if(!mw || mw->isActiveWindow())
305
    return;
306

307
  mw->activateWindow();
308
  mw->raise();
309
  QWindowSystemInterface::flushWindowSystemEvents();
310
}
311
#endif
312
}
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